Assignment 2: CPU Scheduling

Parts I and II of the scheduling assignment focus on basic "paper & pencil" scheduling and the use of a pre-existing scheduling simulator. Your submission should consist of a single PDF or Word document and a compressed archive (zip or tarball) containing simulator setup files for part II. Note that because Blackboard prefers a single handin you should simply package these items up together (zip/tar files are acceptable).

If you find it easier than creating diagrams using software, you may choose to hand draw (neatly!) and scan your charts for part I.

I: Basic algorithms and measurements (24 points)

In part I, you'll apply your understanding of the scheduling algorithms discussed in class to work through some scenarios involving a limited number of processes with given arrival times and CPU burst durations. Be sure to show all your work for full credit!

Consider the following processes:

Process CPU Burst Arrival Time
P0 2 0
P1 10 1
P2 6 5
P3 3 7

1. FCFS

2. Preemptive SJF

Repeat question 1 (all parts) using the preemptive shortest job first (SJF) scheduling algorithm.

3. Round Robin

Repeat question 1 (all parts) using the round robin scheduling algorithm with a time quantum q=3.

In the event that a process completes its time quantum at the same time that another process arrives, the process just completing its quantum is queued ahead of the arriving process.

II: Experimenting with a scheduling simulator (30 points)

In part II, you'll use an existing process scheduling simulator to help test and prove hypotheses about the behavior of various scheduling algorithms.

The simulator you will use can be obtained at http://vip.cs.utsa.edu/simulators/guides/ps/ps_doc.html (documentation for the simulator is also found there. Here's a direct link to the zip file download.

Depending on your platform, you'll either run the simulator by invoking the runps shell script from the command line (on Linux / OS X) or by running the runps.bat file (on Windows). Successfully starting the simulator will bring up the main interface:

Process simulator main interface

Each question in this part of the assignment will adhere to the following pattern:

  1. We'll ask you to consider a question related to CPU scheduling
  2. You'll make some predictions / hypotheses concerning this question
  3. You'll design an experiment meant to test and prove/disprove your hypotheses
  4. Based on your (simulated) experimental results, you'll either justify or revise your original hypotheses

It's the ol' scientific method at work! Please note that you won't be graded on the correctness of your initial hypotheses -- just be honest and thoughtful -- we're much more interested in your being able to design and interpret the output of your experiments.

For each question below, your answer will consist of all your experimental setup files (used as input to the simulator), and a writeup containing your hypotheses, analysis, and conclusion. You should aggregate all your simulator setup files into a single compressed archive (zip or tarball), segregated into directories (per question).

1. FCFS = best turnaround times?

One of the "handwavy" claims I made in class was that FCFS, while over-simplistic and non-ideal for most scheduling scenarios, leads to the best overall turnaround times. Is this really the case?

Design an experiment pitting FCFS against SJF (and others, if you wish) where you try to hit FCFS with "worst case scenarios" to reduce turnaround. Justify your experimental design. What is your conclusion?

2. SJFA: tuning alpha

One of the really cool things about the UTSA process simulator is that it allows you to specify different probability distributions for cpu/io burst durations, interarrival times, etc. Furthermore, by using the same random number seed you can simulate identical scheduling conditions over and again.

For this experiment, we ask you to come up with ideal values of alpha to be used in the SJFA algorithm for different CPU burst distributions. Recall that alpha is the parameter used to compute the exponential moving average. Using each of the probability distributions for CPU bursts:

What is (roughly) an ideal value for alpha in each case? Why? (If there isn't an ideal value, justify that, too).

Remember that "constant" indicates that CPU bursts will always be of the given length, "uniform" indicates CPU bursts that are uniformly/equally distributed over the given range, and "exponential" indicates a memoryless distribution with the specified mean.

Hint: you will probably want to run your simulations for an extended period of time to be able to draw some experimental conclusions. Setting the "duration" in your run file to something like "constant 1000" would be a good start.

3. Round Robin (RR): tuning q

In class we made some interesting (and handwavy) statements about the choice of time quantum for a round robin scheduler needed to maximize the "responsiveness" of a set of processes with certain run characteristics.

Using the same probability distributions in the previous scenario, what are ideal values for the round-robin time quantum q?