scheduling algorithms 2
scheduling algorithms 2
Algorithms
Chap#6
Priority Scheduling
A priority is associated with each process, and the CPU is allocated to the process with
the highest priority.
• The CPU is allocated to the process with the highest priority
(smallest integer = highest priority)
Equal-priority processes are scheduled in FCFS order.
Priority scheduling can be either preemptive or non-preemptive
• SJF is priority scheduling where priority is the inverse of predicted
next CPU burst time
• Problem = Starvation - low priority processes may never execute
• Solution = Aging - as time progresses increase the priority of the
process
Cont...
P1 P4 P2 P4 P1 P3 P5
0 2 5 33 40 49 51 67
Process Arrival Burst priority TAT WT
ID Time Time
P1 0 11 2 49- 49-
0=49 11=38
P2 5 28 0 33- 28-
5=28 28=0
P3 12 2 3 51- 39-
12=39 2=37
P4 2 10 1 40- 38-
2=38 10=28
P5 9 16 4 67- 58-
9=58 16=42
• Average waiting Time =(38+0+37+28+42)/5
• 145/5 ms
• 29 ms
Round-robin (RR)
• The round-robin (RR) scheduling algorithm is designed especially for
timesharing systems.
• It is similar to FCFS scheduling, but preemption is added to enable the
system to switch between processes.
• A small unit of time, called a time quantum or time slice, is defined.
• A time quantum is generally from 10 to 100 milliseconds in length.
Round Robin
If we use a time quantum of 4 milliseconds,
Advantage of Round-robin Scheduling
• It doesn’t face the issues of starvation or convoy effect.
• It deals with all process without any priority
• This scheduling method does not depend upon burst time. That’s why it is easily
implementable on the system.
• Once a process is executed for a specific set of the period, the process is preempted, and
another process executes for that given time period.
• Allows OS to use the Context switching method to save states of preempted processes.
• It gives the best performance in terms of average response time.
Disadvantages of Round-robin
Scheduling
• If slicing time of OS is low, the processor output will be reduced.
• This method spends more time on context switching
• Its performance heavily depends on time quantum.
• Priorities cannot be set for the processes.
• Lower time quantum results in higher the context switching overhead in the system.
• Finding a correct time quantum is a quite difficult task in this system.
Multilevel Queue Scheduling
Queue
3. Interactive editing processes
4. Batch processes
5. Student processes
Multilevel Feedback Queue
Scheduling
• The multilevel feedback queue scheduling algorithm allows a process to move between
queues.
• The idea is to separate processes according to the characteristics of their CPU bursts.
• If a process uses too much CPU time, it will be moved to a lower-priority queue.
• This scheme leaves I/O-bound and interactive processes in the higher-priority queues.
• In addition, a process that waits too long in a lower-priority queue may be moved to a
higher-priority queue. This form of aging prevents starvation.
In general, a
• The number of queues
multilevel
feedback queue • The scheduling algorithm for each queue
scheduler is • The method used to determine when to
defined by the upgrade a process to a higher-priority
following queue.
parameters: • The method used to determine when to
demote a process to a lower-priority
queue.
• The method used to determine which
queue a process will enter when that
process needs service.
Thank you