Question: Write a C Program that writes all the odd numbers from 1 to 1 0 0 , 0 0 0 to the output file. Open

Write a C Program that writes all the odd numbers from 1 to 100,000 to the output file. Open the file, write the next value, and close the file. Measure how much elapsed time it takes to complete this processing. The process should open and close the file 50000 times. Yes, it is inefficient, but we are trying to force some I/O usage.
Next have the program fork and create 10 separate processes. Each process would process a range of 1 to 100,000. One process would process 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. Next read the ten files to make one file with all the number.. Measure the elapsed time it takes for all 10 processes to complete, and to create the output file.
The goal is to show that by breaking up the task across processes (that do I/O), the total elapsed needed will be shorter. Make sure you choose elapsed time function in C to track time, versus CPU Clock time.
If your program is not finding a difference between the approaches or is taking too long, you can modify the 100,000 up or down.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!