CS 481: Solutions for Assignment #2

Problem 4. What happens under each of the following scheduling algorithms on a heavily overloaded system? Discuss average waiting times of short, medium, and long jobs as we go from light to heavy loads. The question is rather vague. It says little about the nature of the jobs (I/O bound or CPU bound?), which would have at least as much effect at their length.

Problem 5. Give a non-computer example of preemptive and of nonpreemptive scheduling. It is easy to think of nonpreemptive scheduling: almost any queueing will do, such as a bank or grocery store queue. There may be external interrupts that take the job (a customer) off the processor (the clerk) for quick interrupt servicing (a phone call, for instance), but not preemption, because the processor is always returned to the job until the job is completed. A true preemptive example is harder. We want an example where a job is taken off the processor after using a certain amount of time, but may return later for more time. Preemption is not just any interrupt: it is an interrupt by which a process actually loses its turn. But appointments are often based on preemptive scheduling (it's really deadline scheduling): even if your business is not over when the time scheduled for the appointment is over, you have to leave and possibly make another appointment to finish your business. Again, interrupts may occur during the appointment (such as a phone call), but, as long as the processor (lawyer, physician) returns to you, this not true preemption. If the physician is called to the bedside of a desperate patient, however, and tells you that she won't be able to return and that you should come back some other day, then that is also real preemption. In an emergency room, the physician rotates her time among the patients, giving higher priority to the more critically sick or injured ones; the system behaves much like a round-robin with priority-based quantum sizes and definitely uses preemption.

Problem 7. In a deadline scheduling system, job A's deadline occurs before job B's. Prove that we should run A before B, that is, prove that, if running A before B fails to meet one deadline, running B before A will also fail to meet one deadline. Let the current time be 0, without loss of generality. Denote the deadlines by dA and dB and the execution times by tA and tB, respectively. We are given dA < dB. If the first schedule fails a deadline, it fails that for A or that for B. If it fails dA, it will also fail dA in the second schedule, since A terminates later in the second schedule than in the first. If it failed dB in the first schedule, then we have tB+tA > dB > dA; but then the second schedule, which completes A after tA+tB time units (i.e., when the first schedule completes B), fails dA.

Back to CS 481 home page