CPU Scheduling Algorithms: P.Naveen 10111D0030
CPU Scheduling Algorithms: P.Naveen 10111D0030
CPU Scheduling Algorithms: P.Naveen 10111D0030
P.Naveen 10111D0030
Agenda
Scheduling Types of Short Term Scheduling FCFS SJF Scheduling Disadvantages of SJF scheduling
Scheduling
In computer science, a scheduling is the method by which threads, processes or data flows are given access to system
The need for a scheduling algorithm arises from the requirement for
most modern systems to perform multitasking(execute more than one process at a time) and multiplexing (transmit multiple flows simultaneously).
FCFS
Non Preemptive Treats ready queue as FIFO Simple, but typically long waiting time. Other Names: First-in First-out(FIFO) Run to completion Run until done
SJF Scheduling
Give CPU to the process with the shortest next burst Schedule the process with the shortest CPU Burst time Two schemes:
Non preemptive once CPU given to the process it cannot be preempted (stopped) 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 know as the Shortest-Remaining-Time-First (SRTF)
SJF is optimal gives minimum average waiting time for a given set of processes
Disadvantages of SJF
Only optimal if all process are available simultaneously Usually run times are not known
P3 7 8
P2 12
P1
P1(7) 0 2 P1(5)
P2 P3
4 5
P2 7
P4
11
10
Optimal scheduling Preemptive SJF is superior to non preemptive SJF. However, there are no accurate estimations to know the length of the next CPU burst
11
Priority Scheduling
A priority number (integer) is associated with each process The CPU is allocated to the process with the highest priority (smallest integer highest priority in Unix but lowest in Java). Preemptive Non-preemptive
12
Each process is given CPU time in turn, (i.e. time quantum: usually 10-100 milliseconds), and thus waits no longer than ( n 1 ) * time quantum time quantum = 20 Process Burst Time Wait Time P1 53 57 +24 = 81 P2 17 20 P3 68 37 + 40 + 17= 94 P4 24 57 + 40 = 97
P1(33) P3(48)
40
P 24 1(13)
40
17
P3(28) P3(8)
P4(4)
Average wait time = (81+20+94+97)/4 = 73
13
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.
Thank You