KEMBAR78
CPU Scheduling Algorithms | PPTX
CPU SCHEDULING
ALGORITHMS
Introduction
Scheduling management
Scheduling decisions
Scheduling Criteria
CPU scheduling algorithms
• First-Come, First-Served (FCFS) Scheduling
• Shortest Job First (Sjf) Scheduling
• Priority Scheduling
OVERVIEW
 Processes are managed through the use of multiple queues of PCB's.
 The job queue contains all jobs submitted to the system, but not yet in main
memory.
 The ready queue contains all jobs in main memory ready to execute.
 Each I/O device has a queue of jobs waiting for various I/O operations.
 All of these events are signaled by interrupts
SCHEDULING MANAGEMENT
 CPU scheduling decisions may take place when a process:
• Switches from running to waiting state.
• Switches from running to ready state.
• Switches from waiting to ready state.
• Terminates.
SCHEDULING DECISIONS
Each scheduling algorithm favors particular criteria:
 CPU utilization
 Throughput
 Turnaround time
 Waiting time
 Response time
SCHEDULING CRITERIA
SCHEDULING ALGORITHMS
First-Come, First-Served (FCFS) Scheduling
• Jobs are executed on first come, first serve basis.
• Easy to understand and implement.
• Poor in performance as average wait time is high.
INTRODUCTION
• Suppose that the processes arrive in the order: P1 , P2 , P3
EXAMPLE
Process Burst Time
P1 24
P2 3
P3 3
SCHEDULING ALGORITHMS
Shortest Job First (Sjf) Scheduling
 Best approach to minimize waiting time.
 Impossible to implement.
 Processer should know in advance how much time process will take.
INTRODUCTION
 Non preemptive:
• 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
TWO SCHEMES:
 Non preemptive:
• 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
EXAMPLE
EXAMPLE
Process Arrival Time Burst Time
P1 0.0 7
P2 2.0 4
P3 4.0 1
P4 5.0 4
SCHEDULING ALGORITHMS
Priority Scheduling
 Each process is assigned a priority.
 Process with highest priority is to be executed first and so on.
 Processes with same priority are executed on first come first serve basis.
 Priority can be decided based on following:
• memory requirement
• time requirements
• any other resource requirement.
INTRODUCTION
A priority number (integer) is associated with each process.
The CPU is allocated to the process with the highest priority (smallest
integer ≡ highest priority).
• Preemptive
• Nonpreemptive
INTRODUCTION
EXAMPLE
CPU Scheduling Algorithms
CPU Scheduling Algorithms

CPU Scheduling Algorithms

  • 2.
  • 3.
    Introduction Scheduling management Scheduling decisions SchedulingCriteria CPU scheduling algorithms • First-Come, First-Served (FCFS) Scheduling • Shortest Job First (Sjf) Scheduling • Priority Scheduling OVERVIEW
  • 4.
     Processes aremanaged through the use of multiple queues of PCB's.  The job queue contains all jobs submitted to the system, but not yet in main memory.  The ready queue contains all jobs in main memory ready to execute.  Each I/O device has a queue of jobs waiting for various I/O operations.  All of these events are signaled by interrupts SCHEDULING MANAGEMENT
  • 5.
     CPU schedulingdecisions may take place when a process: • Switches from running to waiting state. • Switches from running to ready state. • Switches from waiting to ready state. • Terminates. SCHEDULING DECISIONS
  • 6.
    Each scheduling algorithmfavors particular criteria:  CPU utilization  Throughput  Turnaround time  Waiting time  Response time SCHEDULING CRITERIA
  • 7.
  • 8.
    • Jobs areexecuted on first come, first serve basis. • Easy to understand and implement. • Poor in performance as average wait time is high. INTRODUCTION
  • 9.
    • Suppose thatthe processes arrive in the order: P1 , P2 , P3 EXAMPLE Process Burst Time P1 24 P2 3 P3 3
  • 10.
    SCHEDULING ALGORITHMS Shortest JobFirst (Sjf) Scheduling
  • 11.
     Best approachto minimize waiting time.  Impossible to implement.  Processer should know in advance how much time process will take. INTRODUCTION
  • 12.
     Non preemptive: •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 TWO SCHEMES:
  • 13.
     Non preemptive: •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 EXAMPLE
  • 14.
    EXAMPLE Process Arrival TimeBurst Time P1 0.0 7 P2 2.0 4 P3 4.0 1 P4 5.0 4
  • 15.
  • 16.
     Each processis assigned a priority.  Process with highest priority is to be executed first and so on.  Processes with same priority are executed on first come first serve basis.  Priority can be decided based on following: • memory requirement • time requirements • any other resource requirement. INTRODUCTION
  • 17.
    A priority number(integer) is associated with each process. The CPU is allocated to the process with the highest priority (smallest integer ≡ highest priority). • Preemptive • Nonpreemptive INTRODUCTION
  • 18.

Editor's Notes

  • #7 throughput: number of processes which complete execution per time unit (maximize) turnaround time: total amount of time to execute a particular process (minimize) waiting time: amount of time a process has been waiting in the ready queue (minimize) response time: amount of time it takes from when a request is submitted to when the response is produced (minimize); does not include the time for a response to be output
  • #9 throughput: number of processes which complete execution per time unit (maximize) turnaround time: total amount of time to execute a particular process (minimize) waiting time: amount of time a process has been waiting in the ready queue (minimize) response time: amount of time it takes from when a request is submitted to when the response is produced (minimize); does not include the time for a response to be output
  • #10 throughput: number of processes which complete execution per time unit (maximize) turnaround time: total amount of time to execute a particular process (minimize) waiting time: amount of time a process has been waiting in the ready queue (minimize) response time: amount of time it takes from when a request is submitted to when the response is produced (minimize); does not include the time for a response to be output
  • #15 throughput: number of processes which complete execution per time unit (maximize) turnaround time: total amount of time to execute a particular process (minimize) waiting time: amount of time a process has been waiting in the ready queue (minimize) response time: amount of time it takes from when a request is submitted to when the response is produced (minimize); does not include the time for a response to be output