0% found this document useful (0 votes)
12 views16 pages

OS_09

The document discusses priority scheduling in operating systems, explaining how processes are executed based on their assigned priorities, and the concepts of preemptive and non-preemptive scheduling. It also addresses the starvation problem and introduces aging as a solution to prevent low-priority processes from being indefinitely blocked. Additionally, the document covers Round Robin scheduling, its mechanics, and provides examples to illustrate the average waiting times for various scheduling scenarios.

Uploaded by

longplaceman
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
12 views16 pages

OS_09

The document discusses priority scheduling in operating systems, explaining how processes are executed based on their assigned priorities, and the concepts of preemptive and non-preemptive scheduling. It also addresses the starvation problem and introduces aging as a solution to prevent low-priority processes from being indefinitely blocked. Additionally, the document covers Round Robin scheduling, its mechanics, and provides examples to illustrate the average waiting times for various scheduling scenarios.

Uploaded by

longplaceman
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 16

Operating Systems

CS-315
BS(CS/IT) 5th Semester
Lecture No: 09
CS&IT Department
BUET Turbat
Priority Scheduling

• In priority scheduling, a priority is associated with all processes.


• Processes are executed in sequence according to their priority.
• CPU is allocated to the process with highest priority.
• If priority of two or more processes are equal than FCFS is used
to break the tie.
• Priority scheduling can be preemptive or non-preemptive.
Preemptive Priority Scheduling:
In this, scheduler allocates the CPU to the new process if the
priority of new process is higher than the priority of the running
process.
Non-Preemptive Priority Scheduling:
The running process is not interrupted even if the new process
has a higher priority.
In this case, the new process will be placed at the head of the
ready queue.
Starvation Problem:

• Incertain situations, a low priority process can be


blocked infinitely if high priority processes arrive in
the ready queue frequently.
• This situation is known as Starvation.
Aging is a techniqueSolution:
which gradually increases the priority of
processes that are victims of starvation.
For e.g.: Priority of process X is 10.
There are several processes with higher priority in the ready
queue.
Processes with higher priority are inserted into ready queue
frequently.
In this situation, process X will face starvation.
The operating system increases priority of a process by 1 in
every 5 minutes.
Thus, the process X becomes a high priority process after
some time.
Example of Priority Scheduling Algorithm

• Consider the following set of processes that arrive at time 0


with the length of the CPU burst time in milliseconds. The
priority of these processes is also given:
• The Gantt Chart for the schedule is:
Waiting Time for P2 = 0
Waiting Time for P5 = 1
Waiting Time for P1 = 6
Waiting Time for P3 = 16
Waiting Time for P4 = 18
Average Waiting Time = (Total Waiting Time) / No. of
Processes
= (0 + 1 + 6 + 16 + 18) / 5
= 41 / 5
= 8.2 milliseconds
Example 2

• Processes P1, P2, P3 are the processes with their arrival time,
burst time and priorities listed in table below:
• The Gantt Chart for the schedule is:
Waiting Time for P1 = (8 – 1) - 0 = 7
Waiting Time for P2 = (4 – 1-1) = 2
Waiting Time for P3 = (2 – 2) = 0
Average Waiting Time = (Total Waiting Time) / No. of Processes
= (7 + 2 + 0) / 3
=9/3
= 3 milliseconds
Round Robin Scheduling (RR)

• In Round Robin scheduling, processes are dispatched in FIFO but


are given a small amount of CPU time.
• This small amount of time is known as Time Quantum or Time
Slice.
• A time quantum is generally from 10 to 100 milliseconds.
• If a process does not complete before its time slice expires, the
CPU is preempted and is given to the next process in the ready
queue.
• The preempted process is then placed at the tail of the ready
queue.
• Ifa process is completed before its time slice expires, the
process itself releases the CPU.
• The scheduler then proceeds to the next process in the ready
queue.
• Round Robin scheduling is always preemptive as no process is
allocated the CPU for more than one time quantum.
• If a process’s CPU burst time exceeds one time quantum then that
process is preempted and is put back at the tail of ready queue.
• The performance of Round Robin scheduling depends on several
factors:
 Size of Time Quantum
 Context Switching Overhead
Example of Round Robin Scheduling

• Consider the following set of processes that arrive


at time 0 with the length of the CPU burst time in
milliseconds:
• Time quantum is of 2 milliseconds.
The Gantt Chart for the schedule is:

Waiting Time for P1 = 0 + (6 – 2) + (10 – 8) + (13 – 12)


=4+2+1=7
Waiting Time for P2 = 2 + (8 – 4) + (12 – 10)
=2+4+2=8
Waiting Time for P3 = 4
Average Waiting Time = (Total Waiting Time) / No. of Processes
= (7 + 8 + 4) / 3
= 19 / 3
= 6.33 milliseconds

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy