1. A CPU-scheduling algorithm determines the order in which processes execute. Assuming there are n processes and one processor, how many schedules are there? (6 points)
2. Consider the following set of processes, with the length of the CPU-burst time given in milliseconds
Process Burst-time Priority ----------------------------- P1 9 3 P2 1 1 P3 2 3 P4 1 4 P5 6 2 -----------------------------
Processes are assumed to have arrived in the order P1, P2, P3, P4, P5, all at time 0.
a) Draw Gantt charts illustrating the execution of these processes using FCFS, SJF, a non-preemptive priority (smaller priority number means higher priority), and RR (with a time slice of one millisecond) scheduling. (4*5 = 20 points)
b) What is the turnaround time of each process for each of the scheduling algorithms in part a? (5*2 = 10 points)
c. What is the waiting time of each process for each of the scheduling algorithms in part a? (5*2 = 10 points)
d) What is the average waiting time (over all processes) for each of the scheduling algorithms in part a? (5*2 = 10 points)
e) What is the throughput in each case (assume that the observation time is from time zero until all jobs complete)? (5*2 = 10 points)
3. Consider the following set of processes, with the length of the CPU-burst time given in milliseconds. The arrival time is also given in milliseconds.
Process Burst-time Arrival-time --------------------------------- P1 9 0.0 P2 7 0.4 P3 2 1.0 P4 1 1.5 ---------------------------------
a. Draw a Gantt chart illustrating the execution of these processes using FCFS. (5 points)
b. What is the CPU utilization if these processes are scheduled using FCFS? (3 points)
c. What is the turnaround time for each process if FCFS is used? (3 points)
d. What is the average turnaround time for these processes if FCFS is used? (3 points)
e. What is the throughput if FCFS is used? (3 points)
f. Draw a Gantt chart illustrating the execution of these processes using SJF. (5 points)
g. h. i. j. Answer the same questions (b, c, d, e) assuming that the scheduling algorithm is SJF. (4*3 = 12 points)
4. Five jobs are waiting to be run. Their expected run times are 10, 6, 3, 5, and X. In what order should they be run to minimize the average waiting time? (the answer, of course, depends on X). (10 points).
5. Assume two processes P1 and P2 that share an integer variable x in memory. The initial value of x is 0. The two processes may execute in any order. What are the possible values of x after the two processes terminate? (10 points)
P1: P2: ....... ....... if (x > 0) x=x+6; x=x+1; else x=x+4; ....... .......
Maximum mark: 120 points (100%)