Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

1. Complete question 2 in Part 2 of lab 1. 2. Study the linux/unix command cat to understand its basic functionality. 3. Study the attached

1. Complete question 2 in Part 2 of lab 1.

2. Study the linux/unix command "cat" to understand its basic functionality.

3. Study the attached source code (mycat.c) which implements the "cat" command using standard I/O functions.

4. Rewrite the attached mycat.c program in 3 using read, write, open and close (System I/O functions) instead of the standard I/O functions.

There is no submissions required for questions 2 and 3. You only need to submit your answers to questions 1 and 4. Specifically, for question 1, you need to submit the table you created using the data you collected, for each different size of the array, attach a screenshot showing the user CPU, System CPU, and Clock time you obtained for that array size on your machine. For question 4, you just need to submit your source code.

image text in transcribed
Part 2 Now get to the system programming part of this lab. 1. In class we discussed a few different flags when opening/creating a file. There are many discussed in the textbook, many of them are not related to what we are learning right now. Could you write a program that makes use of the flags O_CREAT and O_EXCL, and observe what does it do when try to open an existing file? 2. Unix system i/o is not buffered, which means every read and write operate are carried out immediately on disk, which is very inefficient in most cases. We discussed a program called copy.c on slide page 8 (unix file i/o). Note the size of the array of characters holding the information to be read and written in the program is 100. Change the size of the array to 1, 64, 512, 4096, 8192, 16384, 65536, and run the program on the same large file of your choice, and use the time command to record the times and produce a table similar to the one below from our textbook. BUFFSIZE User CPU System CPU Clock time Number (seconds) (seconds) (seconds) of loops 20.03 117 50 138.73 516,581,760 9.69 58.76 68.60 258,290,880 4.60 36.47 41.27 129,145,440 8 2.47 15.44 18.38 64,572,720 16 1 07 7.93 9.38 32,286,360 32 0.56 4.51 8.82 16,143,180 64 0.34 2.72 8.66 8,07 1,590 128 0.34 1.84 8.69 4,035,795 256 0.15 1.30 8.69 2,017,898 512 0.09 0.95 8.63 1,008,949 1,024 0102 0.78 504,475 2,048 0104 D.66 8. 68 252,238 1,096 0.03 0.58 8.62 126,119 8,192 0.54 8.52 63,060 16,384 0.01 0.56 8.69 31,530 32,768 D.00 0.56 8.51 65,536 15,765 201 0.56 9.12 7,883 131,072 0.00 0.58 9.08 3,942 262,144 D.OD D.60 8.70 1,971 524,283 0.01 0.58 8.58 986

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

Modern Dental Assisting

Authors: Doni Bird, Debbie Robinson

13th Edition

978-0323624855, 0323624855

Students also viewed these Programming questions

Question

What are the major benefits of business ownership?

Answered: 1 week ago