Scheduling - PowerPoint PPT Presentation

1 / 14
About This Presentation
Title:

Scheduling

Description:

Scheduling Algorithms. Batch off-line, jobs come with resource estimates ... Can use non-preemptive algorithms since this reduces process switching ... – PowerPoint PPT presentation

Number of Views:33
Avg rating:3.0/5.0
Slides: 15
Provided by: quynh6
Category:

less

Transcript and Presenter's Notes

Title: Scheduling


1
Scheduling
  • Scheduling is policy context switch is mechanism
  • Scheduling of multiple processes on single CPU
    machine
  • Can also be applied to multi-CPU system
  • Can also be applied to scheduling threads
  • What does scheduler need to consider?
  • Type of process
  • Compute-bound spends most of time computing
  • I/O bound spends most of time reading I/O
  • What process is waiting on what other processes?
  • What processes are blocking and why?

2
Scheduling Criteria
  • Meets policy goal
  • Real-time
  • Low response time (low turn around time average
    time it takes for job to be completed after
    submission)
  • High throughput number of jobs completed per
    hour
  • Fair share equal time
  • Gang parallel processes (1-to-1 mapping of
    process to CPU)
  • Low overhead keep CPU doing useful work as
    opposed to context switching
  • Freedom from starvation
  • Stability at highest loads

3
Scheduling Algorithms
  • Batch off-line, jobs come with resource
    estimates
  • Goal high throughput, low turnaround time, high
    CPU utilization
  • Timeshare (interactive in Tannenbaum book)
  • Goal low response time, meet users expectation
  • Real-time
  • Goal avoid losing data, avoid quality
    degradation
  • Gang for multi-processors

4
Batch Scheduling
  • Know how much time is needed to complete job
    ahead of time
  • Some intuitive algorithms
  • FIFO
  • Shortest job first
  • Shortest remaining time next
  • Shortest job first is provably optimal for
    minimizing run-time proof?
  • If resource needs are sufficiently well defined,
    can also ensure no deadlock
  • Can use non-preemptive algorithms since this
    reduces process switching

5
Time Sharing (Interactive)
  • Scheduler that we most often encounter multiple
    applications running on your PC
  • Typical system
  • Priority queues with round-robin in each priority
    level
  • Priorities of processes change
  • Scheduling invariant at all times, highest
    priority process is running

6
Priority Queues with Round-Robin
  • Round-robin each process is allowed to run
    specified time quantum
  • Quantum a time interval, e.g., 100 msec
  • Each priority level is allowed to run for some
    time quantum
  • Highest priority processes allowed few quantums
  • Lower priority processes allowed more quantums
  • Why?

7
How to Assign/Change Priorities?
  • Statically based on process type
  • Priority 1/f
  • f size of quantum used last
  • More a process ran, lower its priority
  • Least run priority gets highest priority to run
    next

8
Priority Queue (Corbato et al.)
  • High priority given 1 quantum lower priority
    given more quantums
  • Whenever process completed its allowed quanta at
    a priority level, it moved down one priority
    level
  • Round-robin within a level
  • Result
  • Interactive processes with few instructions gets
    completed quickly
  • Long CPU-bound processes moved down in priority
    but were given longer time interval to run

9
Interactive Systems Other Algs.
  • Shortest Process Next
  • Also used in batch systems
  • Interactive jobs tend to take little time and
    give users greater sense of interactivity
  • Need estimate of running time for a job
  • Guaranteed Scheduling
  • Example N jobs, each will get 1/N CPU time
  • Keep guarantee by keeping track of how much CPU
    time each process has and how much it is entitled
  • Fair-share
  • Equal share of CPU to each user (NOT process)

10
Real-time Scheduling
  • Categories
  • Soft desirable to meet deadlines
  • Hard required to meet deadlines
  • Periodic vs. aperiodic occurs at regular or
    irregular intervals
  • Scheduler may need to know required resources to
    meet deadline ahead of time
  • Examples
  • Should a real-time video server be hard or soft?
  • How about a medical monitor?

11
Determining Schedulability of Real-time Process
  • m periodic events
  • p period of process
  • c CPU time of event I
  • Load can be handled if .
  • Examples of dynamic real-time system
  • Video server
  • Number of people connected and getting streamed
    video changes
  • Server needs to balance load

i
i
12
Scheduling and Synchronization
  • Synchronization is a form of scheduling (among a
    restricted set of processes)
  • Common bad interactions
  • Priority inversion
  • Convoy phenomenon
  • Results from harmful coupling between schedulers
    decisions and how access to locked data is
    synchronized

13
Priority Inversion Problem
  • Occurs when low-priority process holds lock and
    is descheduled while high-priority process waits
    for lock
  • Occurs when processes have priorities and
    scheduler invariant is highest priority ready
    process always runs immediately
  • Example
  • Low priority process A has lock
  • A preempted by high priority process B
  • B tries to get lock and blocks
  • Medium priority process C runs before A can run
    again

14
Priority Inversion Solution
  • Preventing preemption inside critical section is
    not acceptable
  • Critical section could be long
  • Violates scheduler invariant that highest
    priority process always runs next
  • Priority inheritance process in critical
    section inherits (for duration of critical
    section only) the priority of the
    highest-priority process that is blocked
  • Higher priority process is blocked, but only for
    duration of critical section
  • Critical section can be long, but process can be
    preempted inside of critical section by
    non-blocking high priority process
  • Deadlock possible
Write a Comment
User Comments (0)
About PowerShow.com