CSC 213:  Operation Systems and Parallel Algorithms

Laboratory Exercise on Process Scheduling

Background:

The scheduling of processes within a computer depends upon three main factors:

Goals:

This lab has four basic goals:

Resources:

  1. Many elements of this laboratory exercise are based on Lab Exercise 7.1 in Nutt's text. In particular, students should read that material carefully for an explanation of the approach of event-driven simulation.

  2. Program ~walker/213/c-examples/simulation-sched.c and include-file ~walker/213/c-examples/fcfs_scheduler.c provides a basic framework for an event-driven simulation for the first-come, first-served (FCFS) non-preemptive scheduling algorithm.

Looking at the above code in more detail,

This program contains three debugging flags that can provide on-going information as the simulation runs:

Any combination of these flags can be invoked at compile time. For example, the following line invokes the input and timemonitor flags:


gcc -o simulation-sched -Dinput -Dtimemonitor simulation-sched.c && simulation-sched
Steps for this Lab:

Part A: Nonpreemptive Scheduling Algorithms

  1. Run the existing program to get timings for the FCFS scheduling algorithm, using schedulerOverhead as 0.0, 0.01, 0.02, 0.03, and 0.04 seconds.
    For this testing, you may use the test data from the text (as copied to two decimal digits of accuracy in simulation-sched.data.txt) or you may expand this file to include further processes.

  2. Change the include file from fcfs_scheduler.c to another that implements the SJN scheduling algorithm.

  3. Test the simulation with SJN for the same cases you did in Step 1.

  4. Compare the waiting times for FCFS and SJN. Does this suggest any conclusions regarding the relative effectiveness of these two scheduling algorithms?

Part B: Preemptive Scheduling Algorithms

  1. A simple Round-Robin (RR) scheduling can be obtained, using the FCFS scheduler you are given, but changing the processJob event handler. In this case, if the time quantum preemptiveAlg is positive, then a job is allowed to run continuously only for that time slice. If the job finishes in a time slice, then statistics for the job are compiled. Otherwise, the time remaining for the job is reduced by the time slice, and the scheduler is invoked again.

  2. Run the RR scheduling simulation for the same job sequence you defined in Part A, with the time quanta being 0.05, 0.1, 0.15, and 0.2 seconds .

  3. Change the include file from fcfs_scheduler.c to another than implements a multi-queue, priority system. Assume priorities are between 1 (most pressing importance) through 10 (not very important). In this variation, vary the time allocated to a job according to its priority:
    
      time interval = preemptiveAlg / 2^(priority-1)
    
  4. Again, run the resulting priority algorithm for the same job sequence defined in Part A and with the same time quanta listed in step B2.

  5. Compare the run times for the nonpreemptive and preemptive algorithms you obtained in your simulations. Can you make any conclusions regarding the relative effectiveness of these algorithms?


Work to be turned in:

Note: If you prefer, you may turn in the entire program (parts A and B) on Friday, October 1, in which case you need not turn in anything further on October 4.

This document is available on the World Wide Web as

     http://www.cs.grinnell.edu/~walker/courses/213.fa04/lab-scheduling.shtml

created September 26, 2004
last revised September 27, 2004
Valid HTML 4.01! Valid CSS!
For more information, please contact Henry M. Walker at (walker@cs.grinnell.edu)