CS 3733 Operating Systems: Assignment 2 (60 points)

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. You must print out this assignment using a monospaced font. If you do not know what this means, look it up.

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 an algorithm that is similar, but possibly not identical to 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 write 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 usually 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.

Run your program on the two examples given in Assignment 1 and the 6 tests. Your results for all of these tests should be the same as for Assignment 1.

Bonus Points: if you can change the proto.c and make it to support multiple processes, not just two processes, you will get 10 points bonus.

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. Convince yourself that the program is running correctly. You can use the applet discussed in class to test your results.

Now run your program on the inputs of assignment1.
Example1: 3 4 2 7 3 6 5
Example2: 3 4 9 5 6 3 7
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.
Test 4: 3 3 3 4 2 1 2.
Test 5: 3 3 2 3 2 1 2.
Test 6: 3 5 2 5 4 1 1
Print the results into a file (called as result.txt) and include it with your assignment.

Note on breaking ties:
Processes can enter the ready queue when they first arrive, when their quantum expires, or when their I/O completes. When the RR algorithm must choose the oldest process from the ready queue it needs a way to break ties. For our algorithms, we break a tie by having process 1 run before process 2. Make sure you understand this and make sure your solution works with the following input: 3 1 1 4 1 3 1

Part 5
As a final test, get a copy of runall.c here.
Look at the source code and understand it.
Compile it with your pslibrary and run the program.
It should take less than a minute to complete and generate 4 files, each of about 40 megabytes and having the extension .all.
Make sure you have no other files with this extension in your directory and execute:
ls -l *.all
wc *.all
md5sum *.all
Include the output ("checksum.txt") generated with your assignment.
Each of the files should have 2,000,001 lines and 2,000,003 words.
You should delete these large files after you have saved the output of md5sum.

Submission Guideline: You will submit through the blackboard. Please including the "result.txt", "checksum.txt", "status.txt" and a "source" directory that includes all source code and Makefile. Please compress all of these files into a package "abc123.zip". abc123 should be replaced with your abcid. The "source" directory should include the source code that is compilable and runnable. "status.txt" will include a brief description of what is working and what progress was made on the part that is not working. There will be a severe penalty if you don't include this "status.txt" or the "status.txt" is not aligned with your code. There will be a severe penalty if you don't include this "status.txt" or the "status.txt" is not aligned with your code. If you have others, but no source code, you can not get the points more than 50%. Future assignments will use the same use and there is NO REMINDING any more.