You are on page 1of 6

R OUND - ROBIN

quantum=1:
P RIORITIES
A ➜ Each thread is associated with a priority
B ➜ Basic mechanism to influence scheduler decision:
C
D • Scheduler will always choose a thread of higher priority over
E
one of lower priority
0 5 10 15 20
• Implemented via multiple FCFS ready queues (one per
Slide 1 quantum=4: Slide 3 priority)
A ➜ Lower-priority may suffer starvation
B
C • adapt priority based on thread’s age or execution history
D
E ➜ Priorities can be defined internally or externally

0 5 10 15 20 - internal: e.g., memory requirements, I/O bound vs CPU


➜ Scheduled thread is given a time slice bound
➜ Running thread is preempted upon clock interrupt, running - external: e.g., importance of thread, importance of user
thread is returned to ready queue

Priority queueing:
Performance of round-robin scheduling:
➜ Average waiting time: not optimal Queue Runable processes
headers
➜ Performance depends heavily on size of time-quantum:
- too short: overhead for context switch becomes too Priority 4 (Highest priority)
Slide 2 expensive Slide 4
Priority 3
- too large: degenerates to FCFS policy
- rule of thumb: about 80% of all bursts should be shorter than Priority 2
1 time quantum
➜ no starvation Priority 1 (Lowest priority)

P RIORITIES 1 P RIORITIES 2
D
D
E
E
A
Round-Robin A
Round-Robin B
(RR), q = 4 B
(RR), q = 4 C
C
D
D
E
E
A
Shortest Process A
Shortest Process B
Next (SPN) B
Next (SPN) C
C
D
D
E
E
A
Shortest Remaining A
Shortest Remaining B
Time (SRT) B
Time (SRT) C
C
D
D
E
E
A
Feedback
Highest Responsescheduling:
Highest Response
A
B
Ratio Next (HRRN) B
Ratio Next (HRRN) C
C 0 5 10 15 20
D
D
E
E L OTTERY S CHEDULING
A
Feedback
First-Come-First
A
B ➜ process gets “lottery tickets” for various resources
Feedback B
q = 1 (FCFS)
Served
q =1 C
C
D
➜ more lottery tickets imply better access to resource
D
E
Slide 5
E
Slide 7 Advantages:
A
A
Feedback
Round-Robin
Feedback B ➜ Simple
= 2ii
q(RR), B
C
q=2 q=1 C
D
D
➜ Highly responsive
E
E ➜ Allows cooperating processes/threads to implement individual
➜ Penalize jobs Athat
0 have been
0
5 running longer
5
10
10
15
15
20
20 scheduling policy (exchange of tickets)
Round-Robin B
➜ qq ==4 2i :
(RR), longerCtime slice for lower priority
D
(reduce starvation)
E

A
Shortest Process B
Next (SPN) C
D
E

A
Shortest Remaining B
Time (SRT)
Feedback scheduling:
C
D Example (taken from Embedded Systems Programming:
E
RQ0 Release
Admit
A Processor
Four processes a running concurrently
Highest Response B
Ratio Next (HRRN) C ➜ Process A: 15% of CPU time
D
E ➜ Process B: 25% of CPU time
A RQ1 Release ➜ Process C: 5% of CPU time
Feedback
q=1
B
C
Processor
➜ Process D: 55% of CPU time
D
Slide 6 E ¥ ¥ ¥ Slide 8 How many tickets should each process get to achieve this?
A ¥ ¥ ¥
Feedback B Number of tickets in proportion to CPU time, e.g., if we have
i
q=2 C
D
RQn Release 20 tickets overall
Processor
E
➜ Process A: 15% of tickets: 3
0 5 10 15 20 ➜ Process B: 25% of tickets: 5
Priorities influence access to resources, but do not guarantee ➜ Process C: 5% of tickets: 1
a certain fraction of the resource (CPU etc)! ➜ Process D: 55% of tickets: 11

L OTTERY S CHEDULING 3 R EALTIME S YSTEMS 4


R EALTIME S YSTEMS Real-time systems:
Overview: ➜ no clear separation
➜ system may meet hard deadline of one application, but not of
Slide 9 ➜ Real time systems Slide 11 other
➜ depending on application, time-scale may vary from
- Hard and soft real time systems
microseconds to seconds
- Real time scheduling
➜ most systems have some real-time requirements
- A closer look at some real time operating systems

Soft Real-time Applications:


R EAL -T IME S YSTEMS
➜ Many multi-media apps
What is a real-time system? ➜ e.g., DVD or MP3 player

A real-time system is a system whose correctness includes its ➜ Many real-time games, networked games

response time as well as its functional correctness. Hard Real-time Applications:


What is a hard real-time system? ➜ Control of laboratory experiments
Slide 10 Slide 12
➜ Embedded devices
A real-time system with guaranteed worst case response ➜ Process control plants
times. ➜ Robotics
➜ Hard real-time systems fail if deadlines cannot be met ➜ Air traffic control
➜ Service of soft real-time systems degrades if deadlines cannot ➜ Telecommunications
be met ➜ Military command and control systems

R EAL -T IME S YSTEMS 5 R EAL -T IME S YSTEMS 6


C HARACTERISTICS OF REAL - TIME OPERATING SYSTEMS

User control: User has much more control compared to


Hard real-time systems:
ordinary OS’s
➜ often lack full functionality of modern OS
➜ User specifies priority
➜ secondary memory usually limited or missing
➜ Specify paging
➜ data stored in short term or read-only memory
➜ Which processes must always reside in main memory
➜ no time sharing
Slide 13 Slide 15 ➜ Disks algorithms to use
Modern operating systems provide support for soft real-time ➜ Rights of processes
applications
Reliability: Failure, loss, degradation of performance may
Hard real-time OS either specially tailored OS, modular have catastrophic consequences
systems, or customized version of general purpose OS. ➜ Attempt either to correct the problem or minimize its effects
while continuing to run
➜ Most critical, high priority tasks execute

C HARACTERISTICS OF REAL - TIME OPERATING SYSTEMS

Deterministic: How long does it take to acknowledge


interrupt?
➜ Operations are performed at fixed, predetermined times or C HARACTERISTICS OF REAL - TIME OPERATING SYSTEMS
within predetermined time intervals
General purpose OS objectives like
➜ Depends on
➜ speed
- response time of system for interrupts
Slide 14 - capacity of system
Slide 16 ➜ fairness

➜ Cannot be fully deterministic when processes are competing for ➜ maximising throughput
resources ➜ minimising average response time
➜ Requires preemptive kernel are not priorities in real time OS’s!
Responsive: How long does it take to service the interrupt?
➜ Includes amount of time to begin execution of the interrupt
➜ Includes the amount of time to perform the interrupt

C HARACTERISTICS OF REAL - TIME OPERATING SYSTEMS 7 C HARACTERISTICS OF REAL - TIME OPERATING SYSTEMS 8
Request from a
real-time process Real-time process added to
run queue to await its next slice

Real-time
Process 1 Process 2 Process n process

Features of real-time operating systems: Clock


tick
R EAL -Scheduling
TIME SCHEDULING
time
➜ Fast context switch
➜ Small size Non-preemptive priority:
(a) Round-robin Preemptive Scheduler

➜ Ability to respond to external interrupts quickly Request from a


➜ Predictability of system performance! real-time process Real-time process added
Slide 17 Slide 19 to head of run queue
➜ Use of special sequential files that can accumulate data at a
fast rate Request from a Real-time
real-time processCurrent process
➜ Preemptive scheduling based on priority Real-time process added process
to
run queue to await its next slice
➜ Minimization of intervals during which interrupts are disabled Current process
Scheduling time blocked or completed
➜ Delay tasks for fixed amount of time Process 1 Process 2 Process n
Real-time
process
(b) Priority-Driven Nonpreemptive Scheduler
Clock
tick
Scheduling
Request from a time
real-time process Wait for next
preemption
(a) Round-robin Preemptive point
Scheduler

Request from a Real-time


real-timeCurrent
process process
Real-time process added
process
to head of run queue
Preemption
Scheduling time
point
Real-time
Current process process
(c) Priority-Driven Preemptive Scheduler on Preemption Points
Current process
R EAL - TIME SCHEDULING EAL RTIME
Scheduling
Request -
fromSCHEDULING
time a blocked or completed
real-time process
Real-time process preempts current
Preemptive round-robin: Preemption points: (b) Priority-Driven Nonpreemptive Scheduler
process and executes immediately

Request from a Request from a Real-time


real-time process Real-time process added to Current process
real-time process Wait for process
next
Slide 18 run queue to await its next slice Slide 20 preemption point

Scheduling time
Real-time Real-time
Process 1 Process 2 Process n process Current process process
(d) Immediate Preemptive Scheduler
Clock Preemption
tick Scheduling time
Scheduling time point

(a) Round-robin Preemptive Scheduler (c) Priority-Driven Preemptive Scheduler on Preemption Points

Request from a Request from a


real-time process Real-time process added real-time process
Real-time process preempts current
to head of run queue
process and executes immediately

Real-time Real-time
Current process process Current process process
R EAL - TIME SCHEDULING Current process 9 R EAL - TIME SCHEDULING 10
Scheduling time blocked or completed Scheduling time

(b) Priority-Driven Nonpreemptive Scheduler (d) Immediate Preemptive Scheduler


Request from a
real-time process Real-time process added
to head of run queue

Real-time
Current process process

Current process
Scheduling time blocked or completed

(b) Priority-Driven Nonpreemptive Scheduler

Request from a
real-time process Wait for next
preemption point

Real-time
Current process process
Preemption
R EAL - TIME
Scheduling time
point SCHEDULING

Immediate (c)
preemptive:
Priority-Driven Preemptive Scheduler on Preemption Points

Request from a
real-time process
Slide 21 Real-time process preempts current
process and executes immediately

Real-time
Current process process

Scheduling time

(d) Immediate Preemptive Scheduler

R EAL - TIME SCHEDULING 11

You might also like