CSci351 Introduction to File Processing: Homework 1
Due date: Monday, February 11, 2008 in class
Each homework may have a different weight, which depends on its level of difficulty.
Absolutely no copying others' work
- Show how to change the permissions on a file
myFile
so the owner has read, write, and execute permissions, group members have read and execute permission, and others have execute permission. (05%)
- Find what value is used to indicate end-of-file in the
stdio.h/cstdio
of C/C++. (05%)
- Write a C/C++ program to create a file and store a string in it.
Write another C/C++ program to open the file and read the last ten bytes of the string and put it into the variable
myString
. (15%)
- Write a C/C++ program to implement the Unix command tail -n, where n is the number of lines from the end of the file to be copied to
stdout
. (15%)
- The ABC 1234 disk drive has the following features:
- It uses block addressing, where the extra space used by an interblock gap is equivalent to 150 bytes.
- It has 20,000 usable bytes available per track, 40 tracks per cylinder, and 400 cylinders per drive.
- Assume that the blocking factor is 20.
Suppose you have a file with 300,000 200-byte records that you want to store on a 1234 drive.
Answer the following questions:
- How many blocks can be stored on one track? How many records? (10%)
- How many cylinders are required to hold the file? How much space will go unused due to internal track fragmentation? (10%)
- If the file were stored on contiguous cylinders and if there were no interference from other processing using the disk drive, the average seek time for a random access of the file would be about 10.0 msec and the time to read one track is 12.0 msec.
Use this rate to compute the average time needed to access one record randomly. (10%)
- Consider a mailing-list file with 1,500,000 100-byte records.
The file is to be backed up on a tape drive which has the following features:
- It has 4800-foot reels of 6250-bpi and nine-track tape with 0.5-inch interblock gaps.
- Tape speed is 300 inches per second.
- Blocking factor of 40 is used.
Answer the following questions.
- How many extra records could be accommodated on a 4800-foot tape? (10%)
- What is the nominal transmission rate? (05%)
- How long would it take to read one block, including the gap?
What would the effective transmission rate be?
How long would it take to read the entire file? (15%)