Lecture 5: Process Scheduling Section 2'4 - PowerPoint PPT Presentation

1 / 16
About This Presentation
Title:

Lecture 5: Process Scheduling Section 2'4

Description:

Process goes to blocked/waiting state. Interrupt: back from I/O operation, ready to use the CPU. ... Preemptive: A Process can be suspended and resumed ... – PowerPoint PPT presentation

Number of Views:56
Avg rating:3.0/5.0
Slides: 17
Provided by: Ai51
Category:

less

Transcript and Presenter's Notes

Title: Lecture 5: Process Scheduling Section 2'4


1
Lecture 5 Process Scheduling(Section 2.4)
2
Schematic Scheduling
3
Process Life Cycle
4
CPU and I/O bursts
Long CPU burst
Waiting for I/O
Short CPU burst
Interrupt back from I/O operation, ready to use
the CPU.
CPU not needed. Process goes to blocked/waiting
state.
5
The Scheduler
  • A module in OS to execute scheduling decisions.
  • This is done by
  • switching context
  • switching to user mode
  • jumping to the proper location in the user
    program to restart that program

6
When is scheduling done?
  • Scheduling absolutely required when
  • A process exists
  • A process becomes blocked (on I/O, etc)
  • Scheduling may be required when
  • New process created
  • I/O interrupt
  • Clock interrupt

7
Terminology Preemptive vs. non-Preemptive
  • Preemptive A Process can be suspended and
    resumed
  • Non-preemptive A process runs until it
    voluntarily gives up the CPU (waiting on I/O or
    terminate).
  • Most modern OSs use preemptive CPU scheduling,
    implemented via timer interrupts.
  • Non-preemptive is used when suspending a process
    is impossible or very expensive e.g., cant
    replace a flight crew in middle of flight.

8
Scheduling Performance Metrics
  • All systems
  • Fairness
  • Policy enforcement
  • Balance
  • Batch Systems
  • Throughput
  • Turnaround time
  • CPU utilization
  • Interactive Systems
  • Response time
  • Proportionality
  • Real-time Systems
  • Meeting deadlines
  • Predictability

Waiting time turnaround time minus solo
execution time
9
Scheduling Policies
  • Batch systems
  • First Come First Served
  • Shorted Job First
  • Shortest Remaining Time Next
  • Interactive systems
  • Round Robin
  • Priority Scheduling
  • Multiple Queues
  • Shortest Process Next
  • Guaranteed Scheduling
  • Lottery Scheduling
  • Fair-share Scheduling
  • Real-time systems
  • Static vs. dynamic

10
Example FCFS Scheduling
  • First Come, First Served.
  • Assume non-preemptive version
  • Example Jobs are P1 (duration 24 units) P2
    (3) and P3 (3), arriving in this order at time 0
  • Gantt Chart for FCFS schedule
  • Average waiting time (0 24 27)/3 17

11
FCFS Continued
  • What if execution order is P2 , P3 , P1 ?
  • Gantt chart
  • Average waiting time (6 0 3)/3 3
  • Much better!
  • Convoy effect many short jobs stuck behind one
    long job

12
Scheduling Policy SJF
  • Shortest Job First
  • Assume each job has a known execution time
  • Non-preemptive version Schedule the shortest job
    first
  • once CPU given to the process it cannot be
    preempted until completes its CPU burst.
  • Preemptive version Shortest Remaining Time Next
  • if a new process arrives with CPU burst length
    less than remaining time of current executing
    process, preempt.
  • Problem?

13
Preemptive Scheduling Round Robin
  • 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.
  • Then the process at head of queue is scheduled.

14
Round Robin Example
  • Process Burst Time
  • P1 53
  • P2 17
  • P3 68
  • P4 24
  • Gantt chart for time quantum 20
  • Typically, higher average turnaround than SJF,
    but better response.

15
Priority Scheduling
  • Idea Jobs are assigned priorities.Always, the
    job with the highest priority runs.
  • Note All scheduling policies are priority
    scheduling!
  • Question How to assign priorities?

priority 1
priority 2
priority M
16
Example for Priorities
Static priorities can lead to starvation!
Write a Comment
User Comments (0)
About PowerShow.com