Download as pdf or txt
Download as pdf or txt
You are on page 1of 22

REAL-TIME SCHEDULING

Dayang Norhayati Abang Jawawi

Department of Software Engineering


Faculty of Computing
Universiti Teknologi Malaysia
email : dayang@utm.my
The Structure of Presentation
1. Introduction
2. Scheduling
Part 1
3. Real-time Scheduling
i. Theory
ii. Pre-run-time scheduling
iii. Non-preemptive fixed-priority scheduling
iv. Preemptive fixed-priority scheduling
v. Preemptive dynamic-priority scheduling
Part 2
3. Schedulability Analysis
i. Processor utilization analysis
ii. Processor workloads analysis
iii. Response time analysis
4. Schedulability Analysis of an Mobile Robot Systems
Part 3
6. Blocking on shared resources
7. Conclusion

2
Introduction
Scheduling & Revision

3
Scheduling
v General definition of scheduling – is the allocation of
resources over time to perform a collection of tasks
(Baker, 1974).
v Examples

Resources Tasks
machine in a factory, operations in the factory,

runway at the airport, takeoffs and landing at the


airport,
operational rooms at hospital, operations in the hospital,

lecture rooms in a university, lectures at the university,

processing unit in a computer. execution of the computer


program

4
Scheduling
Concept (Cooling)
v Basic scheduling Policies (page 202-206)
1. Cyclic scheduling
2. Time slicing
3. Task priorities
4. Using queues

v Scheduling Implementation
1. The task control block
2. The tick
3. System responsiveness
4. By-pass the scheduler
5. Code sharing and re-entrancy

5
Scheduling
Concept (Cyclic)
Part-time Driver Time
v Cyclic scheduling (every 4 Drivers’ (Min)
hours) Problem Da 60
v FiFo
Db 30

De Dc 20

Dd
Dd 30
De 40
Dc

Db
idle
Da

20 40 60 80 100 120 140 160 180 200 220 240 260 280 300 320
90 110

Cycle 1 - 4 hours
6
Cycle 2 - 4 hours
Scheduling
Concept (Time slicing) Driver Time (Min)
v Time slicing (20 min) Da 60
v Cyclic scheduling (FiFo - every 4 hours) Db 30
Dc 20
idle Dd 30
De De 40
idle

Dd

Dc

Db
idle
Da

20 40 60 80 100 120 140 160 180 200 220 240 260 280 300 320
130 150

Cycle 1 4 hours Cycle 2 4 hours


7
Scheduling
Concept (Time slicing) Driver Time (Min)
v Time slicing (20 min) - Improved Da 60
v Cyclic scheduling (FiFo - every 4 hours) Db 30
Dc 20
Dd 30
De De 40
Dd

Dc

Db
idle
Da

20 40 60 80 100 120 140 160 180 200 220 240 260 280 300 320
130 150

Cycle 1 4 hours Cycle 2 4 hours


8
Scheduling
Concept (Priority) Task Time Cycle time
(Min) (Min)/Priority
v Cyclic scheduling – different cycle
Da 60 240/5
time
Db 30 130/2
v Task priorities – shortest cycle
Dc 20 120/1
time with higher priority
Dd 30 180/3
Da De 40 180/4

De

Dd

Db
`

Dc

20 40 60 80 100 120 140 160 180 200 220 240 260 280 300 320
c
b d e c b a d c b e Task
b
d
d
e
e
a
a a a e b
e
e
a
a
Queues
e
a
a a
9
PART 1
Real-time Scheduling

10
Scheduling
ERT scheduling systems
v ERT need to run several tasks on a limited set of
processing unit, scheduling these tasks on processors is
to ensure the real-time constraints are met.

v Scheduling goal (Cheng, 2002-):


v Non-real-time systems – to maximize average
throughput (number of task completed per unit
time) and/or to minimize average waiting time of
the tasks.
v Real-time systems – to meet the deadline of every
task by ensuring that each task can complete
execution by its specified deadline.

11
RT Scheduling
Theory
v Scheduling theory assumes that RTS consists of:
1. A set of computational tasks to be performed.
2. A run-time scheduler which controls task execution at
any given moment.
3. A set of shared resources shared by the task.
v Types of tasks:
1. Periodic tasks – consist of an infinite sequence of
identical invocations which arrive at fixed intervals.
2. Aperiodic tasks – consists of a sequence of invocations
which arrive randomly.
3. Speriodic tasks – are special case of aperiodic ones in
which there is a known worst-case arrival rate for the
task.
v Individual task invocation category:
1. Non-preemptive task invocation execute to completion
without interruption once started.
2. Preemptive task invocations can be temporarily
preempted during their execution by the arrival of a
higher-priority invocation.
12
RT Scheduling
Typical periodic task
arrival time start time finishing time deadline next arrival time

T - period

D - deadline

R – response time

C – Worst-Case Computation time (WCET)

not runnable preempted

blocked locking resources

executing
13
Analysis & Scheduling Policies
Classification of RT scheduling Policies
Real-Time Scheduling

Hard Real-Time Soft Real-Time


Mixture of hard-deadline periodics
Run-time Scheduling Pre-run-time Scheduling
Hard-deadline aperiodic tasks

imprecise computation model


Fixed-priority Dynamic-priority
Rate Monotonic Rate Monotonic + Priority extended periodic task model
ceiling protocol
User defined stochastic rate monotonic
Earliest Deadline First

v Pre-run-time scheduling – require the programmer to


define the entire schedule prior to execution. E.g. run-
robin.
v Run-time scheduling – the algorithm make decision
about which task to execute at run-time based on
priorities of the tasks.

14
RT Scheduling
Pre-run-time Scheduling
Task C (ms) Occurrence in
20 ms (times)
a 1 4
b 7 1
c 3 2
task

time
5 10 15 20

Not runnable Executing idle preempted

15
RT Scheduling
Fixed-priority Scheduling
v Each task has a fixed, static priority.

v The runnable task are executed in the order determined by


their priority.

v In RTS the priority of a task is derived from its temporal


requirements.

v Rate monotonic (RM) scheduling algorithm – a simple


optimal priority assignment scheme (Burn, 2003).
1. Preemptive priority-driven scheduling
2. Priority assignment based on T - shorter T higher
priority

v RM was chosen by - Space Station Freedom Project & FAA


Advanced Automation System (AAS)
v RM influenced - the specs of IEEE Futurebus+
v RMA is widely used for off-line analysis of time-critical
systems.
16
RT Scheduling
Fixed-priority Scheduling (Non-preemptive )
Task C (ms) arrival time D (ms) priority

h 4 9 10 high
m 7 5 12 medium
l 6 1 19 low
task

time
5 10 15 20

Not runnable Executing Blocked Deadlines

17
RT Scheduling
Fixed-priority Scheduling (Preemptive)
Task C (ms) arrival time D (ms) priority

h 4 9 10 high
m 7 5 12 medium
l 6 1 19 low
task

time
5 10 15 20

Not runnable Executing Preempted Deadlines

18
RT Scheduling
Dynamic-priority Scheduling
v Each task has a dynamic priority.

v The runnable task are executed in the order determined by


their dynamic priority.

v Earliest Deadline First (EDF) scheduling algorithm – a


optimal priority assignment scheme (Burn, 2003).
1. Preemptive priority-driven scheduling
2. Priority assignment based on D - Always execute the
task with the nearest absolute (D + arrival time)

19
RT Scheduling
Preemptive Dynamic-priority Scheduling
Task C (ms) arrival time D (ms)

h 4 9 10
m 7 5 12
l 6 1 19
task

h
Identify a small
m mistake in the
colored situation.
l

time
5 10 15 20

Not runnable Executing Preempted Deadlines

20
RT Scheduling
Comparison of the scheduling algorithm
Pre-run-time Non-preemptive Preemptive fixed- Preemptive
fixed-priority priority dynamic-
priority
Adv + entirely deterministic + simple programming + faster service to higher- + guarantee
+ not require RTOS paradigm priority task tasks will meet
+ tasks are evenly spaced in + allow individual task + RTOS available, simpler their D
time to be programmed and easier to maintain
separately + programmer free to
+ Can be formally choose task priorities, T &
analyzed for D
schedulability + Schedulability test
+ stable

Dis- - rigid & difficult to construct - Unresponsive - complex RTOS required - higher run-
support periodic task only Overrunning low- High degree of jitter time overhead
adv - - -
- inefficiency, some cycle were priority task can - Unstable
left idle delay higher-priority under
- Rewrite all code just to fit a one transient
overload
task in the schedule
- makes program difficult to
design
Unstable when a task overrun
-
21
Thank You.

22

You might also like