CS 3733 Operating Systems, Spring 2009 Assignment 2


Due Friday, February 13, 2009


Overview
This assignment is a continuation of Assignment 1. Make an assign2 directory and copy all of your files from assignment 1 into this directory. Make sure you program runs correctly from this directory. We will be modifying these files.

Problem description in terms of process scheduling
Consider two processes, each with two CPU bursts with one I/O burst in between. Process 1 has a CPU burst of x1 units followed by an I/O burst of y1 units followed by a second CPU burst of z1 units. Process 2 has a CPU burst of x2 units followed by an I/O burst of y2 units followed by a second CPU burst of z2 units. Suppose that Process 1 arrives in the ready queue just before Process 2 and just after Process 2 arrives the process that was in the CPU terminates. No other processes are in the system. For each of the scheduling algorithms draw a Gantt charts showing the state of each of the two processes. Use the letter R to represent the running state, the letter w for the waiting state and the letter r for the ready state. Calculate the two waiting times, the average waiting time and the CPU utilization. (Break any ties by having process 1 run first.)

Part 1 of assignment 1 describes the FCFS algorithm, where the last 6 input parameters are x1, y1, z1, x2, y2, and z2. The numbers displayed are the waiting times for process 1 and process 2, the average waiting time, and the cpu utilization. This version of the algorithm always chooses process 1 if both processes become ready at the same time.

Part 1
In this part of the assignment you will rewrite your fcfs program using a state machine design. A state machine has a state (the values of the variables) which changes over time. At each time step the state changes to a new state. The new state depends only on the old one and the input values.

In this case, the state of the system is the state of the two processes, including information about all of their remaining CPU and I/O bursts. Use this code as a prototype for your fcfs function. Insert the appropriate code so that it behaves like the fcfs algorithm. It should produce the same strings as your Assignment 0. The protoype may handle some cases that are not related to fcfs, such as a quantum. You may delete the unncessary code.

Part 2
Implement the SJF algorithm (non-preemptive). Again, ignore the first input parameter. Do this by putting the function:
sjf(char *s1, char *s2, int x1, int y1, int z1, int x2, int y2, int z2);
in pslibrary.c. Add two lines to assign1.c to call this and display. Use the heading: "SJF\n". Implement this by modifying your fcfs code or the prototype.

Part 3
Implement the PSJF algorithm. That is, write the function:
psjf(char *s1, char *s2, int x1, int y1, int z1, int x2, int y2, int z2);
and add two additional lines to assign1.c.

Part 4
Implement the Round Robin algorithm.
That is, write the function:
rr(char *s1, char *s2, int q, int x1, int y1, int z1, int x2, int y2, int z2);
In this case the first input parameter is the quantum and the others will be as before.

Test your program with inputs you have developed. Collect the tests and print them out. Make sure they are labeled so that it is easy to tell what tests were performed and whether or not they worked. Include these with your assignment. Put the starting page number on the cover sheet under Your test output pages.

Then run the program with each of the following three tests. For each, save the output in a file and print the output, each on a single page. Label each one as Test 1, Test 2, or Test 3.

Test 1: 3 8 7 3 6 3 2.
Test 2: 3 8 7 3 6 7 2.
Test 3: 4 8 7 3 6 1 2.
This will be turned in with your assignment. Put the page number of each of these on the cover sheet under Final test output 1, etc.

Use this cover sheet for handing in your assignment.

Assignments are due at the start of class on the due date.