RR Scheduling Algorithm Advantages: -- More interactive for users (quicker user response time?) -- No starvation -- Less overhead (less complex) -- Easy to implement Disadvantages: -- Longer overall wait time -- Longer overall turnaround time -- Does not handle priorities Impact of selecting the time slice? -- Too big: FCFS -- Too small: Way too many context switches (too much overhead) Preemptive Priority Scheduling Given: two processes P1 is CPU-bound P2 is I/O-bound Which of these processes should be assigned the higher priority? Goal: Minimize turnaround time P1 should have higher priority? Why? -- Faster turnaround time, because it doesn't have to wait for I/O? P2 should have higher priority? Why? -- Get CPU first, quickly get out of CPU to doing I/O, allowing other processes (P1) to do their work Example: P1 (CPU-bound) requires 300ms of CPU P2 (I/O-bound) requires 80ms of CPU and three 60ms I/O operations that fire at 20ms intervals RR with time slice of 100ms What are the turnaround times? If P1 has higher priority, P1 takes 340ms and P2 takes 440ms (average is 390ms) If P2 has higher priority, P1 takes 380ms, but P2 takes only 260ms. (average is 320ms) =============================================== Exponential averaging (see lecture notes): What if alpha = 0? Prediction is constant; actual history has no effect What if alpha = 1? Prediction is purely based on actual history (i.e. last measured CPU burst time) Tau0 = 10 alpha = 0.5 t0 = 6ms Recalculate using alpha = 0.25 and 0.75