SlideShare a Scribd company logo
Chapter 2
Scheduling
Outline
 CPU Scheduling
 Importance of scheduling in diff. environment
 CPU bound process, I/O bound process
 Preemptive, non-preemptive scheduling
 Batch system scheduling algorithms
 FCFS, Shortest Job First, Shortest Remaining
First
 Interactive system scheduling
 RR, Priority scheduling, Lottery Scheduling
 Real-time system scheduling
 Thread Scheduling
 User-level thread
 Kernel-level thread
Figure 2-2. A process can be in running, blocked, or ready
state. Transitions between these states are as shown.
Process States
Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639
Figure 2-4. Some of the fields of a typical process table entry.
Process Control Table
Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639
Process Scheduling Queues
 Job queue – set of all processes in the system
 Ready queue – set of all processes residing in
main memory, ready and waiting to execute
 Device queues – set of processes waiting for an
I/O device Processes migrate among the various
queues
Representation of Process Scheduling
Schedulers
 When to schedule?
 when a process is created, or exits
 when a process blocks on I/O, semaphore, mutex…
 interrupts: hardware or software
 timer interrupt: non-preemptive vs preemptive
scheduling
 Long-term scheduler (or job scheduler) – selects
which processes should be brought into the ready
queue
 Short-term scheduler (or CPU scheduler) – selects
which process should be executed next and allocates
CPU
Schedulers
 Short-term scheduler is invoked very frequently
(milliseconds) ⇒ (must be fast)
 Long-term scheduler is invoked very infrequently
(seconds, minutes) ⇒ (may be slow)
 The long-term scheduler controls the degree of
multiprogramming
 Processes can be described as either:
 I/O-bound process – spends more time doing I/O
than computations, many short CPU bursts
 CPU-bound process – spends more time doing
computations; few very long CPU bursts
Bursts of CPU usage alternate with periods of waiting for I/O. (a) A
CPU-bound process. (b) An I/O-bound process.
Process Behavior
Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639
 Batch system: business application, no end
users
 non-preemptive, preemptive(task is
assigned priority wise)
 Interactive system: with interactive users, or
server (with multiple remote interactive
users)
 preemption
 Real time system:
Categories of Scheduling Algorithms
Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639
Scheduling Algorithm Goals
Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639
• First-come first-served
• Shortest job first
• Shortest remaining Time next
Scheduling in Batch Systems
Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639
• First-come first-served
• processes assigned CPU in order of request
• when running process blocks, schedule next one in queue
• when blocking process becomes ready, enter end of
queue
• Pros: simple, easy to implement, fair (in some sense)
• Cons:
• short jobs arrive after a very long job
• one compute-bound process (1 sec at a time), many IO-
bound processes (perform 1000 disk reads) => take a long
time to finish I/O bound process
First Come First Served
Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639
• Assumption: run time for processes are known
in advance
• Scheduler: among equally important jobs in
ready queue, pick the one with the shortest run
time.
• Proof: Shortest Job First yields smallest
average turnaround time, if all jobs are available
simultaneously.
Shortest Job First
Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639
Figure 2-40. An example of shortest job first scheduling.
(a) Running four jobs in the original order. (b) Running them in
shortest job first order.
Shortest Job First
Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639
• Jobs/Processes can arrive at different time
• Preemptive version of Shortest Job First
• When new job arrives, if its run time is smaller than
current process’s remaining time, schedule the new job
• Some kind of greedy algorithm: keep the ready queue
as short as possible
Shortest Remaining Time next
Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639
• Round-robin scheduling
• Priority scheduling
• Multiple queues
• Shortest process next
• Guaranteed scheduling
• Lottery scheduling
• Fair-share scheduling
Scheduling in Interactive Systems
Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639
• A process, when scheduled to run, is assigned
the CPU for a time interval, quantum
• If process blocks or finishes before quantum
expires, CPU switches to run other process
• If still running at end of quantum, preempt and
schedule other process to run
• Length of quantum
• too short => too much context switch overhead
• too long => system not responsive/interactive
• typical setting: 20-50 msec
Round-Robin Scheduling
Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639
Figure 2-41. Round-robin scheduling.
(a) The list of runnable processes. (b) The list of runnable
processes after B uses up its quantum.
Round-Robin Scheduling
Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639
• Idea: assign each process a priority, ready
processes with highest priority is scheduled to
run
• Setting priority
• based upon the process’s user ID: position,
payment
• higher priority for interactive process, lower priority
for background process => to be responsive
• dynamically assigned
• e.g., give higher priority to I/O bound process
Priority Scheduling
Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639
Priority Scheduling: data structure
Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639
Run for one quantum
Run for 2 quanta
Run for 4 quanta
Run for 8 quanta
Example (CTSS)
• CPU bound process will sink to long priority queue
• If used up quantum, move down one class
• larger quantum => cut context switch overhead
• I/O bound process will stay at high priority queue
• Interactive process:
• wait for command
• execute command
• go back to 1
• To minimize response time (step 2 above),
schedule process with shortest running time
Interactive Systems: shortest process next
Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639
• A randomized scheme
• each process given lottery tickets for CPU resource
• Scheduler: choose a lottery ticket at random, the process
holds the ticket is the scheduled to run
• The more tickets a process holds, the higher probability
of scheduled to run
• Pros:
• proportional allocation of CPU
• allow transferring of tickets among cooperating
processes,
Interactive Systems: Lottery Scheduling
Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639
• Real-time system: must react to external events
within a fixed amount of time
• Periodic events vs aperiodic events
• e.g., in voIP system, incoming audio packets
are periodic events
• in intrusion detection system, detected
abnormal signal is an aperiodic event
• Hard real time
• absolute deadline
• Soft real time
• soft deadline: ok to miss occasionally, e.g.,
multimedia system
Scheduling in Real-time Systems
Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639
Figure 2-43. (a) Possible scheduling of user-level threads with a
50-msec process quantum and threads that run 5 msec per
CPU burst.
Thread Scheduling (1)
Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639
Figure 2-43. (b) Possible scheduling of kernel-level threads with
the same characteristics as (a).
Thread Scheduling (2)
Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639
Figure 2-44. Lunch time in the Philosophy Department.
Dining Philosophers Problem
Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639

More Related Content

What's hot

Real Time Systems
Real Time SystemsReal Time Systems
Real Time Systems
Deepak John
 
Process scheduling (CPU Scheduling)
Process scheduling (CPU Scheduling)Process scheduling (CPU Scheduling)
Process scheduling (CPU Scheduling)
Mukesh Chinta
 
RTOS APPLICATIONS
RTOS  APPLICATIONSRTOS  APPLICATIONS
RTOS APPLICATIONS
Dr.YNM
 
Real time system
Real time systemReal time system
Real time system
Aftab Hossain
 
RTAI - Earliest Deadline First
RTAI - Earliest Deadline FirstRTAI - Earliest Deadline First
RTAI - Earliest Deadline First
Stefano Bragaglia
 
Real time-system
Real time-systemReal time-system
Real time-system
ysush
 
Real time operating-systems
Real time operating-systemsReal time operating-systems
Real time operating-systems
kasi963
 
Real Time System
Real Time SystemReal Time System
Real Time System
AKANSH SINGHAL
 
Chapter 19 - Real Time Systems
Chapter 19 - Real Time SystemsChapter 19 - Real Time Systems
Chapter 19 - Real Time Systems
Wayne Jones Jnr
 
cpu scheduling
cpu schedulingcpu scheduling
cpu scheduling
hashim102
 
Pipelining
PipeliningPipelining
Pipelining
sarith divakar
 
Lecture 4 process cpu scheduling
Lecture 4   process cpu schedulingLecture 4   process cpu scheduling
Lecture 4 process cpu scheduling
Kumbirai Junior Muzavazi
 
Process scheduling
Process schedulingProcess scheduling
Process scheduling
Deepika Balichwal
 
Operating System-Process Scheduling
Operating System-Process SchedulingOperating System-Process Scheduling
Operating System-Process Scheduling
Shipra Swati
 
High Performance Computer Architecture
High Performance Computer ArchitectureHigh Performance Computer Architecture
High Performance Computer Architecture
Subhasis Dash
 
2 os structure
2 os structure2 os structure
2 os structure
BaliThorat1
 
cpu scheduling OS
 cpu scheduling OS cpu scheduling OS
cpu scheduling OS
Kiran Kumar Thota
 
03. top level view of computer function & interconnection
03. top level view of computer function & interconnection03. top level view of computer function & interconnection
03. top level view of computer function & interconnection
noman yasin
 
RTOS Basic Concepts
RTOS Basic ConceptsRTOS Basic Concepts
RTOS Basic Concepts
Pantech ProLabs India Pvt Ltd
 

What's hot (19)

Real Time Systems
Real Time SystemsReal Time Systems
Real Time Systems
 
Process scheduling (CPU Scheduling)
Process scheduling (CPU Scheduling)Process scheduling (CPU Scheduling)
Process scheduling (CPU Scheduling)
 
RTOS APPLICATIONS
RTOS  APPLICATIONSRTOS  APPLICATIONS
RTOS APPLICATIONS
 
Real time system
Real time systemReal time system
Real time system
 
RTAI - Earliest Deadline First
RTAI - Earliest Deadline FirstRTAI - Earliest Deadline First
RTAI - Earliest Deadline First
 
Real time-system
Real time-systemReal time-system
Real time-system
 
Real time operating-systems
Real time operating-systemsReal time operating-systems
Real time operating-systems
 
Real Time System
Real Time SystemReal Time System
Real Time System
 
Chapter 19 - Real Time Systems
Chapter 19 - Real Time SystemsChapter 19 - Real Time Systems
Chapter 19 - Real Time Systems
 
cpu scheduling
cpu schedulingcpu scheduling
cpu scheduling
 
Pipelining
PipeliningPipelining
Pipelining
 
Lecture 4 process cpu scheduling
Lecture 4   process cpu schedulingLecture 4   process cpu scheduling
Lecture 4 process cpu scheduling
 
Process scheduling
Process schedulingProcess scheduling
Process scheduling
 
Operating System-Process Scheduling
Operating System-Process SchedulingOperating System-Process Scheduling
Operating System-Process Scheduling
 
High Performance Computer Architecture
High Performance Computer ArchitectureHigh Performance Computer Architecture
High Performance Computer Architecture
 
2 os structure
2 os structure2 os structure
2 os structure
 
cpu scheduling OS
 cpu scheduling OS cpu scheduling OS
cpu scheduling OS
 
03. top level view of computer function & interconnection
03. top level view of computer function & interconnection03. top level view of computer function & interconnection
03. top level view of computer function & interconnection
 
RTOS Basic Concepts
RTOS Basic ConceptsRTOS Basic Concepts
RTOS Basic Concepts
 

Similar to Scheduling

tan2.ppt
tan2.ppttan2.ppt
tan2.ppt
SangeethaBS4
 
Resource Management in (Embedded) Real-Time Systems
Resource Management in (Embedded) Real-Time SystemsResource Management in (Embedded) Real-Time Systems
Resource Management in (Embedded) Real-Time Systems
jeronimored
 
Unit iios process scheduling and synchronization
Unit iios process scheduling and synchronizationUnit iios process scheduling and synchronization
Unit iios process scheduling and synchronization
donny101
 
Cp usched 2
Cp usched  2Cp usched  2
Cp usched 2
nidsrajdev
 
Operating system Q/A
Operating system Q/AOperating system Q/A
Operating system Q/A
Abdul Munam
 
May14ProcessScheduling.ppt
May14ProcessScheduling.pptMay14ProcessScheduling.ppt
May14ProcessScheduling.ppt
ansariparveen06
 
pscheduling.ppt
pscheduling.pptpscheduling.ppt
pscheduling.ppt
ansariparveen06
 
Process scheduling
Process schedulingProcess scheduling
Process scheduling
Riya Choudhary
 
Operating System Scheduling
Operating System SchedulingOperating System Scheduling
Operating System Scheduling
Vishnu Prasad
 
Part 1 - PROCESS CONCEPTS
Part 1  - PROCESS CONCEPTSPart 1  - PROCESS CONCEPTS
Part 1 - PROCESS CONCEPTS
priyasoundar
 
UNIT II - CPU SCHEDULING.docx
UNIT II - CPU SCHEDULING.docxUNIT II - CPU SCHEDULING.docx
UNIT II - CPU SCHEDULING.docx
karthikaparthasarath
 
Introduction to Scheduling
Introduction to SchedulingIntroduction to Scheduling
Introduction to Scheduling
pec2013
 
Processes and Threads
Processes and ThreadsProcesses and Threads
Processes and Threads
Munazza-Mah-Jabeen
 
Cpu scheduling
Cpu schedulingCpu scheduling
Cpu scheduling
marangburu42
 
Cpu scheduling pre final formatting
Cpu scheduling pre final formattingCpu scheduling pre final formatting
Cpu scheduling pre final formatting
marangburu42
 
Cpu scheduling final
Cpu scheduling finalCpu scheduling final
Cpu scheduling final
marangburu42
 
ch_scheduling (1).ppt
ch_scheduling (1).pptch_scheduling (1).ppt
ch_scheduling (1).ppt
Farhanahmad540205
 
Scheduling algorithms
Scheduling algorithmsScheduling algorithms
Scheduling algorithms
Paurav Shah
 
Memory Management
Memory ManagementMemory Management
Memory Management
Munazza-Mah-Jabeen
 
Operating Systems 1 (10/12) - Scheduling
Operating Systems 1 (10/12) - SchedulingOperating Systems 1 (10/12) - Scheduling
Operating Systems 1 (10/12) - Scheduling
Peter Tröger
 

Similar to Scheduling (20)

tan2.ppt
tan2.ppttan2.ppt
tan2.ppt
 
Resource Management in (Embedded) Real-Time Systems
Resource Management in (Embedded) Real-Time SystemsResource Management in (Embedded) Real-Time Systems
Resource Management in (Embedded) Real-Time Systems
 
Unit iios process scheduling and synchronization
Unit iios process scheduling and synchronizationUnit iios process scheduling and synchronization
Unit iios process scheduling and synchronization
 
Cp usched 2
Cp usched  2Cp usched  2
Cp usched 2
 
Operating system Q/A
Operating system Q/AOperating system Q/A
Operating system Q/A
 
May14ProcessScheduling.ppt
May14ProcessScheduling.pptMay14ProcessScheduling.ppt
May14ProcessScheduling.ppt
 
pscheduling.ppt
pscheduling.pptpscheduling.ppt
pscheduling.ppt
 
Process scheduling
Process schedulingProcess scheduling
Process scheduling
 
Operating System Scheduling
Operating System SchedulingOperating System Scheduling
Operating System Scheduling
 
Part 1 - PROCESS CONCEPTS
Part 1  - PROCESS CONCEPTSPart 1  - PROCESS CONCEPTS
Part 1 - PROCESS CONCEPTS
 
UNIT II - CPU SCHEDULING.docx
UNIT II - CPU SCHEDULING.docxUNIT II - CPU SCHEDULING.docx
UNIT II - CPU SCHEDULING.docx
 
Introduction to Scheduling
Introduction to SchedulingIntroduction to Scheduling
Introduction to Scheduling
 
Processes and Threads
Processes and ThreadsProcesses and Threads
Processes and Threads
 
Cpu scheduling
Cpu schedulingCpu scheduling
Cpu scheduling
 
Cpu scheduling pre final formatting
Cpu scheduling pre final formattingCpu scheduling pre final formatting
Cpu scheduling pre final formatting
 
Cpu scheduling final
Cpu scheduling finalCpu scheduling final
Cpu scheduling final
 
ch_scheduling (1).ppt
ch_scheduling (1).pptch_scheduling (1).ppt
ch_scheduling (1).ppt
 
Scheduling algorithms
Scheduling algorithmsScheduling algorithms
Scheduling algorithms
 
Memory Management
Memory ManagementMemory Management
Memory Management
 
Operating Systems 1 (10/12) - Scheduling
Operating Systems 1 (10/12) - SchedulingOperating Systems 1 (10/12) - Scheduling
Operating Systems 1 (10/12) - Scheduling
 

More from Munazza-Mah-Jabeen

Virtual Functions
Virtual FunctionsVirtual Functions
Virtual Functions
Munazza-Mah-Jabeen
 
The Standard Template Library
The Standard Template LibraryThe Standard Template Library
The Standard Template Library
Munazza-Mah-Jabeen
 
Object-Oriented Software
Object-Oriented SoftwareObject-Oriented Software
Object-Oriented Software
Munazza-Mah-Jabeen
 
Templates and Exceptions
 Templates and Exceptions Templates and Exceptions
Templates and Exceptions
Munazza-Mah-Jabeen
 
Dictionaries and Sets
Dictionaries and SetsDictionaries and Sets
Dictionaries and Sets
Munazza-Mah-Jabeen
 
More About Strings
More About StringsMore About Strings
More About Strings
Munazza-Mah-Jabeen
 
Streams and Files
Streams and FilesStreams and Files
Streams and Files
Munazza-Mah-Jabeen
 
Lists and Tuples
Lists and TuplesLists and Tuples
Lists and Tuples
Munazza-Mah-Jabeen
 
Files and Exceptions
Files and ExceptionsFiles and Exceptions
Files and Exceptions
Munazza-Mah-Jabeen
 
Functions
FunctionsFunctions
Pointers
PointersPointers
Repitition Structure
Repitition StructureRepitition Structure
Repitition Structure
Munazza-Mah-Jabeen
 
Inheritance
InheritanceInheritance
Inheritance
Munazza-Mah-Jabeen
 
Operator Overloading
Operator OverloadingOperator Overloading
Operator Overloading
Munazza-Mah-Jabeen
 
Memory Management
Memory ManagementMemory Management
Memory Management
Munazza-Mah-Jabeen
 
Arrays and Strings
Arrays and StringsArrays and Strings
Arrays and Strings
Munazza-Mah-Jabeen
 
Objects and Classes
Objects and ClassesObjects and Classes
Objects and Classes
Munazza-Mah-Jabeen
 
Functions
FunctionsFunctions
Structures
StructuresStructures
Structures
Munazza-Mah-Jabeen
 
Loops and Decisions
Loops and DecisionsLoops and Decisions
Loops and Decisions
Munazza-Mah-Jabeen
 

More from Munazza-Mah-Jabeen (20)

Virtual Functions
Virtual FunctionsVirtual Functions
Virtual Functions
 
The Standard Template Library
The Standard Template LibraryThe Standard Template Library
The Standard Template Library
 
Object-Oriented Software
Object-Oriented SoftwareObject-Oriented Software
Object-Oriented Software
 
Templates and Exceptions
 Templates and Exceptions Templates and Exceptions
Templates and Exceptions
 
Dictionaries and Sets
Dictionaries and SetsDictionaries and Sets
Dictionaries and Sets
 
More About Strings
More About StringsMore About Strings
More About Strings
 
Streams and Files
Streams and FilesStreams and Files
Streams and Files
 
Lists and Tuples
Lists and TuplesLists and Tuples
Lists and Tuples
 
Files and Exceptions
Files and ExceptionsFiles and Exceptions
Files and Exceptions
 
Functions
FunctionsFunctions
Functions
 
Pointers
PointersPointers
Pointers
 
Repitition Structure
Repitition StructureRepitition Structure
Repitition Structure
 
Inheritance
InheritanceInheritance
Inheritance
 
Operator Overloading
Operator OverloadingOperator Overloading
Operator Overloading
 
Memory Management
Memory ManagementMemory Management
Memory Management
 
Arrays and Strings
Arrays and StringsArrays and Strings
Arrays and Strings
 
Objects and Classes
Objects and ClassesObjects and Classes
Objects and Classes
 
Functions
FunctionsFunctions
Functions
 
Structures
StructuresStructures
Structures
 
Loops and Decisions
Loops and DecisionsLoops and Decisions
Loops and Decisions
 

Recently uploaded

Observational Learning
Observational Learning Observational Learning
Observational Learning
sanamushtaq922
 
Gender and Mental Health - Counselling and Family Therapy Applications and In...
Gender and Mental Health - Counselling and Family Therapy Applications and In...Gender and Mental Health - Counselling and Family Therapy Applications and In...
Gender and Mental Health - Counselling and Family Therapy Applications and In...
PsychoTech Services
 
Bonku-Babus-Friend by Sathyajith Ray (9)
Bonku-Babus-Friend by Sathyajith Ray  (9)Bonku-Babus-Friend by Sathyajith Ray  (9)
Bonku-Babus-Friend by Sathyajith Ray (9)
nitinpv4ai
 
SWOT analysis in the project Keeping the Memory @live.pptx
SWOT analysis in the project Keeping the Memory @live.pptxSWOT analysis in the project Keeping the Memory @live.pptx
SWOT analysis in the project Keeping the Memory @live.pptx
zuzanka
 
The basics of sentences session 7pptx.pptx
The basics of sentences session 7pptx.pptxThe basics of sentences session 7pptx.pptx
The basics of sentences session 7pptx.pptx
heathfieldcps1
 
CIS 4200-02 Group 1 Final Project Report (1).pdf
CIS 4200-02 Group 1 Final Project Report (1).pdfCIS 4200-02 Group 1 Final Project Report (1).pdf
CIS 4200-02 Group 1 Final Project Report (1).pdf
blueshagoo1
 
Data Structure using C by Dr. K Adisesha .ppsx
Data Structure using C by Dr. K Adisesha .ppsxData Structure using C by Dr. K Adisesha .ppsx
Data Structure using C by Dr. K Adisesha .ppsx
Prof. Dr. K. Adisesha
 
REASIGNACION 2024 UGEL CHUPACA 2024 UGEL CHUPACA.pdf
REASIGNACION 2024 UGEL CHUPACA 2024 UGEL CHUPACA.pdfREASIGNACION 2024 UGEL CHUPACA 2024 UGEL CHUPACA.pdf
REASIGNACION 2024 UGEL CHUPACA 2024 UGEL CHUPACA.pdf
giancarloi8888
 
Temple of Asclepius in Thrace. Excavation results
Temple of Asclepius in Thrace. Excavation resultsTemple of Asclepius in Thrace. Excavation results
Temple of Asclepius in Thrace. Excavation results
Krassimira Luka
 
How to Fix [Errno 98] address already in use
How to Fix [Errno 98] address already in useHow to Fix [Errno 98] address already in use
How to Fix [Errno 98] address already in use
Celine George
 
RESULTS OF THE EVALUATION QUESTIONNAIRE.pptx
RESULTS OF THE EVALUATION QUESTIONNAIRE.pptxRESULTS OF THE EVALUATION QUESTIONNAIRE.pptx
RESULTS OF THE EVALUATION QUESTIONNAIRE.pptx
zuzanka
 
skeleton System.pdf (skeleton system wow)
skeleton System.pdf (skeleton system wow)skeleton System.pdf (skeleton system wow)
skeleton System.pdf (skeleton system wow)
Mohammad Al-Dhahabi
 
How to Setup Default Value for a Field in Odoo 17
How to Setup Default Value for a Field in Odoo 17How to Setup Default Value for a Field in Odoo 17
How to Setup Default Value for a Field in Odoo 17
Celine George
 
Wound healing PPT
Wound healing PPTWound healing PPT
Wound healing PPT
Jyoti Chand
 
How to Download & Install Module From the Odoo App Store in Odoo 17
How to Download & Install Module From the Odoo App Store in Odoo 17How to Download & Install Module From the Odoo App Store in Odoo 17
How to Download & Install Module From the Odoo App Store in Odoo 17
Celine George
 
BÀI TẬP BỔ TRỢ TIẾNG ANH LỚP 8 - CẢ NĂM - FRIENDS PLUS - NĂM HỌC 2023-2024 (B...
BÀI TẬP BỔ TRỢ TIẾNG ANH LỚP 8 - CẢ NĂM - FRIENDS PLUS - NĂM HỌC 2023-2024 (B...BÀI TẬP BỔ TRỢ TIẾNG ANH LỚP 8 - CẢ NĂM - FRIENDS PLUS - NĂM HỌC 2023-2024 (B...
BÀI TẬP BỔ TRỢ TIẾNG ANH LỚP 8 - CẢ NĂM - FRIENDS PLUS - NĂM HỌC 2023-2024 (B...
Nguyen Thanh Tu Collection
 
KHUSWANT SINGH.pptx ALL YOU NEED TO KNOW ABOUT KHUSHWANT SINGH
KHUSWANT SINGH.pptx ALL YOU NEED TO KNOW ABOUT KHUSHWANT SINGHKHUSWANT SINGH.pptx ALL YOU NEED TO KNOW ABOUT KHUSHWANT SINGH
KHUSWANT SINGH.pptx ALL YOU NEED TO KNOW ABOUT KHUSHWANT SINGH
shreyassri1208
 
CapTechTalks Webinar Slides June 2024 Donovan Wright.pptx
CapTechTalks Webinar Slides June 2024 Donovan Wright.pptxCapTechTalks Webinar Slides June 2024 Donovan Wright.pptx
CapTechTalks Webinar Slides June 2024 Donovan Wright.pptx
CapitolTechU
 
Skimbleshanks-The-Railway-Cat by T S Eliot
Skimbleshanks-The-Railway-Cat by T S EliotSkimbleshanks-The-Railway-Cat by T S Eliot
Skimbleshanks-The-Railway-Cat by T S Eliot
nitinpv4ai
 
How to Manage Reception Report in Odoo 17
How to Manage Reception Report in Odoo 17How to Manage Reception Report in Odoo 17
How to Manage Reception Report in Odoo 17
Celine George
 

Recently uploaded (20)

Observational Learning
Observational Learning Observational Learning
Observational Learning
 
Gender and Mental Health - Counselling and Family Therapy Applications and In...
Gender and Mental Health - Counselling and Family Therapy Applications and In...Gender and Mental Health - Counselling and Family Therapy Applications and In...
Gender and Mental Health - Counselling and Family Therapy Applications and In...
 
Bonku-Babus-Friend by Sathyajith Ray (9)
Bonku-Babus-Friend by Sathyajith Ray  (9)Bonku-Babus-Friend by Sathyajith Ray  (9)
Bonku-Babus-Friend by Sathyajith Ray (9)
 
SWOT analysis in the project Keeping the Memory @live.pptx
SWOT analysis in the project Keeping the Memory @live.pptxSWOT analysis in the project Keeping the Memory @live.pptx
SWOT analysis in the project Keeping the Memory @live.pptx
 
The basics of sentences session 7pptx.pptx
The basics of sentences session 7pptx.pptxThe basics of sentences session 7pptx.pptx
The basics of sentences session 7pptx.pptx
 
CIS 4200-02 Group 1 Final Project Report (1).pdf
CIS 4200-02 Group 1 Final Project Report (1).pdfCIS 4200-02 Group 1 Final Project Report (1).pdf
CIS 4200-02 Group 1 Final Project Report (1).pdf
 
Data Structure using C by Dr. K Adisesha .ppsx
Data Structure using C by Dr. K Adisesha .ppsxData Structure using C by Dr. K Adisesha .ppsx
Data Structure using C by Dr. K Adisesha .ppsx
 
REASIGNACION 2024 UGEL CHUPACA 2024 UGEL CHUPACA.pdf
REASIGNACION 2024 UGEL CHUPACA 2024 UGEL CHUPACA.pdfREASIGNACION 2024 UGEL CHUPACA 2024 UGEL CHUPACA.pdf
REASIGNACION 2024 UGEL CHUPACA 2024 UGEL CHUPACA.pdf
 
Temple of Asclepius in Thrace. Excavation results
Temple of Asclepius in Thrace. Excavation resultsTemple of Asclepius in Thrace. Excavation results
Temple of Asclepius in Thrace. Excavation results
 
How to Fix [Errno 98] address already in use
How to Fix [Errno 98] address already in useHow to Fix [Errno 98] address already in use
How to Fix [Errno 98] address already in use
 
RESULTS OF THE EVALUATION QUESTIONNAIRE.pptx
RESULTS OF THE EVALUATION QUESTIONNAIRE.pptxRESULTS OF THE EVALUATION QUESTIONNAIRE.pptx
RESULTS OF THE EVALUATION QUESTIONNAIRE.pptx
 
skeleton System.pdf (skeleton system wow)
skeleton System.pdf (skeleton system wow)skeleton System.pdf (skeleton system wow)
skeleton System.pdf (skeleton system wow)
 
How to Setup Default Value for a Field in Odoo 17
How to Setup Default Value for a Field in Odoo 17How to Setup Default Value for a Field in Odoo 17
How to Setup Default Value for a Field in Odoo 17
 
Wound healing PPT
Wound healing PPTWound healing PPT
Wound healing PPT
 
How to Download & Install Module From the Odoo App Store in Odoo 17
How to Download & Install Module From the Odoo App Store in Odoo 17How to Download & Install Module From the Odoo App Store in Odoo 17
How to Download & Install Module From the Odoo App Store in Odoo 17
 
BÀI TẬP BỔ TRỢ TIẾNG ANH LỚP 8 - CẢ NĂM - FRIENDS PLUS - NĂM HỌC 2023-2024 (B...
BÀI TẬP BỔ TRỢ TIẾNG ANH LỚP 8 - CẢ NĂM - FRIENDS PLUS - NĂM HỌC 2023-2024 (B...BÀI TẬP BỔ TRỢ TIẾNG ANH LỚP 8 - CẢ NĂM - FRIENDS PLUS - NĂM HỌC 2023-2024 (B...
BÀI TẬP BỔ TRỢ TIẾNG ANH LỚP 8 - CẢ NĂM - FRIENDS PLUS - NĂM HỌC 2023-2024 (B...
 
KHUSWANT SINGH.pptx ALL YOU NEED TO KNOW ABOUT KHUSHWANT SINGH
KHUSWANT SINGH.pptx ALL YOU NEED TO KNOW ABOUT KHUSHWANT SINGHKHUSWANT SINGH.pptx ALL YOU NEED TO KNOW ABOUT KHUSHWANT SINGH
KHUSWANT SINGH.pptx ALL YOU NEED TO KNOW ABOUT KHUSHWANT SINGH
 
CapTechTalks Webinar Slides June 2024 Donovan Wright.pptx
CapTechTalks Webinar Slides June 2024 Donovan Wright.pptxCapTechTalks Webinar Slides June 2024 Donovan Wright.pptx
CapTechTalks Webinar Slides June 2024 Donovan Wright.pptx
 
Skimbleshanks-The-Railway-Cat by T S Eliot
Skimbleshanks-The-Railway-Cat by T S EliotSkimbleshanks-The-Railway-Cat by T S Eliot
Skimbleshanks-The-Railway-Cat by T S Eliot
 
How to Manage Reception Report in Odoo 17
How to Manage Reception Report in Odoo 17How to Manage Reception Report in Odoo 17
How to Manage Reception Report in Odoo 17
 

Scheduling

  • 2. Outline  CPU Scheduling  Importance of scheduling in diff. environment  CPU bound process, I/O bound process  Preemptive, non-preemptive scheduling  Batch system scheduling algorithms  FCFS, Shortest Job First, Shortest Remaining First  Interactive system scheduling  RR, Priority scheduling, Lottery Scheduling  Real-time system scheduling  Thread Scheduling  User-level thread  Kernel-level thread
  • 3. Figure 2-2. A process can be in running, blocked, or ready state. Transitions between these states are as shown. Process States Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639
  • 4. Figure 2-4. Some of the fields of a typical process table entry. Process Control Table Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639
  • 5. Process Scheduling Queues  Job queue – set of all processes in the system  Ready queue – set of all processes residing in main memory, ready and waiting to execute  Device queues – set of processes waiting for an I/O device Processes migrate among the various queues
  • 7. Schedulers  When to schedule?  when a process is created, or exits  when a process blocks on I/O, semaphore, mutex…  interrupts: hardware or software  timer interrupt: non-preemptive vs preemptive scheduling  Long-term scheduler (or job scheduler) – selects which processes should be brought into the ready queue  Short-term scheduler (or CPU scheduler) – selects which process should be executed next and allocates CPU
  • 8. Schedulers  Short-term scheduler is invoked very frequently (milliseconds) ⇒ (must be fast)  Long-term scheduler is invoked very infrequently (seconds, minutes) ⇒ (may be slow)  The long-term scheduler controls the degree of multiprogramming  Processes can be described as either:  I/O-bound process – spends more time doing I/O than computations, many short CPU bursts  CPU-bound process – spends more time doing computations; few very long CPU bursts
  • 9. Bursts of CPU usage alternate with periods of waiting for I/O. (a) A CPU-bound process. (b) An I/O-bound process. Process Behavior Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639
  • 10.  Batch system: business application, no end users  non-preemptive, preemptive(task is assigned priority wise)  Interactive system: with interactive users, or server (with multiple remote interactive users)  preemption  Real time system: Categories of Scheduling Algorithms Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639
  • 11. Scheduling Algorithm Goals Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639
  • 12. • First-come first-served • Shortest job first • Shortest remaining Time next Scheduling in Batch Systems Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639
  • 13. • First-come first-served • processes assigned CPU in order of request • when running process blocks, schedule next one in queue • when blocking process becomes ready, enter end of queue • Pros: simple, easy to implement, fair (in some sense) • Cons: • short jobs arrive after a very long job • one compute-bound process (1 sec at a time), many IO- bound processes (perform 1000 disk reads) => take a long time to finish I/O bound process First Come First Served Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639
  • 14. • Assumption: run time for processes are known in advance • Scheduler: among equally important jobs in ready queue, pick the one with the shortest run time. • Proof: Shortest Job First yields smallest average turnaround time, if all jobs are available simultaneously. Shortest Job First Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639
  • 15. Figure 2-40. An example of shortest job first scheduling. (a) Running four jobs in the original order. (b) Running them in shortest job first order. Shortest Job First Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639
  • 16. • Jobs/Processes can arrive at different time • Preemptive version of Shortest Job First • When new job arrives, if its run time is smaller than current process’s remaining time, schedule the new job • Some kind of greedy algorithm: keep the ready queue as short as possible Shortest Remaining Time next Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639
  • 17. • Round-robin scheduling • Priority scheduling • Multiple queues • Shortest process next • Guaranteed scheduling • Lottery scheduling • Fair-share scheduling Scheduling in Interactive Systems Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639
  • 18. • A process, when scheduled to run, is assigned the CPU for a time interval, quantum • If process blocks or finishes before quantum expires, CPU switches to run other process • If still running at end of quantum, preempt and schedule other process to run • Length of quantum • too short => too much context switch overhead • too long => system not responsive/interactive • typical setting: 20-50 msec Round-Robin Scheduling Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639
  • 19. Figure 2-41. Round-robin scheduling. (a) The list of runnable processes. (b) The list of runnable processes after B uses up its quantum. Round-Robin Scheduling Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639
  • 20. • Idea: assign each process a priority, ready processes with highest priority is scheduled to run • Setting priority • based upon the process’s user ID: position, payment • higher priority for interactive process, lower priority for background process => to be responsive • dynamically assigned • e.g., give higher priority to I/O bound process Priority Scheduling Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639
  • 21. Priority Scheduling: data structure Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639 Run for one quantum Run for 2 quanta Run for 4 quanta Run for 8 quanta Example (CTSS) • CPU bound process will sink to long priority queue • If used up quantum, move down one class • larger quantum => cut context switch overhead • I/O bound process will stay at high priority queue
  • 22. • Interactive process: • wait for command • execute command • go back to 1 • To minimize response time (step 2 above), schedule process with shortest running time Interactive Systems: shortest process next Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639
  • 23. • A randomized scheme • each process given lottery tickets for CPU resource • Scheduler: choose a lottery ticket at random, the process holds the ticket is the scheduled to run • The more tickets a process holds, the higher probability of scheduled to run • Pros: • proportional allocation of CPU • allow transferring of tickets among cooperating processes, Interactive Systems: Lottery Scheduling Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639
  • 24. • Real-time system: must react to external events within a fixed amount of time • Periodic events vs aperiodic events • e.g., in voIP system, incoming audio packets are periodic events • in intrusion detection system, detected abnormal signal is an aperiodic event • Hard real time • absolute deadline • Soft real time • soft deadline: ok to miss occasionally, e.g., multimedia system Scheduling in Real-time Systems Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639
  • 25. Figure 2-43. (a) Possible scheduling of user-level threads with a 50-msec process quantum and threads that run 5 msec per CPU burst. Thread Scheduling (1) Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639
  • 26. Figure 2-43. (b) Possible scheduling of kernel-level threads with the same characteristics as (a). Thread Scheduling (2) Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639
  • 27. Figure 2-44. Lunch time in the Philosophy Department. Dining Philosophers Problem Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639