0% found this document useful (0 votes)
2 views

scheduling algorithms 2

The document discusses various scheduling algorithms, focusing on priority scheduling, round-robin scheduling, multilevel queue scheduling, and multilevel feedback queue scheduling. It highlights the advantages and disadvantages of each method, including issues like starvation in priority scheduling and context switching overhead in round-robin scheduling. Additionally, it explains the concept of aging to mitigate starvation and the classification of processes in multilevel queue systems.

Uploaded by

Marium naeem
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

scheduling algorithms 2

The document discusses various scheduling algorithms, focusing on priority scheduling, round-robin scheduling, multilevel queue scheduling, and multilevel feedback queue scheduling. It highlights the advantages and disadvantages of each method, including issues like starvation in priority scheduling and context switching overhead in round-robin scheduling. Additionally, it explains the concept of aging to mitigate starvation and the classification of processes in multilevel queue systems.

Uploaded by

Marium naeem
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 24

Scheduling

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...

• As an example, consider the


following set of processes,
assumed to have arrived at
time 0 in the order P1, P2, ···,
P5, with the length of the CPU
burst given in milliseconds:
Problem with Priority Scheduling
• A major problem with priority scheduling algorithms is
indefinite blocking, or starvation.
• A process that is ready to run but waiting for the CPU can be
considered blocked.
• A priority scheduling algorithm can leave some low priority
processes waiting indefinitely.
• In a heavily loaded computer system, a steady stream of
higher-priority processes can prevent a low-priority process
from ever getting the CPU.
solution to the problem
• A solution to the problem of indefinite blockage of low-priority
processes is aging.
• Aging involves gradually increasing the priority of processes that wait
in the system for a long time.
• For example, if priorities range from 127 (low) to 0 (high), we could
increase the priority of a waiting process by 1 every 15 minutes.
Eventually, even a process with an initial priority of 127 would have
the highest priority in the system and would be executed.
Example: priority
using(preemptive algorithm)
Process ID Arrival Time Burst Time priority
P1 0 11 2
P2 5 28 0
P3 12 2 3
P4 2 10 1
P5 9 16 4
• Gantt Chart

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

• A class of scheduling algorithms has been created for situations in which


processes are easily classified into different groups.
• A common division is made between:
• foreground (interactive) processes and background (batch) processes.
• These two types of processes have different response-time requirements
• and so may have different scheduling needs.
• In addition, foreground processes may have priority (externally defined)
over background processes.
Cont..

• A multilevel queue scheduling algorithm partitions the ready queue into


several separate queues.
• The processes are permanently assigned to one queue, generally based on
some property of the process, such as memory size, process priority, or
process type.
• Each queue has its own scheduling algorithm.
• For example, separate queues might be used for foreground and
background processes.
• The foreground queue might be scheduled by an RR algorithm, while the
background queue is scheduled by an FCFS algorithm.
Let’s look at an example of a multilevel queue
scheduling algorithm with five queues, listed below
Multilev in order of priority:
1. System processes
el 2. Interactive processes

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

You might also like