Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

*********Program in C only****** Write a C Program that writes all the numbers from 1 to 100,000 that are both prime and the sum of

*********Program in C only******

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 (use 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 Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions

Question

Distinguish between hearing and listening.

Answered: 1 week ago

Question

Use your voice effectively.

Answered: 1 week ago