Scheduling Strategies - PowerPoint PPT Presentation

About This Presentation
Title:

Scheduling Strategies

Description:

collection of processes. Comparing Scheduling Strategies ... RR Example (w/ 50 tu Overhead) p0. 540. 480. 360. 240. 120. 0. p4. p1. p0. p4. p3. p2. p1. p1. p2 ... – PowerPoint PPT presentation

Number of Views:26
Avg rating:3.0/5.0
Slides: 17
Provided by: grantb2
Category:

less

Transcript and Presenter's Notes

Title: Scheduling Strategies


1
Scheduling Strategies
  • Operating Systems
  • Spring 2004
  • Class 10

2
Scheduling Strategies
  • The job of the scheduling strategy is to select
    the next Ready process to enter the Running state.

Preemption or voluntary yield
Scheduler
Strategy
Ready List
New Process
CPU
Done
process
process
process
Ready
Running
process
Resource Manager
Allocate
Request
process
process
process
Blocked
Resources
3
Some Scheduling Strategies
  • Non-Preemptive Strategies
  • First-Come-First-Served (FCFS)
  • Priority
  • Shortest Job Next (SJN)
  • These also come in a preemptive flavor.
  • Preemptive Strategies
  • Round Robin
  • Multi-level Queue
  • Multi-level Feedback Queue

4
Evaluating Scheduling Strategies
  • Some metrics that are useful in evaluating
    scheduling strategies
  • CPU Utilization The percentage of time that the
    CPU spends executing code on behalf of a user.
  • Throughput The average number of processes
    completed per time unit.
  • Turnaround Time The total time from when a
    process first enters the Ready state to last time
    it leaves the Running state.
  • Wait Time The time a process spends in the
    Ready state before its first transition to the
    Running state.
  • Waiting Time The total time that a process
    spends in the Ready state.
  • Response Time The average amount of time that a
    process spends in the Ready state.
  • These metrics are typically averaged across
    acollection of processes.

5
Comparing Scheduling Strategies
  • There are many techniques for comparing
    scheduling strategies
  • Deterministic Modeling
  • Queuing Models
  • Simulation
  • Implementation

6
Deterministic Modeling
  • In deterministic modeling well ignore I/O
    operations and voluntary yields.

Preemption or voluntary yield
Scheduler
Strategy
Ready List
New Process
CPU
Done
process
process
process
Ready
Running
process
Resource Manager
Allocate
Request
process
process
process
Blocked
Resources
7
FCFS Example
Gantt Chart
1275
1200
900
475
350
0
p0
p1
p2
p3
p4
8
SJN Example
Gantt Chart
1275
800
450
200
75
0
p0
p1
p2
p3
p4
  • SJN
  • Guaranteed minimum average wait time.
  • May result in starvation of large jobs.
  • Need to know the CPU burst times.

9
RR Example (w/ 50tu Time Slice)
Gantt Chart
475
400
300
200
100
0
550
650
p0
p4
p1
p0
p4
p3
p2
p1
p1
p2
p3
p0
p3
p2
650
750
850
950
1050
1150
1250
1275
p0
p3
p2
p0
p3
p2
p0
p2
p0
p2
p2
p2
p2
10
RR Example (w/ 50 tu Overhead)
Gantt Chart
540
480
360
240
120
0
575
790
635
670
p0
p4
p1
p0
p4
p3
p2
p1
p1
p2
p3
p0
p3
p2
910
1030
1150
1270
1390
1510
1535
790
p0
p3
p2
p0
p3
p2
p0
p2
p0
p2
p2
p2
p2
  • Throughput, turnaround, wait, waiting and
    response time calculations must now include the
    overhead.

11
Multi-Level Queues
Preemption or voluntary yield
Ready List0
Scheduler
Ready List1
CPU
Done
Ready List2
  • For i lt j All processes at level i run before
    any process at level j.
  • Each list may use its own strategy.

New Process
Ready ListN-1
12
Linux Scheduling
  • Linux uses a multi-level queue scheduling
    strategy
  • All threads in FIFO run before any in RR which
    run before any in OTHER.
  • Within each queue a priority scheme is used with
    higher priority threads running first.
  • User threads run in the OTHER queue.
  • All queues are preemptive.

Preemption or voluntary yield
FIFO
Done
Scheduler
New Process
RR
CPU
OTHER
13
Linux OTHER Queue Scheduling
  • The OTHER queue uses the following strategy
  • Each thread, i, has a priority pi
  • Every new thread is given a default priority, K.
  • A countdown timer is used to create time slices.
  • On each timer interrupt the priority of the
    running thread is decremented (pi--).
  • When a threads priority reaches 0, it is
    blocked.
  • The highest priority thread is selected to run
    for the next time slice.
  • If no threads are available (i.e. all threads are
    blocked on a resource or because they have 0
    priority), then a recrediting operation is
    performed.
  • During recrediting, every thread in the system is
    assigned priority using the following formula
  • Threads blocked for 0 priority nowreturn to the
    ready queue.

14
Multi-Level Feedback Queues
Preemption or voluntary yield
Ready List0
Scheduler
Ready List1
CPU
Done
  • For i lt j All processes at level i run before
    any process at level j.
  • Processes are inserted into queues by priority.
  • Process priorities are updated dynamically.
  • Each queue typically uses a RR strategy.
  • Popular in Modern OS
  • Windows
  • BSD

Ready List2
New Process
Ready ListN-1
15
Scheduling Simulations
  • Scheduling simulations account for several
    important factors that are frequently ignored by
    deterministic modeling
  • Scheduling Overhead
  • I/O Operations
  • Process Profiles
  • CPU Bound
  • I/O Bound
  • Variable process arrival times.

16
Project
  • Implement the RR and Linux OTHER scheduling
    strategies and compare their performance on
  • I/O Bound Processes
  • CPU Bound Processes
  • A mix of CPU and I/O Bound Processes
Write a Comment
User Comments (0)
About PowerShow.com