SlideShare a Scribd company logo
Process   Management
Process management is an integral part of any modern day operating system. The OS must allocate resources to processes, enable processes to share and exchange information, protect the resources of each process from other processes and enable synchronization among processes.
To meet these requirements, the OS must maintain a data structure for each process, which describes the state and resource ownership of that process and which enables the OS to exert control over each process.
A process goes through a series of discrete process states. Various events can cause a process to change states. Submit state Hold state Ready state Running state Wait state Complete state
Process scheduling is one of the most important functions of an operating system that supports multiprogramming. This function is heavily dependent on  queues . There are three types of queues that are used in process scheduling:
Job Queue  - Contains all processes that have been introduced into the system Ready Queue  - Contains processes that are waiting for CPU time, and can be selected to run at any time Device Queue  - Contains processes waiting on a certain device. Each device has its own queue for processes that need input/output from it.
Different algorithms used for handling processes 1. Deterministic Scheduling An algorithm wherein all characteristics of a process are known in advance or before execution. 2. Non- Deterministic Scheduling An algorithm wherein characteristics of  processes are not  known in advance.
Types of Queue being used 1. Single Queuing  - All process arrives at the same time with their corresponding burst time. 2.Multiple Queuing – Each process has its own arrival time in the processor.
CPU Scheduling Basic Concepts Scheduling Criteria  Scheduling Algorithms Multiple-Processor Scheduling Thread Scheduling
Basic Concepts Maximum CPU utilization obtained with multiprogramming CPU–I/O Burst Cycle – Process execution consists of a  cycle  of CPU execution and I/O wait CPU times are generally much shorter than I/O times.
CPU-I/O Burst Cycle Process A Process B
Histogram of CPU-burst Times
Schedulers Process migrates among several queues Device queue, job queue, ready queue Scheduler selects a process to run from these queues Long-term scheduler:  load a job in memory Runs infrequently Short-term scheduler: Select ready process to run on CPU Should be fast Middle-term scheduler Reduce multiprogramming or memory consumption
CPU Scheduler CPU scheduling decisions may take place when a process: 1. Switches from running to waiting state (by sleep). 2. Switches from running to ready state (by yield). 3. Switches from waiting to ready (by an interrupt). Terminates (by exit). Scheduling under 1 and 4 is  nonpreemptive . All other scheduling is  preemptive .
Dispatcher Dispatcher module gives control of the CPU to the process selected by the short-term scheduler;  this involves: switching context switching to user mode jumping to the proper location in the user program to restart that program Dispatch latency  – time it takes for the dispatcher to stop one process and start another running
Scheduling Criteria CPU utilization   –  keep the CPU as busy as possible Throughput   –  # of processes that complete their execution per time unit Turnaround time  ( TAT )  –  amount of time to execute a particular process Waiting time   –  amount of time a process has been waiting in the ready queue Response time   –  amount of time it takes from when a request was submitted until the first response is produced,  not  output  (for time-sharing environment)
“ The perfect CPU scheduler” Minimize latency:  response or job completion time  Maximize throughput:  Maximize jobs / time.  Maximize utilization:  keep I/O devices busy.  Recurring theme with OS scheduling Fairness:  everyone makes progress, no one starves
Algorithms
Scheduling Algorithms FCFS First-come First-served  (FCFS) (FIFO) Jobs are scheduled in order of arrival Non-preemptive Problem: Average waiting time depends on arrival order Troublesome for time-sharing systems Convoy effect  short process behind long process Advantage:  really simple!
First Come First Served Scheduling Example: Process Burst Time P 1 24   P 2   3   P 3   3   Suppose that the processes arrive in the order:  P 1  ,  P 2  ,  P 3  Suppose that the processes arrive in the order:  P 2  ,  P 3  ,  P 1  . Waiting time for  P 1   = 0;  P 2   = 24;  P 3  = 27 Average waiting time:  (0 + 24 + 27)/3 = 17 Waiting time for  P 1  =  6 ;   P 2  = 0 ;  P 3  =  3 Average waiting time:  (6 + 0 + 3)/3 = 3 P 1 P 3 P 2 6 3 30 0 P 1 P 2 P 3 24 27 30 0
Shortest-Job-First (SJR) Scheduling Associate with each process the length of its next CPU burst.  Use these lengths to schedule the process with the shortest time Two schemes:   nonpreemptive  – once CPU given to the process it cannot be preempted until completes its CPU burst preemptive  – if a new process arrives with CPU burst length less than remaining time of current executing process, preempt.  This scheme is know as the  Shortest-Remaining-Time-First (SRTF) SJF is optimal  – gives minimum average waiting time for a given set of processes
Shortest Job First Scheduling Example: Process Arrival Time   Burst Time P 1 0 7   P 2   2 4   P 3 4 1 P 4 5 4   Non preemptive SJF P 1 P 3 P 2 7 P 1 (7) 16 0 P 4 8 12 Average waiting time = (0 + 6 + 3 + 7)/4 = 4 2 4 5 P 2 (4) P 3 (1) P 4 (4) P 1 ‘s wating time = 0 P 2 ‘s wating time = 6 P 3 ‘s wating time = 3 P 4 ‘s wating time = 7
Shortest Job First Scheduling Cont’d Example: Process Arrival Time   Burst Time P 1 0 7   P 2   2 4   P 3 4 1 P 4 5 4   Preemptive SJF Average waiting time = (9 + 1 + 0 +2)/4 = 3 P 1 (7) P 2 (4) P 3 (1) P 4 (4) P 1 ‘s wating time = 9 P 2 ‘s wating time = 1 P 3 ‘s wating time = 0 P 4 ‘s wating time = 2 P 1 (5) P 2 (2) P 1 P 3 P 2 4 2 11 0 P 4 5 7 P 2 P 1 16
Shortest Job First Scheduling Cont’d Optimal scheduling However, there are no accurate estimations to know the length of the next CPU burst
Optimal for minimizing queueing time, but impossible to implement.  Tries to predict the process to schedule based on previous history. Predicting the time the process will use on its next schedule: t( n+1 )  =  w * t( n )  + ( 1 - w )  * T( n ) Here:   t(n+1)  is time of next burst.   t(n)  is time of current burst.   T(n)  is average of all previous bursts .   W  is a weighting factor emphasizing current or previous bursts. Shortest Job First Scheduling Cont’d
A  priority number  (integer) is associated with each process The CPU is allocated to the process with the  highest priority  (smallest integer    highest priority in Unix but lowest in Java). Preemptive Non-preemptive SJF is a priority scheduling where priority is the predicted next CPU burst time. Problem    Starvation  – low priority processes may never execute. Solution    Aging –  as time progresses increase the priority of the process. Priority Scheduling
Round Robin (RR) Each process gets a small unit of CPU time  ( time quantum ),  usually  10-100   milliseconds .  After this time has elapsed, the process is preempted and added to the end of the ready queue. If there are  n  processes in the ready queue and the time quantum is  q , then each process gets  1/ n  of the CPU time in chunks of at most  q  time units at once.  No process waits more than  ( n -1) q   time units.
time quantum = 20 Process Burst Time Wait Time P 1 53 57 +24 = 81   P 2 17 20   P 3 68 37 + 40 + 17= 94   P 4 24 57 + 40 = 97 Round Robin Scheduling Average wait time = (81+20+94+97)/4 = 73 57 20 37 57 24 40 40 17 P 1 (53) P 2 (17) P 3 (68) P 4 (24) P 1 (33) P 1 (13) P 3 (48) P 3 (28) P 3 (8) P 4 (4) P 1 P 2 P 3 P 4 P 1 P 3 P 4 P 1 P 3 P 3 0 20 37 57 77 97 117 121 134 154 162
Typically, higher average turnaround than SJF, but better  response . Performance q  large    FCFS q  small     q  must be large with respect to context switch, otherwise overhead is too high. Round Robin Scheduling
Turnaround Time Varies With The Time Quantum TAT can be improved if most process finish their next CPU burst in a single time quantum.
Multilevel Queue Ready queue is partitioned into separate queues: EX: foreground (interactive) background (batch) Each queue has its own scheduling algorithm EX foreground – RR background – FCFS Scheduling must be done between the queues Fixed priority scheduling; (i.e., serve all from foreground then from background).  Possibility of starvation . Time slice – each queue gets a certain amount of CPU time which it can schedule amongst its processes; EX 80% to foreground in RR 20% to background in FCFS
Multilevel Queue Scheduling
Multi-level Feedback Queues Implement multiple ready queues Different queues may be scheduled using different algorithms Just like multilevel queue scheduling, but assignments are not static Jobs move from queue to queue based on  feedback Feedback = The behavior of the job,  EX  does it require the full quantum for computation, or  does it perform frequent I/O ? Need to select parameters for: Number of queues Scheduling algorithm within each queue When to upgrade and downgrade a job
Example of Multilevel Feedback Queue Three queues:   Q 0  –  RR with time quantum 8 milliseconds Q 1  –  RR time quantum 16 milliseconds Q 2  –  FCFS Scheduling A new job enters queue  Q 0   which is served   FCFS. When it gains CPU, job receives 8 milliseconds (RR).  If it does not finish in 8 milliseconds, job is moved to queue  Q 1 . At  Q 1  job is again served FCFS and receives 16 additional milliseconds (RR).  If it still does not complete, it is preempted and moved to queue  Q 2 . AT  Q 2  job is served FCFS
Multilevel Feedback Queues
Multiple-Processor Scheduling CPU scheduling more  complex  when multiple CPUs are available Different rules for  homogeneous  or  heterogeneous  processors. Load sharing  in the distribution of work, such that all processors have an equal amount to do. Asymmetric multiprocessing  – only one processor accesses the system data structures, alleviating the need for data sharing Symmetric multiprocessing (SMP)  – each processor is self-scheduling Each processor can schedule from a common ready queue OR each one can use a separate ready queue.
Thread Scheduling On operating system that support threads the kernel-threads  (not processes)  that are being scheduled by the operating system. Local Scheduling (process-contention-scope PCS )– How the threads library decides which thread to put onto an available LWP PTHREAD_SCOPE_PROCESS Global Scheduling (system-contention-scope SCS )– How the kernel decides which kernel thread to run next PTHREAD_SCOPE_PROCESS
End  Submitted to : Sir. M. Laureta Submitted by: Lazaro, Orven

More Related Content

PPTX
Process management
Birju Tank
 
PPTX
Os unit 3 , process management
Arnav Chowdhury
 
PPTX
How to prepare a portable bootable devices
iankeithsomoza
 
PPTX
Semantic Web
Adarsh Kumar Yadav
 
PPTX
Presentation skills
Kumar Ferrari
 
PPTX
Operating system and its functions
Namarta Chawla
 
PPTX
operating system
KadianAman
 
PPTX
SCHEDULING ALGORITHMS
Dhaval Sakhiya
 
Process management
Birju Tank
 
Os unit 3 , process management
Arnav Chowdhury
 
How to prepare a portable bootable devices
iankeithsomoza
 
Semantic Web
Adarsh Kumar Yadav
 
Presentation skills
Kumar Ferrari
 
Operating system and its functions
Namarta Chawla
 
operating system
KadianAman
 
SCHEDULING ALGORITHMS
Dhaval Sakhiya
 

What's hot (20)

PDF
Operating System.pdf
Syed Zaid Irshad
 
PPTX
Process management os concept
priyadeosarkar91
 
PDF
OS - Process Concepts
Mukesh Chinta
 
PPT
Client Centric Consistency Model
Rajat Kumar
 
PPTX
Operating system 11 system calls
Vaibhav Khanna
 
PPTX
Real time Scheduling in Operating System for Msc CS
Thanveen
 
PPT
Scheduling algorithms
Chankey Pathak
 
PPTX
Parallel processing
Praveen Kumar
 
PPTX
Cpu scheduling in operating System.
Ravi Kumar Patel
 
PDF
Inter Process Communication
Anil Kumar Pugalia
 
PPTX
Linux process management
Raghu nath
 
PPTX
Concurrency Control in Distributed Systems.pptx
MArshad35
 
PPT
Chapter 1: Introduction to Operating System
Shafaan Khaliq Bhatti
 
PPTX
cpu scheduling
hashim102
 
PDF
Memory management
Rajni Sirohi
 
PPT
Introduction to System Calls
Vandana Salve
 
PPT
advanced computer architesture-conditions of parallelism
Pankaj Kumar Jain
 
PPT
Advanced Operating System- Introduction
Debasis Das
 
PPTX
Operating System Unit 1
SanthiNivas
 
PPTX
Operating Systems: Process Scheduling
Damian T. Gordon
 
Operating System.pdf
Syed Zaid Irshad
 
Process management os concept
priyadeosarkar91
 
OS - Process Concepts
Mukesh Chinta
 
Client Centric Consistency Model
Rajat Kumar
 
Operating system 11 system calls
Vaibhav Khanna
 
Real time Scheduling in Operating System for Msc CS
Thanveen
 
Scheduling algorithms
Chankey Pathak
 
Parallel processing
Praveen Kumar
 
Cpu scheduling in operating System.
Ravi Kumar Patel
 
Inter Process Communication
Anil Kumar Pugalia
 
Linux process management
Raghu nath
 
Concurrency Control in Distributed Systems.pptx
MArshad35
 
Chapter 1: Introduction to Operating System
Shafaan Khaliq Bhatti
 
cpu scheduling
hashim102
 
Memory management
Rajni Sirohi
 
Introduction to System Calls
Vandana Salve
 
advanced computer architesture-conditions of parallelism
Pankaj Kumar Jain
 
Advanced Operating System- Introduction
Debasis Das
 
Operating System Unit 1
SanthiNivas
 
Operating Systems: Process Scheduling
Damian T. Gordon
 
Ad

Similar to Process management in os (20)

PPT
Operating System 5
tech2click
 
PPT
OSCh6
Joe Christensen
 
PPT
Ch6
C.U
 
PPT
cpu sechduling
gopi7
 
PPT
Os..
pri534
 
PPT
Csc4320 chapter 5 2
pri534
 
PPT
Process Scheduling in Ope Spptystems rating
Aryan904173
 
PPT
ch6- CPU scheduling https://www.slideshare.net/slideshow/operating-system-18-...
ssuserc35fa4
 
PDF
CH06.pdf
ImranKhan880955
 
PPT
Operating System Scheduling
Vishnu Prasad
 
PPT
Cpu scheduling(suresh)
Nagarajan
 
PDF
Process Scheduling Algorithms.pdf
Rakibul Rakib
 
PPTX
Preemptive process example.pptx
jamilaltiti1
 
PPTX
Operating systems - Processes Scheduling
Dr. Chandrakant Divate
 
PPT
Scheduling algorithm (chammu)
Nagarajan
 
PPTX
Scheduling algo(by HJ)
Harshit Jain
 
PPT
CPU SCHEDULING IN OPERATING SYSTEMS IN DETAILED
VADAPALLYPRAVEENKUMA1
 
Operating System 5
tech2click
 
Ch6
C.U
 
cpu sechduling
gopi7
 
Os..
pri534
 
Csc4320 chapter 5 2
pri534
 
Process Scheduling in Ope Spptystems rating
Aryan904173
 
ch6- CPU scheduling https://www.slideshare.net/slideshow/operating-system-18-...
ssuserc35fa4
 
CH06.pdf
ImranKhan880955
 
Operating System Scheduling
Vishnu Prasad
 
Cpu scheduling(suresh)
Nagarajan
 
Process Scheduling Algorithms.pdf
Rakibul Rakib
 
Preemptive process example.pptx
jamilaltiti1
 
Operating systems - Processes Scheduling
Dr. Chandrakant Divate
 
Scheduling algorithm (chammu)
Nagarajan
 
Scheduling algo(by HJ)
Harshit Jain
 
CPU SCHEDULING IN OPERATING SYSTEMS IN DETAILED
VADAPALLYPRAVEENKUMA1
 
Ad

Recently uploaded (20)

PPTX
An introduction to Prepositions for beginners.pptx
drsiddhantnagine
 
PPTX
Introduction to pediatric nursing in 5th Sem..pptx
AneetaSharma15
 
PDF
Module 2: Public Health History [Tutorial Slides]
JonathanHallett4
 
PPTX
Five Point Someone – Chetan Bhagat | Book Summary & Analysis by Bhupesh Kushwaha
Bhupesh Kushwaha
 
PPTX
Artificial Intelligence in Gastroentrology: Advancements and Future Presprec...
AyanHossain
 
PPTX
How to Apply for a Job From Odoo 18 Website
Celine George
 
PDF
What is CFA?? Complete Guide to the Chartered Financial Analyst Program
sp4989653
 
PPTX
Basics and rules of probability with real-life uses
ravatkaran694
 
DOCX
Modul Ajar Deep Learning Bahasa Inggris Kelas 11 Terbaru 2025
wahyurestu63
 
PPTX
Artificial-Intelligence-in-Drug-Discovery by R D Jawarkar.pptx
Rahul Jawarkar
 
DOCX
SAROCES Action-Plan FOR ARAL PROGRAM IN DEPED
Levenmartlacuna1
 
PDF
Review of Related Literature & Studies.pdf
Thelma Villaflores
 
PDF
Biological Classification Class 11th NCERT CBSE NEET.pdf
NehaRohtagi1
 
PDF
Virat Kohli- the Pride of Indian cricket
kushpar147
 
DOCX
Unit 5: Speech-language and swallowing disorders
JELLA VISHNU DURGA PRASAD
 
PPTX
Sonnet 130_ My Mistress’ Eyes Are Nothing Like the Sun By William Shakespear...
DhatriParmar
 
PPTX
A Smarter Way to Think About Choosing a College
Cyndy McDonald
 
PPTX
Care of patients with elImination deviation.pptx
AneetaSharma15
 
PPTX
family health care settings home visit - unit 6 - chn 1 - gnm 1st year.pptx
Priyanshu Anand
 
PPTX
An introduction to Dialogue writing.pptx
drsiddhantnagine
 
An introduction to Prepositions for beginners.pptx
drsiddhantnagine
 
Introduction to pediatric nursing in 5th Sem..pptx
AneetaSharma15
 
Module 2: Public Health History [Tutorial Slides]
JonathanHallett4
 
Five Point Someone – Chetan Bhagat | Book Summary & Analysis by Bhupesh Kushwaha
Bhupesh Kushwaha
 
Artificial Intelligence in Gastroentrology: Advancements and Future Presprec...
AyanHossain
 
How to Apply for a Job From Odoo 18 Website
Celine George
 
What is CFA?? Complete Guide to the Chartered Financial Analyst Program
sp4989653
 
Basics and rules of probability with real-life uses
ravatkaran694
 
Modul Ajar Deep Learning Bahasa Inggris Kelas 11 Terbaru 2025
wahyurestu63
 
Artificial-Intelligence-in-Drug-Discovery by R D Jawarkar.pptx
Rahul Jawarkar
 
SAROCES Action-Plan FOR ARAL PROGRAM IN DEPED
Levenmartlacuna1
 
Review of Related Literature & Studies.pdf
Thelma Villaflores
 
Biological Classification Class 11th NCERT CBSE NEET.pdf
NehaRohtagi1
 
Virat Kohli- the Pride of Indian cricket
kushpar147
 
Unit 5: Speech-language and swallowing disorders
JELLA VISHNU DURGA PRASAD
 
Sonnet 130_ My Mistress’ Eyes Are Nothing Like the Sun By William Shakespear...
DhatriParmar
 
A Smarter Way to Think About Choosing a College
Cyndy McDonald
 
Care of patients with elImination deviation.pptx
AneetaSharma15
 
family health care settings home visit - unit 6 - chn 1 - gnm 1st year.pptx
Priyanshu Anand
 
An introduction to Dialogue writing.pptx
drsiddhantnagine
 

Process management in os

  • 1. Process Management
  • 2. Process management is an integral part of any modern day operating system. The OS must allocate resources to processes, enable processes to share and exchange information, protect the resources of each process from other processes and enable synchronization among processes.
  • 3. To meet these requirements, the OS must maintain a data structure for each process, which describes the state and resource ownership of that process and which enables the OS to exert control over each process.
  • 4. A process goes through a series of discrete process states. Various events can cause a process to change states. Submit state Hold state Ready state Running state Wait state Complete state
  • 5. Process scheduling is one of the most important functions of an operating system that supports multiprogramming. This function is heavily dependent on  queues . There are three types of queues that are used in process scheduling:
  • 6. Job Queue  - Contains all processes that have been introduced into the system Ready Queue  - Contains processes that are waiting for CPU time, and can be selected to run at any time Device Queue  - Contains processes waiting on a certain device. Each device has its own queue for processes that need input/output from it.
  • 7. Different algorithms used for handling processes 1. Deterministic Scheduling An algorithm wherein all characteristics of a process are known in advance or before execution. 2. Non- Deterministic Scheduling An algorithm wherein characteristics of processes are not known in advance.
  • 8. Types of Queue being used 1. Single Queuing - All process arrives at the same time with their corresponding burst time. 2.Multiple Queuing – Each process has its own arrival time in the processor.
  • 9. CPU Scheduling Basic Concepts Scheduling Criteria Scheduling Algorithms Multiple-Processor Scheduling Thread Scheduling
  • 10. Basic Concepts Maximum CPU utilization obtained with multiprogramming CPU–I/O Burst Cycle – Process execution consists of a cycle of CPU execution and I/O wait CPU times are generally much shorter than I/O times.
  • 11. CPU-I/O Burst Cycle Process A Process B
  • 13. Schedulers Process migrates among several queues Device queue, job queue, ready queue Scheduler selects a process to run from these queues Long-term scheduler: load a job in memory Runs infrequently Short-term scheduler: Select ready process to run on CPU Should be fast Middle-term scheduler Reduce multiprogramming or memory consumption
  • 14. CPU Scheduler CPU scheduling decisions may take place when a process: 1. Switches from running to waiting state (by sleep). 2. Switches from running to ready state (by yield). 3. Switches from waiting to ready (by an interrupt). Terminates (by exit). Scheduling under 1 and 4 is nonpreemptive . All other scheduling is preemptive .
  • 15. Dispatcher Dispatcher module gives control of the CPU to the process selected by the short-term scheduler; this involves: switching context switching to user mode jumping to the proper location in the user program to restart that program Dispatch latency – time it takes for the dispatcher to stop one process and start another running
  • 16. Scheduling Criteria CPU utilization – keep the CPU as busy as possible Throughput – # of processes that complete their execution per time unit Turnaround time ( TAT ) – amount of time to execute a particular process Waiting time – amount of time a process has been waiting in the ready queue Response time – amount of time it takes from when a request was submitted until the first response is produced, not output (for time-sharing environment)
  • 17. “ The perfect CPU scheduler” Minimize latency: response or job completion time Maximize throughput: Maximize jobs / time. Maximize utilization: keep I/O devices busy. Recurring theme with OS scheduling Fairness: everyone makes progress, no one starves
  • 19. Scheduling Algorithms FCFS First-come First-served (FCFS) (FIFO) Jobs are scheduled in order of arrival Non-preemptive Problem: Average waiting time depends on arrival order Troublesome for time-sharing systems Convoy effect short process behind long process Advantage: really simple!
  • 20. First Come First Served Scheduling Example: Process Burst Time P 1 24 P 2 3 P 3 3 Suppose that the processes arrive in the order: P 1 , P 2 , P 3 Suppose that the processes arrive in the order: P 2 , P 3 , P 1 . Waiting time for P 1 = 0; P 2 = 24; P 3 = 27 Average waiting time: (0 + 24 + 27)/3 = 17 Waiting time for P 1 = 6 ; P 2 = 0 ; P 3 = 3 Average waiting time: (6 + 0 + 3)/3 = 3 P 1 P 3 P 2 6 3 30 0 P 1 P 2 P 3 24 27 30 0
  • 21. Shortest-Job-First (SJR) Scheduling Associate with each process the length of its next CPU burst. Use these lengths to schedule the process with the shortest time Two schemes: nonpreemptive – once CPU given to the process it cannot be preempted until completes its CPU burst preemptive – if a new process arrives with CPU burst length less than remaining time of current executing process, preempt. This scheme is know as the Shortest-Remaining-Time-First (SRTF) SJF is optimal – gives minimum average waiting time for a given set of processes
  • 22. Shortest Job First Scheduling Example: Process Arrival Time Burst Time P 1 0 7 P 2 2 4 P 3 4 1 P 4 5 4 Non preemptive SJF P 1 P 3 P 2 7 P 1 (7) 16 0 P 4 8 12 Average waiting time = (0 + 6 + 3 + 7)/4 = 4 2 4 5 P 2 (4) P 3 (1) P 4 (4) P 1 ‘s wating time = 0 P 2 ‘s wating time = 6 P 3 ‘s wating time = 3 P 4 ‘s wating time = 7
  • 23. Shortest Job First Scheduling Cont’d Example: Process Arrival Time Burst Time P 1 0 7 P 2 2 4 P 3 4 1 P 4 5 4 Preemptive SJF Average waiting time = (9 + 1 + 0 +2)/4 = 3 P 1 (7) P 2 (4) P 3 (1) P 4 (4) P 1 ‘s wating time = 9 P 2 ‘s wating time = 1 P 3 ‘s wating time = 0 P 4 ‘s wating time = 2 P 1 (5) P 2 (2) P 1 P 3 P 2 4 2 11 0 P 4 5 7 P 2 P 1 16
  • 24. Shortest Job First Scheduling Cont’d Optimal scheduling However, there are no accurate estimations to know the length of the next CPU burst
  • 25. Optimal for minimizing queueing time, but impossible to implement. Tries to predict the process to schedule based on previous history. Predicting the time the process will use on its next schedule: t( n+1 ) = w * t( n ) + ( 1 - w ) * T( n ) Here: t(n+1) is time of next burst. t(n) is time of current burst. T(n) is average of all previous bursts . W is a weighting factor emphasizing current or previous bursts. Shortest Job First Scheduling Cont’d
  • 26. A priority number (integer) is associated with each process The CPU is allocated to the process with the highest priority (smallest integer  highest priority in Unix but lowest in Java). Preemptive Non-preemptive SJF is a priority scheduling where priority is the predicted next CPU burst time. Problem  Starvation – low priority processes may never execute. Solution  Aging – as time progresses increase the priority of the process. Priority Scheduling
  • 27. Round Robin (RR) Each process gets a small unit of CPU time ( time quantum ), usually 10-100 milliseconds . After this time has elapsed, the process is preempted and added to the end of the ready queue. If there are n processes in the ready queue and the time quantum is q , then each process gets 1/ n of the CPU time in chunks of at most q time units at once. No process waits more than ( n -1) q time units.
  • 28. time quantum = 20 Process Burst Time Wait Time P 1 53 57 +24 = 81 P 2 17 20 P 3 68 37 + 40 + 17= 94 P 4 24 57 + 40 = 97 Round Robin Scheduling Average wait time = (81+20+94+97)/4 = 73 57 20 37 57 24 40 40 17 P 1 (53) P 2 (17) P 3 (68) P 4 (24) P 1 (33) P 1 (13) P 3 (48) P 3 (28) P 3 (8) P 4 (4) P 1 P 2 P 3 P 4 P 1 P 3 P 4 P 1 P 3 P 3 0 20 37 57 77 97 117 121 134 154 162
  • 29. Typically, higher average turnaround than SJF, but better response . Performance q large  FCFS q small  q must be large with respect to context switch, otherwise overhead is too high. Round Robin Scheduling
  • 30. Turnaround Time Varies With The Time Quantum TAT can be improved if most process finish their next CPU burst in a single time quantum.
  • 31. Multilevel Queue Ready queue is partitioned into separate queues: EX: foreground (interactive) background (batch) Each queue has its own scheduling algorithm EX foreground – RR background – FCFS Scheduling must be done between the queues Fixed priority scheduling; (i.e., serve all from foreground then from background). Possibility of starvation . Time slice – each queue gets a certain amount of CPU time which it can schedule amongst its processes; EX 80% to foreground in RR 20% to background in FCFS
  • 33. Multi-level Feedback Queues Implement multiple ready queues Different queues may be scheduled using different algorithms Just like multilevel queue scheduling, but assignments are not static Jobs move from queue to queue based on feedback Feedback = The behavior of the job, EX does it require the full quantum for computation, or does it perform frequent I/O ? Need to select parameters for: Number of queues Scheduling algorithm within each queue When to upgrade and downgrade a job
  • 34. Example of Multilevel Feedback Queue Three queues: Q 0 – RR with time quantum 8 milliseconds Q 1 – RR time quantum 16 milliseconds Q 2 – FCFS Scheduling A new job enters queue Q 0 which is served FCFS. When it gains CPU, job receives 8 milliseconds (RR). If it does not finish in 8 milliseconds, job is moved to queue Q 1 . At Q 1 job is again served FCFS and receives 16 additional milliseconds (RR). If it still does not complete, it is preempted and moved to queue Q 2 . AT Q 2 job is served FCFS
  • 36. Multiple-Processor Scheduling CPU scheduling more complex when multiple CPUs are available Different rules for homogeneous or heterogeneous processors. Load sharing in the distribution of work, such that all processors have an equal amount to do. Asymmetric multiprocessing – only one processor accesses the system data structures, alleviating the need for data sharing Symmetric multiprocessing (SMP) – each processor is self-scheduling Each processor can schedule from a common ready queue OR each one can use a separate ready queue.
  • 37. Thread Scheduling On operating system that support threads the kernel-threads (not processes) that are being scheduled by the operating system. Local Scheduling (process-contention-scope PCS )– How the threads library decides which thread to put onto an available LWP PTHREAD_SCOPE_PROCESS Global Scheduling (system-contention-scope SCS )– How the kernel decides which kernel thread to run next PTHREAD_SCOPE_PROCESS
  • 38. End Submitted to : Sir. M. Laureta Submitted by: Lazaro, Orven