Write a C Program that writes all the numbers from 1 to 100,000 that are both prime and the sum of the digits > 9. For example 47, 911 are 2 such numbers, since the sum of the digits is > 9. After finding a number, you must immediately write it to the output file. Open the file, write the number you just found, and close the file. Measure how much elapsed time it takes to do this processing. Yes, it is inefficient, but we are trying to force some I/O usage, which will cause interrupts. When this process is completed, next have the program fork and create 10 separate processes. Each process would find search a range of 1 to 100,000 for these prime and sum 11 numbers. One process searches 1 to 10000, another 10001 to 20000 etc. Each process performs the exact same tasks , in the same way, as the first part of the problem, but write the output to 10 separate files, one for each process. When all 10 processes are done, read the ten files to make one file with all the numbers. Measure the elapsed time it takes for all 10 processes to complete, and to create the output file. Make sure you research the difference between capturing CPU time and elapsed time. The CPU time will be the same, but the elapsed time is different between the two approaches
Write a C Program that writes all the numbers from 1 to 100,000 that are both prime and the sum of the digits > 9. For example 47, 911 are 2 such numbers, since the sum of the digits is > 9. After finding a number, you must immediately write it to the output file. Open the file, write the number you just found, and close the file. Measure how much elapsed time it takes to do this processing. Yes, it is inefficient, but we are trying to force some I/O usage, which will cause interrupts.
When this process is completed, next have the program fork and create 10 separate processes. Each process would find search a range of 1 to 100,000 for these prime and sum 11 numbers. One process searches 1 to 10000, another 10001 to 20000 etc. Each process performs the exact same tasks , in the same way, as the first part of the problem, but write the output to 10 separate files, one for each process. When all 10 processes are done, read the ten files to make one file with all the numbers. Measure the elapsed time it takes for all 10 processes to complete, and to create the output file.
Make sure you research the difference between capturing CPU time and elapsed time. The CPU time will be the same, but the elapsed time is different between the two approaches.
Step by step
Solved in 2 steps with 2 images