SlideShare a Scribd company logo
1 of 33
UNIPROCESS SCHEDULING
Chapter 6 2
CPU Scheduling
Chapter 6
3
Classification of Scheduling Activity
• Long-term: which process to admit
• Medium-term: which process to swap in or out
• Short-term: which ready process to execute next
4
Long-Term Scheduling
• Determines which programs are
admitted to the system for processing
• Controls the degree of
multiprogramming
• If more processes are admitted
– less likely that all processes will be blocked
– better CPU usage
– each process has smaller fraction of the
CPU
• The long term scheduler may attempt to
5
Medium-Term Scheduling
• Swapping decisions based on the need to manage
multiprogramming
– Allows the long-term scheduler to admit more processes than
actually fit in memory
– but too many processes can increase disk activity (paging), so
there is some “optimum” level of multiprogramming.
• Done by memory management software (chapter 8)
6
Short-Term Scheduling
• Determines which process is going to execute
next (also called CPU scheduling)
• the focus of this chapter..
• invoked on a event that may lead to choosing
another process for execution:
– clock interrupts
– I/O interrupts
– operating system calls and traps, including
I/O
– signals
7
The CPU-I/O Cycle
Silberschatz, Galvin, and Gagne 1999
“CPU-bound”
processes require
more CPU time
than I/O time
“I/O-bound”
processes spend
most of their time
waiting for I/O.
8
Histogram of CPU-burst Times
Silberschatz, Galvin, and Gagne 1999
9
Our focus
• Uniprocessor Scheduling: scheduling a
single CPU among all the processes in
the system
• Key Criteria:
– Maximize CPU utilization
– Maximize throughput
– Minimize waiting times
– Minimize response time
– Minimize turnaround time
10
Criteria
• Maximize CPU utilization
– Efficiency
– Need to keep the CPU busy
• Minimize waiting times
– Time spent waiting in READY queue
– Each process should get a fair share of the
CPU
11
Criteria
• Maximize throughput
– Process completions per time unit
• Minimize response time
– From a user request to the first response
– I/O bound processes
• Minimize turnaround time
– CPU-bound process equivalent of response
time
– Elapsed time to complete a process
12
User vs. System Scheduling Criteria
User-oriented
• Turnaround Time (batch systems): Elapsed time from
the submission of a process to its completion
• Response Time (interactive systems): Elapsed time
from the submission of a request to the first response
System-oriented
• CPU utilization
• fairness
• throughput: processes completed per unit time
13
Two Components of Scheduling Policies
Selection function
• which process in the ready queue is selected next for
execution?
Decision mode
• at what times is the selection function exercised?
– Nonpreemptive
• A process in the running state runs until it blocks or
ends
– Preemptive
• Currently running process may be interrupted and
moved to the Ready state by the OS
• Prevents any one process from monopolizing the
CPU
14
Policy vs. Mechanism
• Important in scheduling and resource
allocation algorithms
• Policy
– What is to be done
• Mechanism
– How to do it
• Policy: All users equal access
• Mechanism: round robin scheduling
• Policy: Paid jobs get higher priority
• Mechanism: Preemptive scheduling
15
A running example to discuss various scheduling policies
Process
Arrival
Time
Burst
Time
1
2
3
4
5
0
2
4
6
8
3
6
4
5
2
16
First Come First Served (FCFS)
• Selection function: the process that has
been waiting the longest in the ready
queue (hence, FCFS, FIFO queue)
• Decision mode: nonpreemptive
– a process runs until it blocks itself (I/O or
other)
17
FCFS Drawbacks
• Favors CPU-bound processes
– A process that does not perform any I/O will
monopolize the processor!
– I/O-bound processes have to wait until
CPU-bound process completes
– They may have to wait even when their I/Os
have completed
• poor device utilization
– We could reduce the average wait time by
giving more priority to I/O bound processes
18
Shortest Job First (SJF)
• Selection function: the process with the shortest
expected CPU burst time
• Decision mode: non-preemptive
• I/O bound processes will be picked first
• We need to estimate the expected CPU burst time for
each process: on the basis of past behavior.
Shortest job
First (SJF)
19
Estimating the Required CPU Burst
• Can average all past history equally
• But recent history of a process is more likely to
reflect future behavior
• A common technique for that is to use exponential
averaging
– S[n+1] = a T[n] + (1-a) S[n] ; 0 < a < 1
– Puts more weight on recent instances
whenever a > 1/n
20
Exponentially Decreasing Coefficients
21
Exponential Averaging
• Set S[1] = 0 to give new processes high priority.
• Exponential averaging tracks changes in process
behavior much faster than simple averaging.
22
Shortest Job First: Critique
• SJF implicitly incorporates priorities: shortest jobs
are given preference.
– Typically these are I/O bound jobs
• Longer processes can starve if there is a steady
supply of shorter processes
• Lack of preemption not suitable in a time sharing
environment
– CPU bound process gets lower priority
– But a process doing no I/O at all could
monopolize the CPU if it is the first one in the
system
23
Shortest Remaining Time (SRT) =
Preemptive SJF
• If a process arrives in the Ready
queue with estimated CPU burst less
than remaining time of the currently
running process, preempt.
• Prevents long jobs from dominating.
– But must keep track of remaining burst
times
• Better turnaround time than SJF
– Short jobs get immediate preference
24
• Selection function: same as FCFS
• Decision mode: Preemptive
– Maximum time slice (typically 10 - 100 ms)
enforced by timer interrupt
– running process is put at the tail of the
ready queue
Round-Robin
25
Time Quantum for Round Robin
• must be substantially larger than process switch time
• should be larger than the typical CPU burst
• If too large, degenerates to FCFS
• Too small, excessive context switches (overhead)
26
Fairness vs. Efficiency
• Each context switch has the OS using the
CPU instead of the user process
– give up CPU, save all info, reload w/ status of
incoming process
– Say 20 ms quantum length, 5 ms context
switch
– Waste of resources
• 20% of CPU time (5/20) for context switch
– If 500 ms quantum, better use of resources
• 1% of CPU time (5/500) for context switch
• Bad if lots of users in system – interactive users
waiting for CPU
27
Round Robin: Critique
• Still favors CPU-bound processes
– An I/O bound process uses the CPU for a time less than
the time quantum and then is blocked waiting for I/O
– A CPU-bound process runs for its whole time slice and
goes back into the ready queue (in front of the blocked
processes)
• One solution: virtual round robin (VRR, not in book…)
– When a I/O has completed, the blocked process is
moved to an auxiliary queue which gets preference over
the main ready queue
– A process dispatched from the auxiliary queue gets a
shorter time quantum (what is “left over” from its
quantum when it was last selected from the ready
queue)
FIRST COME FIRST SERVE (FCFS)
• Characteristics of FCFS CPU Process Scheduling
1. Implementation is simple.
2. Does not cause any causalities while using
3. It adopts a non pre emptive and pre emptive strategy.
4. It runs each procedure in the order that they are received.
5. Arrival time is used as a selection criterion for procedures.
• Advantages of FCFS CPU Process Scheduling
• The advantages of FCFS CPU Process Scheduling are:
• In order to allocate processes, it uses the First In First Out queue.
• The FCFS CPU Scheduling Process is straight forward and easy to
implement.
• In the FCFS situation pre emptive scheduling, there is no chance of
process starving.
The disadvantages of FCFS CPU Process Scheduling are:
1. FCFS CPU Scheduling Algorithm has Long Waiting Time
2. FCFS CPU Scheduling favors CPU over Input or Output operations
3. In FCFS there is a chance of occurrence of Convoy Effect
4. Because FCFS is so straight forward, it often isn't very effective.
Extended waiting periods go hand in hand with this. All other orders
are left idle if the CPU is busy processing one time-consuming order.
EXAMPLE :
• S. No Process ID Process Name Arrival Time Burst Time
• _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
• 1 P 1 A 0 9
• 2 P 2 B 1 3
• 3 P 3 C 1 2
• 4 P 4 D 1 4
• 5 P 5 E 2 3
• 6 P 6 F 3 2
FCFS Scheduling Algorithms in OS (Operating
System)
• Gantt chart for the above Example 1 is:
• Turn Around Time = Completion Time - Arrival Time
• Waiting Time = Turn Around Time - Burst Time
• Solution”:
• S. No P ID Arrival Time Burst Time Completion Time Turn Around Time Waiting Time
• 1 P 1 0 9 9 9 0
• 2 P 2 1 3 12 11 8
• 3 P 3 1 2 14 13 11
• 4 P 4 1 4 18 17 13
• 5 P 5 2 3 21 19 16
• 6 P 6 3 2 23 20 18
Turn Around Time = Completion Time - Arrival Time
Waiting Time = Turn Around Time - Burst Time ( TAT= WT + BT )

More Related Content

Similar to UNIPROCESS SCHEDULING.pptx

Ch05 cpu-scheduling
Ch05 cpu-schedulingCh05 cpu-scheduling
Ch05 cpu-schedulingNazir Ahmed
 
Operating system 28 fundamental of scheduling
Operating system 28 fundamental of schedulingOperating system 28 fundamental of scheduling
Operating system 28 fundamental of schedulingVaibhav Khanna
 
Scheduling algorithms
Scheduling algorithmsScheduling algorithms
Scheduling algorithmsPaurav Shah
 
CPU Scheduling.pptx
CPU Scheduling.pptxCPU Scheduling.pptx
CPU Scheduling.pptxyashu23
 
Scheduling algo(by HJ)
Scheduling algo(by HJ)Scheduling algo(by HJ)
Scheduling algo(by HJ)Harshit Jain
 
programming .pptx
programming .pptxprogramming .pptx
programming .pptxSHUJEHASSAN
 
chapter 5 CPU scheduling.ppt
chapter  5 CPU scheduling.pptchapter  5 CPU scheduling.ppt
chapter 5 CPU scheduling.pptKeyreSebre
 
Operating Systems 1 (10/12) - Scheduling
Operating Systems 1 (10/12) - SchedulingOperating Systems 1 (10/12) - Scheduling
Operating Systems 1 (10/12) - SchedulingPeter Tröger
 
Round-ribon algorithm presntation
Round-ribon algorithm presntationRound-ribon algorithm presntation
Round-ribon algorithm presntationJamsheed Ali
 
In computing, scheduling is the action .
In computing, scheduling is the action .In computing, scheduling is the action .
In computing, scheduling is the action .nathansel1
 
dataprocess using different technology.ppt
dataprocess using different technology.pptdataprocess using different technology.ppt
dataprocess using different technology.pptssuserf6eb9b
 
operating system (1).pdf
operating system (1).pdfoperating system (1).pdf
operating system (1).pdfAliyanAbbas1
 
OS Process Chapter 3.pdf
OS Process Chapter 3.pdfOS Process Chapter 3.pdf
OS Process Chapter 3.pdfKp Sharma
 

Similar to UNIPROCESS SCHEDULING.pptx (20)

Section05 scheduling
Section05 schedulingSection05 scheduling
Section05 scheduling
 
Ch05 cpu-scheduling
Ch05 cpu-schedulingCh05 cpu-scheduling
Ch05 cpu-scheduling
 
Lect07
Lect07Lect07
Lect07
 
Operating system 28 fundamental of scheduling
Operating system 28 fundamental of schedulingOperating system 28 fundamental of scheduling
Operating system 28 fundamental of scheduling
 
Ch6 cpu scheduling
Ch6   cpu schedulingCh6   cpu scheduling
Ch6 cpu scheduling
 
Scheduling algorithms
Scheduling algorithmsScheduling algorithms
Scheduling algorithms
 
Lecture 4 process cpu scheduling
Lecture 4   process cpu schedulingLecture 4   process cpu scheduling
Lecture 4 process cpu scheduling
 
CPU Scheduling.pptx
CPU Scheduling.pptxCPU Scheduling.pptx
CPU Scheduling.pptx
 
Osy ppt - Copy.pptx
Osy ppt - Copy.pptxOsy ppt - Copy.pptx
Osy ppt - Copy.pptx
 
Scheduling algo(by HJ)
Scheduling algo(by HJ)Scheduling algo(by HJ)
Scheduling algo(by HJ)
 
CPU Scheduling Part-III.pdf
CPU Scheduling Part-III.pdfCPU Scheduling Part-III.pdf
CPU Scheduling Part-III.pdf
 
programming .pptx
programming .pptxprogramming .pptx
programming .pptx
 
chapter 5 CPU scheduling.ppt
chapter  5 CPU scheduling.pptchapter  5 CPU scheduling.ppt
chapter 5 CPU scheduling.ppt
 
Operating Systems 1 (10/12) - Scheduling
Operating Systems 1 (10/12) - SchedulingOperating Systems 1 (10/12) - Scheduling
Operating Systems 1 (10/12) - Scheduling
 
Round-ribon algorithm presntation
Round-ribon algorithm presntationRound-ribon algorithm presntation
Round-ribon algorithm presntation
 
CPU Scheduling Part-I.pdf
CPU Scheduling Part-I.pdfCPU Scheduling Part-I.pdf
CPU Scheduling Part-I.pdf
 
In computing, scheduling is the action .
In computing, scheduling is the action .In computing, scheduling is the action .
In computing, scheduling is the action .
 
dataprocess using different technology.ppt
dataprocess using different technology.pptdataprocess using different technology.ppt
dataprocess using different technology.ppt
 
operating system (1).pdf
operating system (1).pdfoperating system (1).pdf
operating system (1).pdf
 
OS Process Chapter 3.pdf
OS Process Chapter 3.pdfOS Process Chapter 3.pdf
OS Process Chapter 3.pdf
 

More from ansariparveen06

discrete mathematics binary%20trees.pptx
discrete mathematics binary%20trees.pptxdiscrete mathematics binary%20trees.pptx
discrete mathematics binary%20trees.pptxansariparveen06
 
Introduction to Arduino 16822775 (2).ppt
Introduction to Arduino 16822775 (2).pptIntroduction to Arduino 16822775 (2).ppt
Introduction to Arduino 16822775 (2).pptansariparveen06
 
Fundamentals of programming Arduino-Wk2.ppt
Fundamentals of programming Arduino-Wk2.pptFundamentals of programming Arduino-Wk2.ppt
Fundamentals of programming Arduino-Wk2.pptansariparveen06
 
Combinational_Logic_Circuit.pptx
Combinational_Logic_Circuit.pptxCombinational_Logic_Circuit.pptx
Combinational_Logic_Circuit.pptxansariparveen06
 
presentation_python_7_1569170870_375360.pptx
presentation_python_7_1569170870_375360.pptxpresentation_python_7_1569170870_375360.pptx
presentation_python_7_1569170870_375360.pptxansariparveen06
 
BCom-Sem2-Marketing-Digital-payment-Presentation.pptx
BCom-Sem2-Marketing-Digital-payment-Presentation.pptxBCom-Sem2-Marketing-Digital-payment-Presentation.pptx
BCom-Sem2-Marketing-Digital-payment-Presentation.pptxansariparveen06
 
1-introduction-to-dart-programming.pptx
1-introduction-to-dart-programming.pptx1-introduction-to-dart-programming.pptx
1-introduction-to-dart-programming.pptxansariparveen06
 
exception%20handlingcpp.pptx
exception%20handlingcpp.pptxexception%20handlingcpp.pptx
exception%20handlingcpp.pptxansariparveen06
 
chap1 The_Internet_and_the_World_Wide_Web.ppt
chap1 The_Internet_and_the_World_Wide_Web.pptchap1 The_Internet_and_the_World_Wide_Web.ppt
chap1 The_Internet_and_the_World_Wide_Web.pptansariparveen06
 

More from ansariparveen06 (20)

discrete mathematics binary%20trees.pptx
discrete mathematics binary%20trees.pptxdiscrete mathematics binary%20trees.pptx
discrete mathematics binary%20trees.pptx
 
Introduction to Arduino 16822775 (2).ppt
Introduction to Arduino 16822775 (2).pptIntroduction to Arduino 16822775 (2).ppt
Introduction to Arduino 16822775 (2).ppt
 
Fundamentals of programming Arduino-Wk2.ppt
Fundamentals of programming Arduino-Wk2.pptFundamentals of programming Arduino-Wk2.ppt
Fundamentals of programming Arduino-Wk2.ppt
 
kmap.pptx
kmap.pptxkmap.pptx
kmap.pptx
 
Combinational_Logic_Circuit.pptx
Combinational_Logic_Circuit.pptxCombinational_Logic_Circuit.pptx
Combinational_Logic_Circuit.pptx
 
presentation_python_7_1569170870_375360.pptx
presentation_python_7_1569170870_375360.pptxpresentation_python_7_1569170870_375360.pptx
presentation_python_7_1569170870_375360.pptx
 
BCom-Sem2-Marketing-Digital-payment-Presentation.pptx
BCom-Sem2-Marketing-Digital-payment-Presentation.pptxBCom-Sem2-Marketing-Digital-payment-Presentation.pptx
BCom-Sem2-Marketing-Digital-payment-Presentation.pptx
 
dsa.ppt
dsa.pptdsa.ppt
dsa.ppt
 
11-IOManagement.ppt
11-IOManagement.ppt11-IOManagement.ppt
11-IOManagement.ppt
 
1-introduction-to-dart-programming.pptx
1-introduction-to-dart-programming.pptx1-introduction-to-dart-programming.pptx
1-introduction-to-dart-programming.pptx
 
CHAP4.pptx
CHAP4.pptxCHAP4.pptx
CHAP4.pptx
 
green IT cooling.pptx
green IT cooling.pptxgreen IT cooling.pptx
green IT cooling.pptx
 
06-Deadlocks.ppt
06-Deadlocks.ppt06-Deadlocks.ppt
06-Deadlocks.ppt
 
chp9 green IT.pptx
chp9 green IT.pptxchp9 green IT.pptx
chp9 green IT.pptx
 
regex.ppt
regex.pptregex.ppt
regex.ppt
 
BOM.ppt
BOM.pptBOM.ppt
BOM.ppt
 
Cooling.pptx
Cooling.pptxCooling.pptx
Cooling.pptx
 
exception%20handlingcpp.pptx
exception%20handlingcpp.pptxexception%20handlingcpp.pptx
exception%20handlingcpp.pptx
 
C++InputOutput.pptx
C++InputOutput.pptxC++InputOutput.pptx
C++InputOutput.pptx
 
chap1 The_Internet_and_the_World_Wide_Web.ppt
chap1 The_Internet_and_the_World_Wide_Web.pptchap1 The_Internet_and_the_World_Wide_Web.ppt
chap1 The_Internet_and_the_World_Wide_Web.ppt
 

Recently uploaded

18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdfssuser54595a
 
EPANDING THE CONTENT OF AN OUTLINE using notes.pptx
EPANDING THE CONTENT OF AN OUTLINE using notes.pptxEPANDING THE CONTENT OF AN OUTLINE using notes.pptx
EPANDING THE CONTENT OF AN OUTLINE using notes.pptxRaymartEstabillo3
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxGaneshChakor2
 
Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Celine George
 
Alper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentAlper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentInMediaRes1
 
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...Marc Dusseiller Dusjagr
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxNirmalaLoungPoorunde1
 
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdfEnzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdfSumit Tiwari
 
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdfFraming an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdfUjwalaBharambe
 
Earth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatEarth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatYousafMalik24
 
Historical philosophical, theoretical, and legal foundations of special and i...
Historical philosophical, theoretical, and legal foundations of special and i...Historical philosophical, theoretical, and legal foundations of special and i...
Historical philosophical, theoretical, and legal foundations of special and i...jaredbarbolino94
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptxVS Mahajan Coaching Centre
 
Hierarchy of management that covers different levels of management
Hierarchy of management that covers different levels of managementHierarchy of management that covers different levels of management
Hierarchy of management that covers different levels of managementmkooblal
 
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Celine George
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxSayali Powar
 
Full Stack Web Development Course for Beginners
Full Stack Web Development Course  for BeginnersFull Stack Web Development Course  for Beginners
Full Stack Web Development Course for BeginnersSabitha Banu
 
Proudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxProudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxthorishapillay1
 

Recently uploaded (20)

18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
 
EPANDING THE CONTENT OF AN OUTLINE using notes.pptx
EPANDING THE CONTENT OF AN OUTLINE using notes.pptxEPANDING THE CONTENT OF AN OUTLINE using notes.pptx
EPANDING THE CONTENT OF AN OUTLINE using notes.pptx
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptx
 
Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17
 
Alper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentAlper Gobel In Media Res Media Component
Alper Gobel In Media Res Media Component
 
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptx
 
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdfEnzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
 
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdfFraming an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
 
Earth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatEarth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice great
 
Historical philosophical, theoretical, and legal foundations of special and i...
Historical philosophical, theoretical, and legal foundations of special and i...Historical philosophical, theoretical, and legal foundations of special and i...
Historical philosophical, theoretical, and legal foundations of special and i...
 
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdfTataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
 
Hierarchy of management that covers different levels of management
Hierarchy of management that covers different levels of managementHierarchy of management that covers different levels of management
Hierarchy of management that covers different levels of management
 
ESSENTIAL of (CS/IT/IS) class 06 (database)
ESSENTIAL of (CS/IT/IS) class 06 (database)ESSENTIAL of (CS/IT/IS) class 06 (database)
ESSENTIAL of (CS/IT/IS) class 06 (database)
 
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
 
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
 
Full Stack Web Development Course for Beginners
Full Stack Web Development Course  for BeginnersFull Stack Web Development Course  for Beginners
Full Stack Web Development Course for Beginners
 
Proudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxProudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptx
 

UNIPROCESS SCHEDULING.pptx

  • 2. Chapter 6 2 CPU Scheduling Chapter 6
  • 3. 3 Classification of Scheduling Activity • Long-term: which process to admit • Medium-term: which process to swap in or out • Short-term: which ready process to execute next
  • 4. 4 Long-Term Scheduling • Determines which programs are admitted to the system for processing • Controls the degree of multiprogramming • If more processes are admitted – less likely that all processes will be blocked – better CPU usage – each process has smaller fraction of the CPU • The long term scheduler may attempt to
  • 5. 5 Medium-Term Scheduling • Swapping decisions based on the need to manage multiprogramming – Allows the long-term scheduler to admit more processes than actually fit in memory – but too many processes can increase disk activity (paging), so there is some “optimum” level of multiprogramming. • Done by memory management software (chapter 8)
  • 6. 6 Short-Term Scheduling • Determines which process is going to execute next (also called CPU scheduling) • the focus of this chapter.. • invoked on a event that may lead to choosing another process for execution: – clock interrupts – I/O interrupts – operating system calls and traps, including I/O – signals
  • 7. 7 The CPU-I/O Cycle Silberschatz, Galvin, and Gagne 1999 “CPU-bound” processes require more CPU time than I/O time “I/O-bound” processes spend most of their time waiting for I/O.
  • 8. 8 Histogram of CPU-burst Times Silberschatz, Galvin, and Gagne 1999
  • 9. 9 Our focus • Uniprocessor Scheduling: scheduling a single CPU among all the processes in the system • Key Criteria: – Maximize CPU utilization – Maximize throughput – Minimize waiting times – Minimize response time – Minimize turnaround time
  • 10. 10 Criteria • Maximize CPU utilization – Efficiency – Need to keep the CPU busy • Minimize waiting times – Time spent waiting in READY queue – Each process should get a fair share of the CPU
  • 11. 11 Criteria • Maximize throughput – Process completions per time unit • Minimize response time – From a user request to the first response – I/O bound processes • Minimize turnaround time – CPU-bound process equivalent of response time – Elapsed time to complete a process
  • 12. 12 User vs. System Scheduling Criteria User-oriented • Turnaround Time (batch systems): Elapsed time from the submission of a process to its completion • Response Time (interactive systems): Elapsed time from the submission of a request to the first response System-oriented • CPU utilization • fairness • throughput: processes completed per unit time
  • 13. 13 Two Components of Scheduling Policies Selection function • which process in the ready queue is selected next for execution? Decision mode • at what times is the selection function exercised? – Nonpreemptive • A process in the running state runs until it blocks or ends – Preemptive • Currently running process may be interrupted and moved to the Ready state by the OS • Prevents any one process from monopolizing the CPU
  • 14. 14 Policy vs. Mechanism • Important in scheduling and resource allocation algorithms • Policy – What is to be done • Mechanism – How to do it • Policy: All users equal access • Mechanism: round robin scheduling • Policy: Paid jobs get higher priority • Mechanism: Preemptive scheduling
  • 15. 15 A running example to discuss various scheduling policies Process Arrival Time Burst Time 1 2 3 4 5 0 2 4 6 8 3 6 4 5 2
  • 16. 16 First Come First Served (FCFS) • Selection function: the process that has been waiting the longest in the ready queue (hence, FCFS, FIFO queue) • Decision mode: nonpreemptive – a process runs until it blocks itself (I/O or other)
  • 17. 17 FCFS Drawbacks • Favors CPU-bound processes – A process that does not perform any I/O will monopolize the processor! – I/O-bound processes have to wait until CPU-bound process completes – They may have to wait even when their I/Os have completed • poor device utilization – We could reduce the average wait time by giving more priority to I/O bound processes
  • 18. 18 Shortest Job First (SJF) • Selection function: the process with the shortest expected CPU burst time • Decision mode: non-preemptive • I/O bound processes will be picked first • We need to estimate the expected CPU burst time for each process: on the basis of past behavior. Shortest job First (SJF)
  • 19. 19 Estimating the Required CPU Burst • Can average all past history equally • But recent history of a process is more likely to reflect future behavior • A common technique for that is to use exponential averaging – S[n+1] = a T[n] + (1-a) S[n] ; 0 < a < 1 – Puts more weight on recent instances whenever a > 1/n
  • 21. 21 Exponential Averaging • Set S[1] = 0 to give new processes high priority. • Exponential averaging tracks changes in process behavior much faster than simple averaging.
  • 22. 22 Shortest Job First: Critique • SJF implicitly incorporates priorities: shortest jobs are given preference. – Typically these are I/O bound jobs • Longer processes can starve if there is a steady supply of shorter processes • Lack of preemption not suitable in a time sharing environment – CPU bound process gets lower priority – But a process doing no I/O at all could monopolize the CPU if it is the first one in the system
  • 23. 23 Shortest Remaining Time (SRT) = Preemptive SJF • If a process arrives in the Ready queue with estimated CPU burst less than remaining time of the currently running process, preempt. • Prevents long jobs from dominating. – But must keep track of remaining burst times • Better turnaround time than SJF – Short jobs get immediate preference
  • 24. 24 • Selection function: same as FCFS • Decision mode: Preemptive – Maximum time slice (typically 10 - 100 ms) enforced by timer interrupt – running process is put at the tail of the ready queue Round-Robin
  • 25. 25 Time Quantum for Round Robin • must be substantially larger than process switch time • should be larger than the typical CPU burst • If too large, degenerates to FCFS • Too small, excessive context switches (overhead)
  • 26. 26 Fairness vs. Efficiency • Each context switch has the OS using the CPU instead of the user process – give up CPU, save all info, reload w/ status of incoming process – Say 20 ms quantum length, 5 ms context switch – Waste of resources • 20% of CPU time (5/20) for context switch – If 500 ms quantum, better use of resources • 1% of CPU time (5/500) for context switch • Bad if lots of users in system – interactive users waiting for CPU
  • 27. 27 Round Robin: Critique • Still favors CPU-bound processes – An I/O bound process uses the CPU for a time less than the time quantum and then is blocked waiting for I/O – A CPU-bound process runs for its whole time slice and goes back into the ready queue (in front of the blocked processes) • One solution: virtual round robin (VRR, not in book…) – When a I/O has completed, the blocked process is moved to an auxiliary queue which gets preference over the main ready queue – A process dispatched from the auxiliary queue gets a shorter time quantum (what is “left over” from its quantum when it was last selected from the ready queue)
  • 28. FIRST COME FIRST SERVE (FCFS) • Characteristics of FCFS CPU Process Scheduling 1. Implementation is simple. 2. Does not cause any causalities while using 3. It adopts a non pre emptive and pre emptive strategy. 4. It runs each procedure in the order that they are received. 5. Arrival time is used as a selection criterion for procedures.
  • 29. • Advantages of FCFS CPU Process Scheduling • The advantages of FCFS CPU Process Scheduling are: • In order to allocate processes, it uses the First In First Out queue. • The FCFS CPU Scheduling Process is straight forward and easy to implement. • In the FCFS situation pre emptive scheduling, there is no chance of process starving.
  • 30. The disadvantages of FCFS CPU Process Scheduling are: 1. FCFS CPU Scheduling Algorithm has Long Waiting Time 2. FCFS CPU Scheduling favors CPU over Input or Output operations 3. In FCFS there is a chance of occurrence of Convoy Effect 4. Because FCFS is so straight forward, it often isn't very effective. Extended waiting periods go hand in hand with this. All other orders are left idle if the CPU is busy processing one time-consuming order.
  • 31. EXAMPLE : • S. No Process ID Process Name Arrival Time Burst Time • _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ • 1 P 1 A 0 9 • 2 P 2 B 1 3 • 3 P 3 C 1 2 • 4 P 4 D 1 4 • 5 P 5 E 2 3 • 6 P 6 F 3 2
  • 32. FCFS Scheduling Algorithms in OS (Operating System) • Gantt chart for the above Example 1 is: • Turn Around Time = Completion Time - Arrival Time • Waiting Time = Turn Around Time - Burst Time
  • 33. • Solution”: • S. No P ID Arrival Time Burst Time Completion Time Turn Around Time Waiting Time • 1 P 1 0 9 9 9 0 • 2 P 2 1 3 12 11 8 • 3 P 3 1 2 14 13 11 • 4 P 4 1 4 18 17 13 • 5 P 5 2 3 21 19 16 • 6 P 6 3 2 23 20 18 Turn Around Time = Completion Time - Arrival Time Waiting Time = Turn Around Time - Burst Time ( TAT= WT + BT )