CS 481: Test #1

Thursday, March 27

You have 75 minutes to complete this test. The test is open book, open notes. There are four questions of equal weight. Keep your answers short; each problem may have several questions, but each question has a concise and (for an OS question) unambiguous answer.

Problem 1. You have a preemptive scheduling system that works on the following principle: every fixed time period (quantum), a clock interrupts the current process and the OS evaluates the priority of each process in the ready queue (including the process interrupted), choosing that process to dispatch next which has the highest priority. The priority of a process changes with time: for each unit of time spent running, its priority increases by alpha and for each unit spent waiting in the ready queue its priority increases by beta. (Time spent blocked does not affect the priority.) alpha and beta are real-valued constants that can be negative, zero, or positive, depending on the goals of the scheduler.

  • What is the effective policy of this scheduler when alpha < beta?
  • In particular, what is the policy when alpha < 0 yet beta > 0? when both alpha and beta are positive?
  • Is this a good implementation of these policies?
  • Problem 2. A computer system completes jobs at the rate of mu jobs per unit time; jobs arrive at the rate of lambda jobs per unit time. If a job arrives when the system is busy, it is queued in a queue of size 5; if the queue is full, the job is simply discarded.

  • Show the state diagram for the system, clearly labeling each state and each transition.
  • Write and solve the equations to determine the probability of occupation of each state.
  • Assume that we have mu=2*lambda. What is the probability that the CPU will be idle? that a job will be discarded?
  • Problem 3. You are to control a one-lane bridge so as to avoid collisions and ensure reasonable efficiency. The bridge is quite long, so you can let several vehicles share it as long as they all go in the same direction; in fact, you should definitely do so in the interest of efficiency. Write pseudocode solutions (i.e., protocols that will avoid collisions, deadlocks, livelocks, and starvation) for routines "Enter bridge from the North," "Enter bridge from the South," "Exit bridge from the South," and "Exit bridge from the North," all routines which must be called by a car before (enter) it enters the bridge and immediately after (exit) it leaves the bridge. You may choose to use semaphores, a monitor, or rendez-vous, but justify your choice.

    Problem 4. Define and distinguish deadlock, livelock, and starvation; give a clear example of each. Of the three, only one is detectable; which one and why?

    Back to CS 481 home page