HW 2
HW 2
Theoretical Assignment # 2
Scheduling
1) Assume that the following processes are the only processes in a computer system and that
there are no input/output requests from all the given processes. Answer the following
questions for each process's following arrival time and CPU burst time (also called service
time).
P1 0 20
P2 3 7
P3 5 2
P4 7 3
a) Draw the Gantt chart and compute the throughput, average waiting time and average
turnaround time for the following CPU scheduling algorithms. Here the waiting time of a
process includes all the time it spends in the ready list.
i. (15pts) First Come First Service (FCFS).
ii. (15pts) Preemptive Shortest Job Next (Shortest Remaining Job Next).
iii. (20pts) Round-Robin with a time quantum of 4 (Assume that new processes will be
inserted at the end of the ready list).
a) (10pts) According to your results, which scheduling algorithm in (a) gives the shortest
average waiting time? Is that consistent with your theoretical prediction? Justify your
answer.
CPU utilization
[15 points] Suppose that the context switch takes 1 unit of time. What is the CPU utilization of
each algorithm in the above example?
Scheduler Implementation
[25 points] You are writing the code for the Round-Robin scheduler of an Operating System.
Complete the code as instructed. You can write pseudo-code. The focus is on the correctness of
the algorithm and chosen data structures rather than on the syntax of a specific language.