COP4610 CGS5765 Recitation Section: _____ Last 4 SSN: ______
Points: 100 points (Maximum 110 points)
1. (30 points, 10 points each) True/false. For each statement, write ‘T’ at the end if it is true and write ‘F’ if it is false. If you think the question is ambiguous, state your additional assumptions clearly.
a. In a time sharing system, the most suitable criterion for CPU scheduling is to maximize the CPU utilization ……………………………………………[ F ]
b. A round robin scheduling algorithm can be nonpreemptive …………….[ F ]
c. In a preemptive priority scheduling algorithm, the running process/thread always has the highest priority among all ready processes/threads …… . [ T ]
2. (20 points) Suppose that a process is executing ``counter=counter+1'' while another process is executing concurrently (without any synchronization) ``counter=counter2'', where the counter is a variable shared between the two processes and is only changed in those statements. Given that the value of counter is five before execution, give all the possible value(s) after both processes finish their statement.
As in the example we went through during class, each statement can be implemented through three instructions. Thus, the possible values are 5 + 1 = 6 (where the counter = counter –2 is overwritten), 5 – 2 = 3 (where the counter = counter + 1 is overwritten), or 5 + 1 – 2 = 4 (which is correct).
3. (60 points, 20 points each) 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. Given the following arrival time and CPU burst time for each process, draw the Gantt chart and compute the average turnaround time and the average wait time as defined in the textbook for the following CPU scheduling algorithms:
a. First Come First Service (FCFS).




P_{1} 








P_{2} 


P_{3} 

P_{4} 

0 
1 
2 
3 
4 
5 
6 
7 
8 
9 
10 
11 
12 
13 
14 
15 
16 
17 
18 
19 
20 
The turnaround time for P1 is 100=10, for P2 is 162=14 for P3 is 173=14 and for P4 is 205=15. So the average turnaround time is (10+14+14+15)/4=13.25
The wait time for P1 is 00=0, for P2 is 102 = 8, for P3 is 163=13 and for P4 is 175=12. So the average wait time is (0+8+13+12)/4 = 8.25
b. Preemptive Shortest Job Next.
P_{1} 

P_{2} 
P_{3} 
P_{2} 

P_{4} 



P_{2} 




P_{1} 




0 
1 
2 
3 
4 
5 
6 
7 
8 
9 
10 
11 
12 
13 
14 
15 
16 
17 
18 
19 
20 
The turnaround time for P1 is 200=20, for P2 is 122=10 for P3 is 43=1 and for P4 is 85=3. So the average turnaround time is (20+10+1+3)/4=8.5
The wait time for P1 is 00=0, for P2 is 22 = 8, for P3 is 33=0 and for P4 is 55=0. So the average wait time is (0+0+0+0)/4 = 0.
c. RoundRobin with time quantum of 4, ignoring the context switch cost. We assume that the newly arrived processes will be inserted at the end of the ready queue.

P_{1} 



P_{2} 


P_{3} 

P_{1} 



P_{4} 

P_{2} 

P_{1} 

0 
1 
2 
3 
4 
5 
6 
7 
8 
9 
10 
11 
12 
13 
14 
15 
16 
17 
18 
19 
20 
The turnaround time for P1 is 200=20, for P2 is 182=16 for P3 is 93=6 and for P4 is 165=11. So the average turnaround time is (20+16+6+11)/4=13.25
The wait time for P1 is 00=0, for P2 is 42 = 2, for P3 is 83=5 and for P4 is 135=8. So the average wait time is (0+2+5+8)/4 = 3.75