RT2021 Chap4
RT2021 Chap4
Chapter 4:
Basic concepts of scheduling
Start/
dispatched terminate
activate
task Ready queue running
preempted
released Wait/blocked
Wait queues
NLT, SoICT, 2021
Preemption
❑ The running task can be interrupted at any point, so that a
more important task that arrives can immediately gain the
processor.
❑ The to-be-preempted task is interrupted and inserted to
the ready queue, while CPU is assigned to the most
important ready task which just arrived.
❑ Why preemption is needed in real-time systems?
Exception handling of a task
Treating with different criticalities of tasks, permits to anticipate
the execution of the most critical activities
Efficient scheduling to improve system responsiveness
❑ Simple translation
CPU time is divided into time slices [t1,t2)
During a time slice (t)=const, representing the task
that is executed
NLT, SoICT, 2021
Notation
Notation of scheduling (2)
of scheduling(2)
Idle J1 J2 J3 idle
3
(t)
2
1 A time slice
t1 t2 t3 t4
❑ Feasible schedule
A schedule that all tasks can be completed according to
a set of specified constraints
J1
t
J2 t
J3 t
(t)
Li
Lateness
Ci
time
fi
Di relative deadline
Ci Execution
time
time
ai Si fi di
arrival time start time finishing absolute
time deadline
Xi Laxity
NLT, SoICT, 2021
Task parameters(2)
❑ Other task parameters
Response time: different between the finishing time and
the request time Ri = fi - ri
Criticality: Hard or Soft
Value vi: relative importance of task with respect to the
other tasks
Lateness: the delay of a task completion with respect to its
deadline Li = fi –di
Tardiness or Exceeding time: Ei = max(0,Li) is the time a
task stays active after its deadline.
Laxity or Slack time Xi = di – ai – Ci is the maximum time a
task can be delayed on its activation to complete within its
deadline
❑ Notation:
Precedence relations are described by a directed acyclic
graph G.
: task Ja is a predecessor of task Jb
: task Ja is an immediate predecessor of Jb
To be executed
earlier
J1
J2 J3
J4 J5
To be executed
later
❑ Private resource:
A resource dedicated to a particular process
❑ Shared resource:
A resource that can be used by more tasks
❑ Critical section
A piece of code under mutual exclusion constraints
Created by synchronization mechanism
Wait(s)
Wait(s)
Critical section Shared resource
R Critical section
Signal(s)
Signal(s)
preempts blocked
Higher priority
J1
Lower priority
J2
scheduling
activation Termination
READY RUN
preemption
WAITING
❑ Scheduling problem:
Assigning processors from P and resource from R to
tasks from J under given constraints
❑ Practical approach:
Simplify computer architecture: uniprocessor
Adopt additional conditions: preemptive model,
priority, task activation…
➔ Result in different classes of problem that can be
solved by different scheduling algorithms
❑ Non-preemptive
A task, once started, is executed by the processor until
completion without interruption by any other tasks.
<non-preemptive>
time
The arrival time of The arrival time of
the lower priority the higher priority
task task
time
❑ Dynamic
Scheduling decisions are based on dynamic parameters
that may change during system evolution.
Task1: 1
Task2: 5 refers <Static>
Scheduler
Task3:2
dispatch
Fixed priorities
<on-line>
Dynamically Scheduler
generates a Large run-time overhead
schedule
dispatch Good flexibility
scheduling
Activation Termination
Yes
ACCEPTANCE READY RUN
TEST
preemption
No Signal free Wait on busy
resource resource
WAITING
J1
J2
J3
J4
❑ Best-effort algorithms
Accepts all tasks that arrived
Aborts some tasks under real overload conditions
Cannot guarantee feasibility
J1 J2 J3 J4 J5
0 2 4 6 8 10 12 14 16 18 20 22 24 26 t
d1 d2 d3 d4 d5
J2 J3 J4 J5 J1
0 2 4 6 8 10 12 14 16 18 20 22 24 26 t
v(fi) v(fi)
(a) fi (b) di fi
v(fi)
v(fi)
on time
firm
di fi di
(c) (d)
❑ Three processors
❑ Optimal schedule *
in Figure next slide
Global completion time is 12
J1 (3) J9 (9)
J8 (4)
J2 (2)
J7 (4)
J3 (2)
J6 (4)
J4 (2) J5 (4)
P1 J1 J9
P2 J2 J4 J5 J7
P3 J3 J6 J8
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 t
P1 J1 J8
P2 J4 J5 J9
P3 J2 J6
P4 J3 J7
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 t
P1 J1 J5 J8
P2 J2 J4 J6 J9
P3 J3 J7
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 t
J8 (4)
J2 (2)
J7 (4)
J3 (2)
J6 (4)
J4 (2) J5 (4)
P1 J1 J8 J9
P2 J2 J4 J5
P3 J3 J7 J6
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 t
J1 J2
J3 J4 J5 tc = 17
0 2 4 6 8 10 12 14 16 18 20 22 24 26 t
J1 J2
J3 J4 J5 tc = 22
0 2 4 6 8 10 12 14 16 18 20 22 24 26 t