In preemptive scheduling, a timer goes off every so often, and the scheduler runs. The scheduler decides whether the currently running process gets to retain control of the CPU or not.
Strict nonpreemptive scheduling is not good for use in a computer center because there is no incentive to give up the CPU other than altruism, so once a user gets onto the CPU no one else gets a turn until that user deigns to give up the CPU.
Process Burst Time Priority ------------------------------- 1 10 3 2 1 1 3 2 3 4 1 4 5 5 2
FCFS: 1111111111233455555 SJF: 2433555551111111111 NPP: 2555551111111111334 RR: 1234513515151511111
b. The turnaround times for each process by scheduling algorithm are:
Process: 1 2 3 4 5 Scheme: +------------------- FCFS |10 11 13 14 19 SJF |19 1 4 2 9 NPP |16 1 18 19 6 RR |19 2 7 4 14
c. The waiting times for each process by scheduling algorithm are:
Process: 1 2 3 4 5 Time: +------------------- FCFS | 0 10 11 13 14 SJF | 9 0 2 1 4 NPP | 6 0 16 18 1 RR | 9 1 5 3 9
d. The average waiting times by schedule are:
Schedule | Time ---------+----------------------- FCFS | (0+10+11+13+14)/5 = 9.6 SJF | (9+0+2+1+4)/5 = 3.2 NPP | (6+0+16+18+1)/5 = 8.2 RR | (9+1+5+3+9)/5 = 5.4Shortest job first yields the minimal average waiting time.
Process Arrival Time Burst Time ----------------------------------- 1 0.0 8 2 0.4 4 3 1.0 1
b. The average turnaround time with SJF is: ((8 - 0.0) + (9 - 1.0) + (13 - 0.4))/3 = 9.533
c. The average turnaround time with one idle unit and then SJF is: ((2 - 1.0) + (6 - 0.4) + (14 - 0.0))/3 = 6.867
b. Advantages: Hey, we've just created no-brainer prioritization! Disadvantages: There's still a context switch every time slice, even if the same process runs twice in a row. Data structure management may be a pain if a process dies (or is moved to the waiting queue).
c. The basic RR could just read a new entry in the PCB indicating how many quanta it should run for.
b. If alpha < beta < 0, then the running process keeps the processor until either it finishes or a new process comes along. So the first priority goes to new processes. Among processes of the same age, the process which has run the most gets priority. This does not conform to any of the algorithms outlined in the book and frankly, it's pretty wacky. I think they're just trying to show that this alpha-beta business, though deceptively simple looking, can actually describe a wide variety of behavior.
b. Multilevel feedback queues and FCFS. The whole idea behind the multilevel feedback queue is that you can do anything with it. It is very flexible and adaptible. One thing you can do with it is throw away most of its usefulness by only using one queue and defining that queue's behavior to be FCFS.
c. Priority and FCFS. FCFS is just priority where the priority is assigned by order of arrival, with low priorities being higher.
d. Round Robin and SJF. It doesn't seem very easy to implement either of these in terms of the other, but they do share the characteristic that in each, the smallest job finishes first.