110 likes | 253 Views
Lab6. IT325. CPU Scheduling. F irst C ome F irst S erve (FCFS):. Jobs are scheduled in order of arrival Non-preemptive Problem: Average waiting time depends on arrival order Troublesome for time-sharing systems Convoy effect short process behind long process.
E N D
Lab6 IT325 CPU Scheduling
First Come First Serve (FCFS): • Jobs are scheduled in order of arrival • Non-preemptive • Problem: • Average waiting time depends on arrival order • Troublesome for time-sharing systems • Convoy effect short process behind long process
Shortest Job First (SJF) • Use next CPU burst lengths to schedule the process with the shortest time • If the next CPU bursts of two processes are the same, scheduling is used. • Two schemes: • nonpreemptive – once CPU given to the process it cannot be preempted until completes its CPU burst • preemptive – if a new process arrives with CPU burst length less than remaining time of current executing process, preempt. This scheme is known as the FCFS Shortest-Remaining-Time-First (SRTF)
Shortest Job First (SJF) • Optimal, gives minimum average waiting time for a given set of processes • There are no accurate estimations to know the length of the next CPU burst
Priority Scheduling • The CPU is allocated to the process with the highest priority (smallest integer highest priority in Unix but lowest in Java). • Equal-priority processes are scheduled in FCFS order. • Preemptive • Non-preemptive • SJF is a priority scheduling where priority is the predicted next CPU burst time. • Problem Starvation: low priority processes may never execute. • Solution Aging : as time progresses increase the priority of the process.
Round Robin (RR) • Similar to FCFS scheduling, but preemption is added to switch between processes • Preemptive FCFS = • Each process gets a small unit of CPU time (time quantum). After this time has elapsed, the process is preempted and added to the end of the ready queue. RR
Round Robin (RR) • Typically, higher average turnaround than SJF, but better response. • Performance • q large FCFS • q small q must be large with respect to context switch, otherwise overhead is too high. • If : • The process may have a CPU burst of < time quantum the process itself will release the CPU voluntarily. • The CPU burst of the currently running process > time quantum the timer will go off and will cause an interrupt to the OS. a context switch will be executed, and the process will be put at the tail of the ready queue.
Round Robin (RR) • Typically, higher average turnaround than SJF, but better response • Response: • amount of time it takes from when a request was submitted until the first response is produced (for time-sharing environment) • Turnaround: • amount of time to execute a particular process
“The perfect CPU scheduler” • Minimize latency: response or job completion time • Maximize throughput: Maximize jobs / time. • Maximize utilization: keep I/O devices busy. • Fairness: everyone makes progress, no one starves
Some Equations: • Turnaround Time (TAT)= End Time – Arrival Time. • End Time Knownas Termination Time. • Waiting Time = End Time – Arrival Time – CPU Burst Time Waiting Time = TAT – CPU Burst Time • CPU Burst Time Known as Service Time.
Some Equations Cont. : • In the non-preemptive algorithms: • Waiting Time = Start Time – Arrival Time. • End Time = Start Time + CPU Burst Time.