Write a mycopy program that shall copy a file from


Write a mycopy program that shall copy a file from the program's standard input (stdin) to its standard output (stdout). You are allowed to use only the functions open/read/write/close for I/O: no other I/O functions (such as fprintfprintffscanfscanf) shall be used, except for the user interaction (such as error reporting or printing help messages). The user shall specify the size of the read/write buffer (the number of bytes the program reads/writes "in one shot") on the command line. The data from the original file shall be redirected to the program's standard output, and the standard output of the program shall be redirected to the target file, e.g.:

mycopy 1024 < myfile.orig > myfile.copy

In this example, your program mycopy copies the content of the file myfie.orig into a new file myfile.copy in 1024 byte chunks. Remember that the last fragment of the input file can be shorter than B bytes.

Besides copying the file, the program measures its running time using the gettimeofday function, and reports the result to the standard error output (stderr).

For an arbitrary 10MB file, plot the program running time T against the buffer size B for B=5B, 10, 15, 20, 25, 50, 75, 100, 250, 500, 1kB, 1250B, 2500B, 5kB, 10kB, 25kB, 50kB, 100kB, 250kB, 500kB, 1MB (you may need to use log-log axes). Explain the chart.

You can use dd to create a 10MB zero-filled file named "/tmp/myfile":

dd if=/dev/zero of=/tmp/myfile count=5kB bs=1000

Submit the program source code and the chart. Suggestion: use gnuplot to produce the chart. Do not discard the data you collected to build the chart: you will need them in the future.

 

Request for Solution File

Ask an Expert for Answer!!
Basic Computer Science: Write a mycopy program that shall copy a file from
Reference No:- TGS0968168

Expected delivery within 24 Hours