Prime Number Generator with Processes

Program Description

This program demonstrates how to communicate between processes using pipes. More specifically, it generates prime numbers through the Sieve of Eros algorithm.

The program spawns 4 processes--the first of which simply sends all odd numbers to the second process. The second process then attempts to divide the numbers it receives by 3 or 5. Numbers that pass are consequently sent to process 3, which attempts to divide the received numbers by 7, 11, 13, and 17. Lastly, any numbers passing this test are then sent to the final process. This process tests each received number against all known prime numbers, and if the number passes, it is added to the list of primes.

Features

Sample Run

 
kevin@LightningJoe:~/public_html/portfolio/png-pipes$ ./png-pipes 75

Known Prime: 3
Known Prime: 5
Known Prime: 7
Known Prime: 11
Known Prime: 13
Known Prime: 17
Prime: 19
Prime: 23
Prime: 29
Prime: 31
Prime: 37
Prime: 41
Prime: 43
Prime: 47
Prime: 53
Prime: 59
Prime: 61
Prime: 67
Prime: 71
Prime: 73