CS 110 Homework Assignment 5
Due: Friday Dec 7, 9PM

  1. OSC, 6.15, pg 479, 4 Points
    Supermarkets are constantly faced with a problem similar to page reference in virtual memory systems. They have a fixed amount of shelf space to display an ever-increasing number of products. If an important new product comes along, say, 100% efficient dog food, some existing product must be dropped from the inventory to make room for it. The obvious replacement algorithms are LRU and FIFO. Which of these would you prefer?
  2. OSC, 6.16, pg 479, 3 Points
    Why are cache blocks always much smaller than virtual memory pages, often a hundred times smaller?
  3. T, 5.3, pg 237, 3 Points
    A disk is double interleaved, i.e., sectors are in the order 0, 3, 6, 1, 4, 7, 2, 5. It has eight sectors of 512 bytes per track, and a rotation rate of 300 rpm. How long does it take to read all the sectors of a track in order, assuming the arm is already correctly positioned, and 1/2 rotation is needed to get sector 0 under the head? What is the data rate? Now repeat the problem for a noninterleaved disk, i.e., sectors are in the order 0, 1, 2, 3, 4, 5, 6, 7, with the same characteristics. How much does the data rate degrade due to interleaving?
    Controllers may be able to read only every other block or maybe every second block - because of the time necessar to read a disk block, then get ready for the next block. Skipping blocks to give the controller time to transfer data to memory is called interleaving.
    Disk with 8 blocks per track, without interleaving block order - 0 1 2 3 4 5 6 7
    Disk with single interleaving block order - 0 4 1 5 2 6 3 7
    Disk with double interleaving block order - 0 3 6 1 4 7 2 5
  4. T, 5.7, pg 237, 5 Points
    In which of the four i/o software layers (Interrupt drivers, Device drivers, Device-independent os software, and User level software) is each of the following done.
    1. Computing the track, sector, and head for a disk read.
    2. Maintaining a cache of recently used blocks.
    3. Writing commands to the device registers.
    4. Checking to see if the user is permitted to use the device.
    5. Converting binary integers to ASCII for printing.
  5. T, 5.9, pg 238, 3 Points
    Disk requests come to the disk driver for cylinders 10, 22, 20, 2, 40, 6, and 38, in that order. A seek takes 6msec per cylinder moved. How much seek time is needed for:
    1. First come, first served
    2. Closet cylinder next.
    3. SCAN
    In all cases the arm is initially at 20 and moving towards track 0.
  6. T, 5.12, pg 238, 3 Points
    The clock interrupt handler on a certain computer requires 2 msec (including process switching overhead) per clock tick. The clock runs at 60Hz. What fraction of the CPU is devoted to the clock?
  7. T, 5.14, pg 238, 3 Points
    Consider how a terminal works. The driver outputs one character and then blocks. When the character has been printed, an interrupt occurs and a message is sent to the blocked drive, which outputs the next character and then blocks again. If the time to pass a message, output a character, and block is 4msec, does this method work well on 110 baud lines? How about 4800 baud lines?
  8. t.7.2, pg 313.
    2 Points
    Write a UNIX pipeline that prints the eighth line of file Z on standard output.
  9. t.7.5, pg 313.
    2 Points
    When the UNIX shell starts up a process, it puts copies of its environment variables, such as HOME, on the process' stack, so the process can find out what its home directory is. If this process should later fork, will the child automatically get these variables too?
  10. t.7.7, pg 313.
    2 Points
    To what hardware concept is a signal closely related? Give two examples of how signals are used.
  11. t.7.13, pg 313.
    3 Points
    If a UNIX process runs for 1 sec without competition from other processes, how long does it take for its CPU usage counter to get back down to 0?
    "Once a second, all process priorities are recalculated. First, all the CPU usage counters are divided by 2, so that processes are not punished forever for past CPU use. Then each process' priority is calculated according to the formula:
    New priority = base + CPU usage
    The base is normally 0..."
  12. t.7.14, pg 314. 2 Points
    About how long does it take to fork off a child process under the following conditions: text size = 100K bytes, data size = 20K bytes, stack size = 10K bytes, process table size = 1K, user structure = 5K. The kernel trap and return takes 1 msec, and the machine can copy one 32-bit word every 500nsec. Text segments are shared.
  13. s.21.6, pg 694 4 Points
    Does 4.2BSD UNIX give scheduling priority to I/O or CPU-bound processes? For what reason does it differentiate between these categories, and why is one given priority over the other? How does it know which of these categories fits a given process?

Last modified Nov 17, 01 by mike@cs.hmc.edu