Professional Documents
Culture Documents
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
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
A real-time system is a system whose correctness includes its ➜ Many real-time games, networked games
➜ 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
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
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
Real-time
Current process process
Current process
Scheduling time blocked or completed
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