Scott Santarromana

concurrent generation of hamming numbers

concurrent generation of hamming numbers

- 1 min

This was a fun little program I had to do for a concurrent programming course. It generates Hamming numbers, which are numbers of the form (2^k)(3^m)(5^n), where k, m and n are non-negative integers.

It has the following design:

Each dotted line represents a blocking queue and each box represents an individual thread. The “Multiply” boxes take an input and multiply it by it’s respective constant. These are then fed into the “3-In Ordered Merge” thread which takes the minimum value and sends it to the “4-Out Copy” thread. This thread then sends it to the “print” thread while also sending it to the “Multiply” threads. This is an elegant example of transforming a serial program into a concurrent one.

scott

scott

Technical Architect @ 6Street

rss facebook twitter github 500px youtube mail spotify lastfm instagram linkedin google google-plus pinterest medium vimeo stackoverflow reddit quora