CSE 451 - Winter 1999

Sample Solutions, Quiz 3

Chapter 5, Silberschatz and Galvin, 5th edition

  1. n! possible schedules, assuming each process is allowed to run to completion once it has started. That's because there are n choices for the first process, n-1 for the second, n-2 for the third, and so on, producing (n)(n-1)(n-2)...(1) = n! schedules.

  2. In nonpreemptive scheduling, the running process only leaves the CPU by giving it up voluntarily, either by making a request via a system call, or by calling yield(). (Well, technically, yield() is a request too, but let's not get picky.)

    In preemptive scheduling, a timer goes off every so often, and the scheduler runs. The scheduler decides whether the currently running process gets to retain control of the CPU or not.

    Strict nonpreemptive scheduling is not good for use in a computer center because there is no incentive to give up the CPU other than altruism, so once a user gets onto the CPU no one else gets a turn until that user deigns to give up the CPU.

  3. Here is the set of processes:
    Process   Burst Time   Priority
    -------------------------------
       1          10          3
       2           1          1
       3           2          3
       4           1          4
       5           5          2
    
  4. Here is the set of processes:
    Process   Arrival Time   Burst Time
    -----------------------------------
       1          0.0            8
       2          0.4            4
       3          1.0            1
    
  5. RR with entries in ready queue as pointers to PCBs.

  6. Why might you want different quanta for different levels on the multi-level queueing system? Well, imagine a single queue. How do you set the quantum for that queue? You want it to be long enough that you can get some real work done without having to context switch all the time, but short enough that interactive processes can get quick response times. A very natural division for queues is to have one queue (with a short quantum) for interactive jobs which need quick response time but won't need the CPU for long and another queue (with a long quantum) for long-running jobs which don't need quick response time but will use their entire quantum each run. Then you have the best of both worlds.

  7. Beta is the priority rate of change for the running process, alpha is the priority rate of change for waiting processes, and new processes start at priority 0.

  8. What relation holds between these pairs of algorithms?
  9. Suppose a short-term CPU scheduling algorithm favors processes that have used the least CPU time in the recent past. Then take two jobs, an I/O bound job and a CPU bound job. The I/O bound job, when given a chance to run, will execute a few instructions and then immediately block on I/O, because that's what it means to be I/O bound. Then the CPU bound job will run, and it will run until it is preempted, churning away on the CPU the entire time, because that's what it means to be CPU bound. When the scheduler looks at the recent history and chooses who to run next, it will run the I/O bound job whenever possible. (Now, the I/O bound job will not always be available, since it will spend a lot of time on the waiting queue rather than on the ready queue, so the CPU bound job will get its time too.)

  10. How much does each scheduling algorithm favor short processes?