Presentation on theme: "1 First Come, First Served (FCFS) The simplest algorithm –When a process becomes ready, it enters the FIFO queue. –When the currently-running process ceases."— Presentation transcript:
1 First Come, First Served (FCFS) The simplest algorithm –When a process becomes ready, it enters the FIFO queue. –When the currently-running process ceases to execute, the oldest process in the queue is selected for running. Non-preemptive CPU FIFO Ready Queue dispatched
3 The average waiting time is not minimal and varies substantially if the process execution times vary. ex 1 ProcessArrival TimeProcess Exec Time P1024 msec P213 msec P323 msec –Calculate the average waiting time, turnaround time and throughput. ex 2 ProcessArrival TimeProcess Exec Time P203 msec P313 msec P1224 msec –Calculate the average waiting time, turnaround time and throughput.
5 Normalized turnaround time –The ratio of turnaround time to process exec time. –A relative delay experienced by a process The longer process exec time, the greater absolute amount of tolerable delay. ex 1 ProcessArrival TimeProcess Exec Time P1024 msec P213 msec P323 msec ex 2 ProcessArrival TimeProcess Exec Time P203 msec P313 msec P1224 msec –Calculate the turnaround time and the normalized turnaround time for each process.
7 The normalized turnaround times for P2 and P3 are intolerable. –This problem occurs whenever a short-lived process arrives right after a long-lived process. When the variance of process exec time is high, FCFS penalizes short processes. –FCFS is not a fair scheduling algorithm; it does not treat long-lived and short-lived processes equally.
9 Round Robin Clock-based preemption of process (time slicing) –When a clock interrupt occurs, the currently-running process is placed in the end of the Ready queue, and the next ready process is executed. –A straightforward way to reduce the penalty that short-lived processes suffer with FCFS. A fairer algorithm than FCFS CPU Ready Queue FIFO and Circular Queue dispatched timeout
10 A Key Design Issue in RR How to determine the length of time quantum (time slice)? –If it’s too short, Processing overhead becomes high to handle clock interrupts and perform context switches. –(the time to handle a clock interrupt and perform a context switch) / (time quantum) should be small enough. –If it’s too long, RR degenerates to FCFS.
21 Time Quantum Should be slightly longer than typical process execution time Should be shorter than the longest process exec time. Generally 10 to 100 msec
22 Another Fairness Issue RR treats long-lived and short-lived processes equally. However, it does not treat CPU-bound and I/O- bound processes equally. –CPU-bound process Mainly performs computational work and occasionally uses I/O devises –I/O-bound process spends more time using I/O devises than using the CPU.
23 I/O-bound processes use less CPU time than CPU-bound processes. –An I/O-bound process uses for a short period and then is blocked for an I/O operation. It returns to the Ready queue when the I/O operation is completed. –A CPU-bound process uses a complete time quantum and returns to the Ready queue. CPU Ready Queue admitted dispatched exit interrupted I/O type 1 wait I/O 1 completed I/O 1 Blocked Queue I/O N Blocked Queue I/O type N wait I/O N completed CPU-bound processes tend to use more CPU time, which leads to poor performance in I/O-bound processes.
24HW Read Paper #1 (see the course web site), and summarize how the proposed scheduling algorithm addresses this fairness issue. –Use a queuing diagram in your explanation.