0% found this document useful (0 votes)
38 views11 pages

7.OS Lecturer

Uploaded by

Ghaffar Buzdar
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)
38 views11 pages

7.OS Lecturer

Uploaded by

Ghaffar Buzdar
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/ 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)
• Preemptive
• Nonpreemptive
 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

Operating System Concepts – 10th Edition 5.1 Silberschatz, Galvin and Gagne ©2018
Example of Priority Scheduling

Process Burst Time Priority


P1 10 3
P2 1 1
P3 2 4
P4 1 5
P5 5 2

 Priority scheduling Gantt Chart

 Average waiting time = 8.2

Operating System Concepts – 10th Edition 5.2 Silberschatz, Galvin and Gagne ©2018
Priority Scheduling

In the Example, there are 7 processes P1, P2, P3, P4, P5, P6 and P7.
Their priorities, Arrival Time and burst time are given in the table..

Process ID Priority Arrival Time Burst Time

1 2 0 3
2 6 2 5
3 3 1 4
4 5 4 2
5 7 6 9
6 4 5 4
7 10 7 10

Operating System Concepts – 10th Edition 5.3 Silberschatz, Galvin and Gagne ©2018
Priority Scheduling…

Process Priority
Arrival Burst Complet Turnaro Waiting Respons
Id Time Time ion und Time e Time
Time TimeTime
1.Turn Around Time = Completion - Arrival Time
2.Waiting Time = Turn Around Time - Burst Time
1 2 0 3 3 3 0 0
2 6 2 5 18 16 11 13
3 3 1 4 7 6 2 3
4 5 4 2 13 9 7 11
5 7 6 9 27 21 12 18
6 4 5 4 11 6 2 7
7 10 7 10 37 30 18 27

Operating System Concepts – 10th Edition 5.4 Silberschatz, Galvin and Gagne ©2018
Priority Scheduling

In the Example, there are 7 processes P1, P2, P3, P4, P5, P6 and P7.
Their priorities, Arrival Time and burst time are given in the table..

Process Id Priority Arrival Time Burst Time

1 2(L) 0 1
2 6 1 7
3 3 2 3
4 5 3 6
5 4 4 5
6 10(H) 5 15
7 9 15 8

Operating System Concepts – 10th Edition 5.5 Silberschatz, Galvin and Gagne ©2018
Priority Scheduling

Process Priority Arrival Burst Comple Turn Waiting


Id Time Time tion around Time
Time Time

1 2 0 1 1 1 0
2 6 1 7 22 21 14
3 3 2 3 5 3 0
4 5 3 6 16 13 7
5 4 4 5 10 6 1
6 10 5 15 45 40 25
7 9 6 8 30 24 16

Operating System Concepts – 10th Edition 5.6 Silberschatz, Galvin and Gagne ©2018
Multilevel Queue
 The ready queue consists of multiple queues
 Multilevel queue scheduler defined by the following parameters:
• Number of queues
• Scheduling algorithms for each queue
• Method used to determine which queue a process will enter
when that process needs service
• Scheduling among the queues

Operating System Concepts – 10th Edition 5.7 Silberschatz, Galvin and Gagne ©2018
Multilevel Queue
 With priority scheduling, have separate queues for each priority.
 Schedule the process in the highest-priority queue!

Operating System Concepts – 10th Edition 5.8 Silberschatz, Galvin and Gagne ©2018
Multilevel Queue
 Prioritization based upon process type

Operating System Concepts – 10th Edition 5.9 Silberschatz, Galvin and Gagne ©2018
Multilevel Feedback Queue
 A process can move between the various queues.
 Multilevel-feedback-queue scheduler defined by the following
parameters:
• Number of queues
• Scheduling algorithms for each queue
• Method used to determine when to upgrade a process
• Method used to determine when to demote a process
• Method used to determine which queue a process will enter
when that process needs service
 Aging can be implemented using multilevel feedback queue

Operating System Concepts – 10th Edition 5.10 Silberschatz, Galvin and Gagne ©2018
Example of Multilevel Feedback Queue
 Three queues:
• Q0 – RR with time quantum 8 milliseconds
• Q1 – RR time quantum 16 milliseconds
• Q2 – FCFS
 Scheduling
• A new process enters queue Q0 which is
served in RR
 When it gains CPU, the process receives 8
milliseconds
 If it does not finish in 8 milliseconds, the
process is moved to queue Q1
• At Q1 job is again served in RR and
receives 16 additional milliseconds
 If it still does not complete, it is preempted
and moved to queue Q2

Operating System Concepts – 10th Edition 5.11 Silberschatz, Galvin and Gagne ©2018

You might also like