Homework 10 Solutions

22C:116, Fall 1998

Douglas W. Jones
  1. Part A: The UNIX readv() kernel call is related to the problems raised by disk I/O to user buffers in a virtual memory environment. Specifically, if a buffer spans multiple pages of the user's virtual address space, the buffer will appear, in real memory, as if it is broken into fragments that are scattered through main memory. DMA I/O hardware that can read or write such scattered fragments of a buffer has been common since the introduction of the IBM System 360 in 1965, and the presence of such hardware makes it equally reasonable to support scattered buffers in the user's address space, such as are supported by the readv() kernel call.

    Part B: If an operating system maintains a buffer pool, perhaps also serving as a disk cache, so that all disk output involves, first, copying from the user's buffer to the system's buffer, and then scheduling the read or write, does this solves the problems posed by user buffers spanning page boundaries. The operating system software can easily gather the data from the scatterd parts of a user buffer and place this into system buffers before scheduling a disk write. As a result, the DMA hardware never needs to deal with buffers that are scattered through physical memory.

  2. Background Suppose a network contains 10 clocks, where the rates of clock drift are random and bounded. No clock drifts away from real time by more than .01 percent per day; clocks are equally likely to run fast or slow. Each machine runs a local clock synchronization algorithm once every day.

    For the following two synchronization algorithms, what is the maximum spread you would expect between the fastest clock and the slowest clock, and what is the long-term rate of drift you would expect for any clock in the network.

    Part A: If the local clock synchronization algorithm operates by having each clock periodically pick a random partner to synchronize with, the clocks will form a composite, and the times showing on all clocks will be held within an envelope centered on the average of all clocks, with a rate of drift determined by the average of the rates of drifts of all clocks.

    The spread in the values of the clocks is harder to figure. On the average, each of the 10 clocks will synchronize with any given clock once every 9 synchronization cycles (9 days); if all other interactions were ignored, the expected spread of the values of the clocks would be bounded by .0018 day, with the given clock holding an approximation of the average for the group and the others diverging from this average by up to .0009 day (9 days of drift at .01 percent per day). I would rely on a simulation model for a more precise estimate of the expected distribution of clock values.

    Part B: If the local clock synchronization algorithm samples all other clocks and adjusts the local time to the average shown by all, and this is done once per day, and clocks drift at a maximum rate of .01 percent per day, then the maximum error we expect for any clock from the average is .0001 day, or the maximum difference between two clocks is .0002 day. The long-term drift of each clock will be the same as the average of the natural rates of drift of all the clocks.

  3. If Ricart and Agrawala's algorithm is modified so that all requests must be answered immediately, there is no change in the fault tolerance of the algorithm. However, if, in addition, each requesting machine adds a time-out, and assumes that any machine that does not reply within the specified time interval has failed, then the algorithm becomes fault tolerant.

    This is still not completely fault tolerant! If a machine answeres immediately saying "no, do not enter, I will tell you when you may enter," the requesting machine knows that that machine has not failed. If, then, the machine fails, the requesting machine will wait forever for the deferred permission request. To solve this problem, each machine requesting entry to a critical section must periodically repeat its request.