CSC 213, Fall 2008 : Schedule : Lab 5

Lab 5: Scheduling Algorithms

Background:

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

  1. whether a process is allowed to run to completion once it is started (i.e., whether scheduling is preemptive or nonpreemptive);
  2. the specific algorithm used to determine the next job to be scheduled; and
  3. the time slice given to a process, if preemptive scheduling is used.
In this lab, you will compare average wait time and system throughput for several scheduling algorithms.

Goals:

In this lab, you will

  1. Gain first-hand experience implementing several scheduling algorithms.
  2. Apply the event-driven simulation approach to the problem of modeling the behavior of a system over time.
  3. Obtain comparative data on throughput and average waiting time for different scheduling algorithms and varying scheduler overhead.
  4. Get more experience with list structures in C.

Reading:

Collaboration: You will complete this lab in teams of 1 to 3 of your choice. You may, as always, consult with your classmates on issues of design and debugging.


Overview of Starter Code

scheduler.h

This header declares some structure types and functions specific to job scheduling:

scheduler_fcfs.c

This file contains implementations of the functions above for the FCFS scheduling algorithm. Other scheduling algorithms will also need their own implementations of these functions. If you wish, you may use scheduler_fcfs.c as a template for implementing the Shortest Job Next (SJN) and Priority scheduling algorithms according to the scheduler.h interface.

scheduler_simulation.c

This program incorporates a scheduling algorithm into an event-based simulation. The program contains three debugging flags that can provide on-going information as the simulation runs: Any combination of these flags can be specified at compile time. See the example Makefile. Similarly, you can override the values of SCHEDULER_OVERHEAD and TIME_QUANTUM at compile time.

Part A

Non-preemptive scheduling algorithms

  1. Run the existing program to get average waiting times and throughputs for the FCFS scheduling algorithm, using values of 0.0, 0.01, 0.02, 0.03, and 0.04 for the SCHEDULER_OVERHEAD. (Record your measurements in a text file or a spreadsheet.)
  2. Implement the SJN scheduling algorithm, using the scheduler.h interface described above.
  3. Compile your own SJN scheduler and link it with scheduler_simulation.c.
  4. Run the simulation with SJN for the same cases as in step 1.
  5. Compare the average waiting times and throughputs for FCFS and SJN. Does this information suggest any conclusions regarding the relative effectiveness of FCFS and SJN?

Part B: Preemptive scheduling algorithms

  1. A simple Round-Robin (RR) scheduling algorithm can be obtained by using the FCFS scheduler you are given, but changing the processJob event handler in scheduler_simulation.c as indicated by /* YOUR CODE HERE */. If the constant TIME_QUANTUM is positive, then a job is allowed to run continuously only for that time slice. If the job will not finish within the time slice, then 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 values of SCHEDULER_OVERHEAD you did in step A.1, with the time quanta being 0.05, 0.1, 0.15, and 0.2. (Record your measurements in a text file or a spreadsheet.)
  3. Implement a multi-queue priority algorithm, using the scheduler.h interface described above. Assume priorities are from 1 (most important) through 10 (not very important). Vary the time slice allocated to a job according to its priority:
    time_quantum = TIME_QUANTUM / 2^(priority-1)
  4. Again, run the resulting priority algorithm for the same values of SCHEDULER_OVERHEAD given in step A.1 and the same time quanta specified in step B.2.
  5. Compare the average waiting times and throughputs for the non-preemptive and preemptive algorithms you obtained in your simulations. Can you draw any conclusions regarding the relative effectiveness of these algorithms?

Work to be Turned In

This lab is due Tuesday 10/7.

As always, for the programs in steps A.2, B.1, and B.3, please follow the instructions for submitting programs.

Note that the exam is Friday 10/3. While the lab has been "partitioned," it is not due in its entirety until Tuesday 10/7 so that you have ample time to study. According to syllabus, the exam carries three times more weight than any given lab.


Jerod Weinman

Created June 24, 2008
Based on CSC 213, Fall 2006 : Lab 5 : Scheduling Algorithms
With thanks to Janet Davis and Henry Walker