Question: Task 2 : read Write a small C program that opens a file ( / usr / lib / locale / locale - archive on

Task 2: read
Write a small C program that opens a file (/usr/lib/locale/locale-archive on the department servers is a reasonable choice due to its size; though it is rather small by today's standards) and reads the contents of that file using the read system call. Write this code in a manner that allows you to easily change the number of bytes read (use a #define for the array size and argument to read).
Your program must not print anything (doing so will skew the timings discussed below).
Run this program with sizes 1,2,16,32,64,128,256,512,1024,2048,4096, and 8192(yes, all of these; it shouldn't take that long) and record the running time with the time program on the command-line (e.g., at the prompt, type time ./a. out and record the "real" time). Plot the results; can you infer any characteristics about the system?
Task 3: fread
Copy your program from above and modify it to use the fread library function in place of the read system call (and fopen instead of open).
Run the program with the same sizes and above and plot the execution times.
 Task 2: read Write a small C program that opens a

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 Databases Questions!