Real-Time Task Scheduling3

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

Real Time Task Scheduling

ͽ Basic concepts related to scheduling


ͽ 1. Valid schedule
ͽ 2. Feasible schedule
ͽ 3. Scheduling points
ͽ 4. Preemptive scheduler
ͽ 5. Optimal scheduler
ͽ 6. Proficient scheduler
ͽ 7. Jitter
ͽ 8. Utilization
Classification of real-time scheduling
algorithms based on scheduling points

Clock Driven Event driven Hybrid


• Table-driven • Simple priority-based • Round-robin
• Cyclic • Rate Monotonic Analysis
(RMA)
• Earliest Deadline First (EDF)
Classification of real-time scheduling
algorithms based on acceptance test

Planning-based Best effort


Classification of real-time scheduling
algorithms based on target platform

Uniprocesso Multiproces
Distributed
r sor
Clock-Driven Scheduling
ͽ Scheduling points are determined by timer interrupts.
ͽ Scheduling decisions regarding which task to run next.
ͽ Also called off-line schedulers because these schedulers fix the schedule
before the system starts to run.
ͽ Adv: incur very little run time overhead
ͽ Disadv: can not satisfactorily handle aperiodic and sporadic tasks since the
exact time of occurrence of these tasks can not be predicted. (also called a
static scheduler)
ͽ Two important clock-driven schedulers:
ͽ 1. Table-driven and
ͽ 2. Cyclic schedulers.
1. Table-Driven Scheduling
ͽ precompute which task would run when
ͽ store the schedule in a table at the time the system is designed or configured.
ͽ The application programmer can be given the freedom to select his own
schedule for the set of tasks in the application and store the schedule in a
table.
1. Table-Driven Scheduling
ͽ major cycle / hyper period of the set of tasks ST
ͽ LCM(p1, p2, .., pn) is called the major cycle of the set of tasks ST.
ͽ Determines the size of the schedule table.

ͽ A major cycle of a set of tasks is an interval of time on the time line such
that in each major cycle, the different tasks recur identically.

ͽ For any given task set it is sufficient to store entries only for LCM(p1,
p2, .., pn) duration in the schedule table.
Table-Driven Scheduling

Task p e

1. T1
T2
20
100
5
20
T3 250 30

Task P e
2. T1 40 1
T2 10 2
T3 20 1
T4 20 5
Table-Driven Scheduling
Task P e
T1 4 1
T2 5 1.8
T3 20 1
T4 20 2

ͽ Utilization: 0.25, 0.36, 0.05, and 0.1

ͽ Example S
2. Cyclic Schedulers
ͽ Popular and extensively used in the industry.
ͽ A large majority of all small embedded applications being manufactured
presently are based on cyclic schedulers.
ͽ Simple, efficient, and are easy to program.
ͽ Example: temperature controller. A temperature controller periodically
samples the temperature of a room and maintains it at a preset value. Such
temperature controllers are embedded in typical computer-controlled air
conditioners.
2. Cyclic Schedulers
ͽ repeats a precomputed schedule.
ͽ The precomputed schedule needs to be stored only for one major cycle.
ͽ Each task in the task set to be scheduled repeats identically in every major
cycle.
ͽ The major cycle is divided into one or more minor cycles.
ͽ Each minor cycle is also called a frame.
ͽ scheduling points occur at frame boundaries.
ͽ This means that a task can start executing only at the beginning of a frame.
2. Cyclic Schedulers
ͽ The size of the frame to be used by the scheduler is an important design
parameter and needs to be chosen very carefully.
ͽ A selected frame size should satisfy the following three constraints.
ͽ 1. Minimum Context Switching
ͽ 2. Minimization of Table Size
ͽ 3. Satisfaction of Task Deadline
2. Cyclic Schedulers
ͽ 1. Minimum Context Switching
ͽ This constraint is imposed to minimize the number of context switches occurring
during task execution.
ͽ task instance must complete running within its assigned frame.
ͽ Unless a task completes within its allocated frame, the task might have to be
suspended and restarted in a later frame.
ͽ This would require a context switch involving some processing overhead.
ͽ To avoid unnecessary context switches, the selected frame size should be larger
than the execution time of each task, so that when a task starts at a frame
boundary it should be able to complete within the same frame. Formally, we can
state this constraint as: max({ei}) < F where e is the execution times of the of
task T, and F is the frame size.
ͽ This constraint imposes a lower-bound on frame size.
2. Cyclic Schedulers
ͽ 2. Minimization of Table Size.
ͽ This constraint requires that the number of entries in the schedule table should be
minimum in order to minimize the storage requirement of the schedule table.
ͽ Remember that cyclic schedulers are used in small embedded applications with
very small storage capacity.
ͽ So, this constraint is important to the commercial success of a product.
ͽ Minimization of the number of entries to be stored in the schedule table can be
achieved when the minor cycle squarely divides the major cycle.
ͽ When the minor cycle squarely divides the major cycle, the major cycle contains an
integral number of minor cycles (no fractional minor cycles).
ͽ We can formulate this constraint as:
2. Cyclic Schedulers
ͽ 3. Satisfaction of Task Deadline.
ͽ This third constraint on frame size is necessary to meet the task deadlines.
ͽ This constraint imposes that between the arrival of a task and its deadline, there
must exist at least one full frame.
ͽ This constraint is necessary since a task should not miss its deadline.
ͽ Consider this: a task can only be taken up for scheduling at the start of a frame.
2. Cyclic Schedulers
ͽ If between the arrival and completion of a task not even one frame exists, a situation
as shown in Fig. 7 might arise. In this case, the task arrives a little after the kth
frame has started. Obviously it can not be taken up for scheduling in the kth frame
and can only be taken up in the (k+1)th frame. But, then it may be too late to meet
its deadline since the execution time of a task can be upto the size of a full frame.
This might result in the task missing its deadline since the task might complete only
at the end of (k+1)th frame.

ͽ This constraint imposes a upper-bound on frame size.


Task P e
T1 4 1
T2 5 1
T3 20 1
T4 20 2

Task P e
T1 4 1
T2 5 2
T3 20 5
Find LCM
Task P e
T1 4 1 1. max({ei}) < F
T2 5 2
T3 20 5 2.

3.

Task P e
T1 4 1
T2 5 2
T3 20 1
T3 20 2
T3 20 2
Cyclic Schedulers vs Table-driven Schedulers
ͽ A cyclic scheduler needs to set a periodic timer only once at the application
initialization time. This timer continues to give an interrupt exactly at every frame
boundary.
ͽ But in table-driven scheduling, a timer has to be set every time a task starts to run.
The execution time of a typical real-time task is usually of the order of a few
milliseconds. Therefore, a call to a timer is made every few mill Seconds.
ͽ This represents a significant overhead and results in degraded system performance.
Therefore, a cyclic scheduler is more efficient than a table-driven scheduler.
ͽ This probably is a reason why cyclic schedulers are so overwhelmingly popular
especially in embedded applications.
ͽ However, if the overhead of setting a timer can be ignored, a table-driven
scheduler is more proficient than a cyclic scheduler because the size of the frame
that needs to be chosen should be at least as long as the size of the largest execution
time of a task in the task set.

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy