CSCI 350 Fall 2001 Quiz 3

Statistics: (including the 8-point bonus)

mean     45.278 (815.000/18)
stddev   6.305
median   45.000
midrange 40.000-50.000

#   Average score
1   7.667 / 15
2a  6.889 / 7
 b  4.778 / 7
 c  5.611 / 7
3a  6.5   / 7
 b  5.833 / 7

  1. [15 pts] Say we have two processes - one that tracks a monitoring device and one that displays measurements from the device to the screen. The monitoring process gets data from the device once every five seconds. The displaying process updates the screen only when the user clicks a button. At these times, it updates with the latest measurement from the monitoring process. But if the user clicks twice in succession, the displaying process stalls until a new observation becomes available.

    One way of accomplishing this is with three variables. One holds the latest observation (latest), another (latest_id) associates a unique identification number with the current observation, and the last (last_read) tracks the identification number of the last observation read by the displaying process.

    We use a semaphore latest_lock to ensure that the correct identification number is associated with data sent or received.

    Following is C code for using this technique.

    void save_obs(int value) {      int read_obs() {
                                        while(latest_id == last_read);
        down(latest_lock);              down(latest_lock);
        latest = value;                 int ret = latest;
        is_good = true;                 is_good = false;
        up(latest_lock);                up(latest_lock);
                                        return ret;
    }                               }
    

    This implementation, however, involves some busy-waiting by read_obs(), bogging the CPU down when the user double-clicks the button. Design an approach that uses semaphores to eliminate this busy-waiting.

  2. [21 pts] An entry in the Minix process table has many fields. For each of the following fields, describe in your own words a specific circumstance where that field might be used and how that field is used. For each, I've listed lines where Minix references the fields.
  3. [14 pts] In your own words, describe the purpose of the following sets of lines within Minix. Describe both what the lines accomplish and also why Minix might want to accomplish it.