Skip to content

Find a certain number of primes in parallel using the PThreads API

Notifications You must be signed in to change notification settings

ruairidhm98/Multi-threaded-prime-finder

Repository files navigation

Multi-threaded-prime-finder

Find a certain number of primes entered as one of the command line arguments using the PThreads API. The collector thread inserts the primes as it recieves them into a min-heap. The generator threads are searching for the prime numbers. A bounded buffer implemented as a monitor was used to store the primes and then remove them at the same time. The program then prints out each prime in sorted order to the stdout then terminates.

How to Use

run the commands

make
./mtprimes -b <block> -l <limit> -t <num_threads>

block - the block each thread is searching through (e.g., one thread does 0..49, another 50..99, etc.)
limit - maximum range looking for primes
num_threads - number of threads fiding primes at the same time

About

Find a certain number of primes in parallel using the PThreads API

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published