Question: Write a C program that uses pthreads to compute the number of prime numbers between multiple ranges of specified low and high values inclusive. Here
Write a C program that uses pthreads to compute the number of prime numbers between multiple ranges of specified low and high values inclusive. Here is an example execution: p3 3 103 1000 2000 3000 4000 The first range is 3 through 103, the second is 1000 through 2000, and the third is 3000 through 4000, al inelusive. You can assume that there will be no more than 4 ranges of values, implying that you will need to create no more than 4 threads Note that you only count the total number of primes found in each range, and not the actual prime numbers themselves. The mainline program should NOT perform any of the it should create one pthread to examine cach range. BE SURE TO HAVE THIS AS THE FIRST EXECUTABLE LINE IN YOUR PROGRAM Use timel from timedemo.e in main to determine the amount of time between starting the threads and termination of all threads. The print should contain EXACTLY 1 LINE OF OUTPUT containing these values the total time the total mumber of primes the number of primes in range 1 the number of primes in range 2 An example print for the above test might be: 0,014 281 26 135 120 where I just made up the 0,014 time. #include
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
