Assignment 6, due Mar. 12
Part of
the homework for 22C:112, Spring 2010
|
Always, on every assignment, please write your name legibly as it appears on your University ID and on the class list! All assignments will be due at the start of class on the day indicated (usually a Friday). The only exceptions to this rule will be by advance arrangement unless there is what insurance companies call "an act of God" - something outside your control. Homework must be turned in on paper and in class! Late work may be turned in to the teaching assistant's mailbox, but see the late work policy. Never push late work under someone's door!
Note that, on most Unix systems, the disk sector size is always 512 bytes. In 1970's, some disk vendors sold drives with unusual sector sizes such as 100 bytes. The economics of modern disk drives is such that, if software compatibility were not an issue, we might do better with larger sectors such as 4K bytes.
a) What is the basic function of the software layer between the read() and write() interface within the operating system and the layer inside the disk driver that actually enqueues disk I/O requests? (0.5 points)
b) The design of this layer could place it inside the I/O driver, or outside, common to all disk drivers. Explain the impact of the uniformity or non-uniformity of disk sector size on this decision. (0.5 points)
c) Explain how this layer could also serve as a disk cache. (0.5 points)
a) One of these is a system call. Which one. Explain how it relates to your answer to part (a) of problem 1. (0.5 points)
b) One of these is a part of the middleware in the C standard library. Explain how it relates to the system call. (0.5 points)
A Problem: Explain how a file system that maintains sequential files as linked lists of disk sectors (or some similar organization) would force the seek routine to return a cookie instead of an integer offset. Suggest what you would encode in the cookie if you were writing the library routine. (0.5 points)
Modify the example shell from MP1 so that, if the shell input comes from a file, it supports the following new built-in shell command:
loop n # any number of shell commands endloopHere, n is an integer (you can use atoi() to convert strings to integers), and the effect is to execute the shell commands between the loop and the endloop commands that number of times. There are at least two ways to do the iteration, one involving creating a temporary file holding the loop body and then repeatedly launching the shell to read that temporary file, and the other involving using either lseek() or fseek() to remember the position in the standard input file at the start of the loop and return to it for each new iteration (use the man command to get documentation).
Your loop implementation must support nested loops.
If run from an interactive terminal, the loop command should output an error message.