SlideShare a Scribd company logo
2
Most read
4
Most read
7
Most read
CPU SCHEDULING SONALI CHAUHAN SYBSc IT  2008-09 UDIT
BASIC CONCEPTS Main objective of multiprogramming is to keep on running processes all the time for maximum CPU utilization. In uniprocess system only one process run at a time, others process have to wait for cpu time. Scheduling is fundamental function of OS.
CPU-I/O BURST CYCLE CPU–I/O Burst Cycle – Process execution  consists of a cycle of CPU execution and I/O  wait.
CONT…
CPU SCHEDULER Selects from among the processes in memory that  are ready to execute, and allocates the CPU to one of them CPU scheduling decisions may take place when a  process: 1. Switches from running to waiting state 2. Switches from running to ready state 3. Switches from waiting to ready 4. Terminates Scheduling under 1 and 4 is nonpreemptive All other scheduling is preemptive
Selects one process from ready queue to run on CPU Scheduling can be  Nonpreemptive Preemptive  CONT…
Nonpreemptive   Once a process is allocated the CPU, it does not leave unless:  it has to wait, e.g., for I/O request  or for a child to terminate  it terminates    Preemptive   OS can force (preempt) a process from CPU at anytime  Say, to allocate CPU to another higher-priority process   CONT…
DISPATCHER Scheduler : selects one process to run on  CPU   Dispatcher : allocates  CPU  to the selected process, which involves:  switching context  switching to user mode  jumping to the proper location (in the selected process) and restarting it Dispatcher should be fast enough. Dispatch latency  – time it takes for the dispatcher to stop one process and start another running.
How does scheduler select a process to run?
SCHEDULING CRITERIA CPU utilization  – keep the  CPU  as busy as possible  Maximize   Throughput   – No of processes that complete their execution per time unit  Maximize   Turnaround   time  – amount of time to execute a particular process (time from submission to termination) i.e (waiting in memory + waiting time in ready queue + executing time in CPU + doing IO) Minimize
Waiting   time  – amount of time a process has been waiting in the  ready queue  (sum of time waiting in ready queue) Minimize   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)  Minimize   CONT…
SCHEDULING ALGORITHM First Come, First Served  Shortest Job First  Priority  Round Robin
FIRST COME FIRST SERVED  SCHEDULING
Process   Burst Time P1 24   P2   3   P3   3   Suppose that the processes arrive in the order: P1  ,  P2  ,  P3  The Gantt Chart for the schedule is: Waiting time for  P1   = 0;  P2   = 24;  P3  = 27 Average waiting time:  (0 + 24 + 27)/3 = 17 CONT… First come, First served… P 1 P 2 P 3 24 27 30 0
Suppose that the processes arrive in the order :  P 2  ,  P 3  ,  P 1  ( P1: 24, P2: 3, P3: 3) The Gantt chart for the schedule is: Waiting time for  P 1  =  6 ;   P 2  = 0 ;  P 3  =  3 Average waiting time:  (6 + 0 + 3)/3 = 3 Much better than previous case Convoy effect  short process behind long process CONT… First come, First served… P 1 P 3 P 2 6 3 30 0
CONT… SHORTEST-JOB-FIRST 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 CONT… SHORTEST-JOB-FIRST
CONT… SHORTEST-JOB-FIRST… Process Arrival Time Burst Time P 1 0.0 7   P 2 2.0 4   P 3 4.0 1   P 4 5.0 4 SJF (non-preemptive) Average waiting time = (0 + 6 + 3 + 7)/4 - 4 Example of Non-Preemptive SJF P 1 P 3 P 2 7 3 16 0 P 4 8 12
Process Arrival Time Burst Time   P1    0.0 7   P2   2.0 4   P3   4.0 1   P4   5.0 4 SJF (preemptive) Average waiting time = (9 + 1 + 0 +2)/4 - 3 CONT… SHORTEST-JOB-FIRST… Example of Preemptive SJF P 1 P 3 P 2 4 2 11 0 P 4 5 7 P 2 P 1 16
PRIORITY SCHEDULING
A priority number (integer) is associated with each process Lager the CPU burst lower the priority The CPU is allocated to the process with the highest priority (smallest integer    highest priority) Preemptive nonpreemptive Problem     Starvation (Infinity blocking) – low priority processes may never execute Solution     Aging – as time progresses increase the priority of the process CONT… PRIORITY…
ROUND-ROBIN SCHEDULING
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. Performance q  large    FIFO q  small     q  must be large with respect to context switch, otherwise overhead is too high CONT… ROUND-ROBIN…
Process   Burst Time P1 24 P2 3 P3 3 Quantum time 4millisec The Gantt chart is:  Typically, higher average turnaround than SJF, but better  response CONT… ROUND-ROBIN… P 1 P 2 P 3 P 1 P 1 P 1 P 1 P 1 0 4 7 10 14 18 22 26 30

More Related Content

PPTX
Priority Scheduling
PPTX
Shortest Job First
PPT
Scheduling algorithms
PPTX
Memory Organization
PPT
microprocessor
PPTX
Cpu scheduling in operating System.
PDF
OS - Process Concepts
PPTX
Process scheduling
Priority Scheduling
Shortest Job First
Scheduling algorithms
Memory Organization
microprocessor
Cpu scheduling in operating System.
OS - Process Concepts
Process scheduling

What's hot (20)

PPTX
Computer architecture multi processor
PPTX
Introduction to parallel processing
PPTX
INTER PROCESS COMMUNICATION (IPC).pptx
PPT
chapter 5 CPU scheduling.ppt
PDF
QOS (Quality of Services) - Computer Networks
PPT
CPU Scheduling Algorithms
PPSX
CPU Scheduling algorithms
PPTX
System interconnect architecture
PPT
Parallel processing
PDF
Pthread
PPT
Part 1 - PROCESS CONCEPTS
PDF
Deadlock Avoidance - OS
PPT
Timing Analysis
PPT
Ipv4 ppt
PPT
Interrupt
PDF
Serial Communication Interfaces
PPT
Sa by shekhar
PPTX
FCFS scheduling OS
PPTX
cpu scheduling
PPTX
Input-Buffering
Computer architecture multi processor
Introduction to parallel processing
INTER PROCESS COMMUNICATION (IPC).pptx
chapter 5 CPU scheduling.ppt
QOS (Quality of Services) - Computer Networks
CPU Scheduling Algorithms
CPU Scheduling algorithms
System interconnect architecture
Parallel processing
Pthread
Part 1 - PROCESS CONCEPTS
Deadlock Avoidance - OS
Timing Analysis
Ipv4 ppt
Interrupt
Serial Communication Interfaces
Sa by shekhar
FCFS scheduling OS
cpu scheduling
Input-Buffering
Ad

Viewers also liked (9)

PPTX
Programming Key terms Flash Cards
PPTX
Cpu presentation
PPT
Cpu ppt cse
PPTX
Central Processing Unit
PPTX
GCSE Compuitng Hardware Key terms
PPT
Motherboard components and their functions
PPT
Motherboard
PPT
Chapter 4 Microprocessor CPU
PPTX
Motherboard and its components
Programming Key terms Flash Cards
Cpu presentation
Cpu ppt cse
Central Processing Unit
GCSE Compuitng Hardware Key terms
Motherboard components and their functions
Motherboard
Chapter 4 Microprocessor CPU
Motherboard and its components
Ad

Similar to Cpu Scheduling Galvin (20)

PPTX
CPU Scheduling
PPT
PPT
Process management in os
PPTX
CPU scheduling
PPT
Operating System 5
PPT
OS-operating systems- ch05 (CPU Scheduling) ...
PPTX
Week 5a.pptx of cpu scheduling operating system class
PPTX
Scheduling algo(by HJ)
PPTX
CPU Scheduling
PPT
Operating System Scheduling
PPT
Ch6
 
PPTX
2_CPU Scheduling (2)beautifulgameyt.pptx
PDF
Fcfs and sjf
PPT
Process Scheduling in Ope Spptystems rating
PPT
ch6- CPU scheduling https://www.slideshare.net/slideshow/operating-system-18-...
PPT
Scheduling algorithm (chammu)
PPTX
operating system scheduling concept lec2
CPU Scheduling
Process management in os
CPU scheduling
Operating System 5
OS-operating systems- ch05 (CPU Scheduling) ...
Week 5a.pptx of cpu scheduling operating system class
Scheduling algo(by HJ)
CPU Scheduling
Operating System Scheduling
Ch6
 
2_CPU Scheduling (2)beautifulgameyt.pptx
Fcfs and sjf
Process Scheduling in Ope Spptystems rating
ch6- CPU scheduling https://www.slideshare.net/slideshow/operating-system-18-...
Scheduling algorithm (chammu)
operating system scheduling concept lec2

More from Sonali Chauhan (20)

PDF
Chapter 2 enterprise an overview - alexis leon
PDF
Chapter 10 Future Directions In ERP
PDF
Chapter 5 E R P Modules Alexis Leon
PDF
Chapter 7 E R P Implementation Lifecycle Alexis Leon
PDF
Chapter 10 Future Directions In Erp A Lexis Leon
PDF
Chapter 9 Vendors Consultants Users Alexis Leon
PDF
Chapter 3 E R P And Related Tech Alexis Leon
PDF
Chapter 1 enterprise resource planning alexis leon
PDF
Os Question Bank
PPS
Chapter 2 Enterprise An Overview Alexis Leon
PPT
Chapter 1 Enterprise Resource Planning Alexis Leon
PPS
Chapter 7 Erp Implementation Lifecycle Alexis Leon
PPT
Mobile Communication Broadcast System Jochen Schiller
PPT
3.Medium Access Control
PPT
Process Synchronization
PPT
PPT
Operating System Deadlock Galvin
PPT
Erp Alex Leon Chapter 10
PPT
Erp Alex Leon Chapter 5
Chapter 2 enterprise an overview - alexis leon
Chapter 10 Future Directions In ERP
Chapter 5 E R P Modules Alexis Leon
Chapter 7 E R P Implementation Lifecycle Alexis Leon
Chapter 10 Future Directions In Erp A Lexis Leon
Chapter 9 Vendors Consultants Users Alexis Leon
Chapter 3 E R P And Related Tech Alexis Leon
Chapter 1 enterprise resource planning alexis leon
Os Question Bank
Chapter 2 Enterprise An Overview Alexis Leon
Chapter 1 Enterprise Resource Planning Alexis Leon
Chapter 7 Erp Implementation Lifecycle Alexis Leon
Mobile Communication Broadcast System Jochen Schiller
3.Medium Access Control
Process Synchronization
Operating System Deadlock Galvin
Erp Alex Leon Chapter 10
Erp Alex Leon Chapter 5

Recently uploaded (20)

PDF
The Lost Whites of Pakistan by Jahanzaib Mughal.pdf
PDF
Basic Mud Logging Guide for educational purpose
PDF
Microbial disease of the cardiovascular and lymphatic systems
PPTX
PPH.pptx obstetrics and gynecology in nursing
PPTX
human mycosis Human fungal infections are called human mycosis..pptx
PPTX
Pharmacology of Heart Failure /Pharmacotherapy of CHF
PDF
Sports Quiz easy sports quiz sports quiz
PPTX
GDM (1) (1).pptx small presentation for students
PPTX
Institutional Correction lecture only . . .
PDF
O7-L3 Supply Chain Operations - ICLT Program
PDF
Classroom Observation Tools for Teachers
PPTX
Renaissance Architecture: A Journey from Faith to Humanism
PDF
01-Introduction-to-Information-Management.pdf
PDF
O5-L3 Freight Transport Ops (International) V1.pdf
PDF
Black Hat USA 2025 - Micro ICS Summit - ICS/OT Threat Landscape
PPTX
Microbial diseases, their pathogenesis and prophylaxis
PPTX
Introduction_to_Human_Anatomy_and_Physiology_for_B.Pharm.pptx
PDF
TR - Agricultural Crops Production NC III.pdf
PPTX
IMMUNITY IMMUNITY refers to protection against infection, and the immune syst...
PPTX
Cell Structure & Organelles in detailed.
The Lost Whites of Pakistan by Jahanzaib Mughal.pdf
Basic Mud Logging Guide for educational purpose
Microbial disease of the cardiovascular and lymphatic systems
PPH.pptx obstetrics and gynecology in nursing
human mycosis Human fungal infections are called human mycosis..pptx
Pharmacology of Heart Failure /Pharmacotherapy of CHF
Sports Quiz easy sports quiz sports quiz
GDM (1) (1).pptx small presentation for students
Institutional Correction lecture only . . .
O7-L3 Supply Chain Operations - ICLT Program
Classroom Observation Tools for Teachers
Renaissance Architecture: A Journey from Faith to Humanism
01-Introduction-to-Information-Management.pdf
O5-L3 Freight Transport Ops (International) V1.pdf
Black Hat USA 2025 - Micro ICS Summit - ICS/OT Threat Landscape
Microbial diseases, their pathogenesis and prophylaxis
Introduction_to_Human_Anatomy_and_Physiology_for_B.Pharm.pptx
TR - Agricultural Crops Production NC III.pdf
IMMUNITY IMMUNITY refers to protection against infection, and the immune syst...
Cell Structure & Organelles in detailed.

Cpu Scheduling Galvin

  • 1. CPU SCHEDULING SONALI CHAUHAN SYBSc IT 2008-09 UDIT
  • 2. BASIC CONCEPTS Main objective of multiprogramming is to keep on running processes all the time for maximum CPU utilization. In uniprocess system only one process run at a time, others process have to wait for cpu time. Scheduling is fundamental function of OS.
  • 3. CPU-I/O BURST CYCLE CPU–I/O Burst Cycle – Process execution consists of a cycle of CPU execution and I/O wait.
  • 5. CPU SCHEDULER Selects from among the processes in memory that are ready to execute, and allocates the CPU to one of them CPU scheduling decisions may take place when a process: 1. Switches from running to waiting state 2. Switches from running to ready state 3. Switches from waiting to ready 4. Terminates Scheduling under 1 and 4 is nonpreemptive All other scheduling is preemptive
  • 6. Selects one process from ready queue to run on CPU Scheduling can be Nonpreemptive Preemptive CONT…
  • 7. Nonpreemptive Once a process is allocated the CPU, it does not leave unless: it has to wait, e.g., for I/O request  or for a child to terminate it terminates   Preemptive OS can force (preempt) a process from CPU at anytime Say, to allocate CPU to another higher-priority process  CONT…
  • 8. DISPATCHER Scheduler : selects one process to run on CPU Dispatcher : allocates CPU to the selected process, which involves: switching context switching to user mode jumping to the proper location (in the selected process) and restarting it Dispatcher should be fast enough. Dispatch latency – time it takes for the dispatcher to stop one process and start another running.
  • 9. How does scheduler select a process to run?
  • 10. SCHEDULING CRITERIA CPU utilization – keep the CPU as busy as possible Maximize Throughput – No of processes that complete their execution per time unit Maximize Turnaround time – amount of time to execute a particular process (time from submission to termination) i.e (waiting in memory + waiting time in ready queue + executing time in CPU + doing IO) Minimize
  • 11. Waiting time – amount of time a process has been waiting in the ready queue (sum of time waiting in ready queue) Minimize 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) Minimize CONT…
  • 12. SCHEDULING ALGORITHM First Come, First Served Shortest Job First Priority Round Robin
  • 13. FIRST COME FIRST SERVED SCHEDULING
  • 14. Process Burst Time P1 24 P2 3 P3 3 Suppose that the processes arrive in the order: P1 , P2 , P3 The Gantt Chart for the schedule is: Waiting time for P1 = 0; P2 = 24; P3 = 27 Average waiting time: (0 + 24 + 27)/3 = 17 CONT… First come, First served… P 1 P 2 P 3 24 27 30 0
  • 15. Suppose that the processes arrive in the order : P 2 , P 3 , P 1 ( P1: 24, P2: 3, P3: 3) The Gantt chart for the schedule is: Waiting time for P 1 = 6 ; P 2 = 0 ; P 3 = 3 Average waiting time: (6 + 0 + 3)/3 = 3 Much better than previous case Convoy effect short process behind long process CONT… First come, First served… P 1 P 3 P 2 6 3 30 0
  • 17. 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 CONT… SHORTEST-JOB-FIRST
  • 18. CONT… SHORTEST-JOB-FIRST… Process Arrival Time Burst Time P 1 0.0 7 P 2 2.0 4 P 3 4.0 1 P 4 5.0 4 SJF (non-preemptive) Average waiting time = (0 + 6 + 3 + 7)/4 - 4 Example of Non-Preemptive SJF P 1 P 3 P 2 7 3 16 0 P 4 8 12
  • 19. Process Arrival Time Burst Time P1 0.0 7 P2 2.0 4 P3 4.0 1 P4 5.0 4 SJF (preemptive) Average waiting time = (9 + 1 + 0 +2)/4 - 3 CONT… SHORTEST-JOB-FIRST… Example of Preemptive SJF P 1 P 3 P 2 4 2 11 0 P 4 5 7 P 2 P 1 16
  • 21. A priority number (integer) is associated with each process Lager the CPU burst lower the priority The CPU is allocated to the process with the highest priority (smallest integer  highest priority) Preemptive nonpreemptive Problem  Starvation (Infinity blocking) – low priority processes may never execute Solution  Aging – as time progresses increase the priority of the process CONT… PRIORITY…
  • 23. 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. Performance q large  FIFO q small  q must be large with respect to context switch, otherwise overhead is too high CONT… ROUND-ROBIN…
  • 24. Process Burst Time P1 24 P2 3 P3 3 Quantum time 4millisec The Gantt chart is: Typically, higher average turnaround than SJF, but better response CONT… ROUND-ROBIN… P 1 P 2 P 3 P 1 P 1 P 1 P 1 P 1 0 4 7 10 14 18 22 26 30