Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
54 views

Module 3 - Real Time Task Scheduling - Part1

The document discusses real-time task scheduling. It describes how real-time tasks recur periodically or sporadically and each recurrence is called a task instance. It also discusses the relative and absolute deadlines of tasks, task precedence, data sharing between tasks, and the different types of real-time tasks like periodic, sporadic, and aperiodic tasks. Furthermore, it covers key concepts like utilization, jitter, task schedulers, scheduling points, optimal and preemptive schedulers. Finally, it describes different real-time scheduling algorithms like clock-driven, event-driven, table-driven cyclic scheduling, and priority-based algorithms like rate monotonic, deadline monotonic, earliest deadline first etc.

Uploaded by

pranav
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
54 views

Module 3 - Real Time Task Scheduling - Part1

The document discusses real-time task scheduling. It describes how real-time tasks recur periodically or sporadically and each recurrence is called a task instance. It also discusses the relative and absolute deadlines of tasks, task precedence, data sharing between tasks, and the different types of real-time tasks like periodic, sporadic, and aperiodic tasks. Furthermore, it covers key concepts like utilization, jitter, task schedulers, scheduling points, optimal and preemptive schedulers. Finally, it describes different real-time scheduling algorithms like clock-driven, event-driven, table-driven cyclic scheduling, and priority-based algorithms like rate monotonic, deadline monotonic, earliest deadline first etc.

Uploaded by

pranav
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 53

Module 3 – Real Time Task

Scheduling
Task Instance
• Each time an event occurs, it triggers the task
that handles this event to run
• Real-time tasks therefore normally recur a large
number of times at different instants of time
depending on the event occurrence times
• It is possible that real-time tasks recur at
random instants
• T1 (1), T2 (1), T1 (2),
…Continued
• However, most real-time tasks recur with certain
fixed periods
• Example:
– A temperature sensing task in a chemical plant might
recur indefinitely with a certain period because the
temperature is sampled periodically, whereas a task
handling a device interrupt might recur at random
instants
• Each time a task recurs, it is called an instance of
the task
Relative and Absolute Deadlines of Task
Response Time
• Time it takes to produce results (from Arrival
time of the task)
Task Precedence
• A task is said to precede another task, if the
first task must complete before the second
task can start
• T1(1) T2(1)
• Partial Ordering
• T1, T2 , T3 , t4 and T5
• T1 –> T2; T3T4; T2, T4 T5
• Antisymmetric and Transitive
Data Sharing
• A task will precede another if the first task
wants to share data with the later
Type of Real Time Tasks
• Periodic Tasks
• Sporadic Tasks  Hard Real time  Highly
critcal – moderately critical
• Aperiodic Tasks  soft tasks  tolerate lapse
in time -- >logging in distributed  less critical
tasks
Periodic Tasks
• Regular intervals

• Demarcated by clock interrupts  Clock driven tasks

• Ti = < Φi, pi, ei, di > =<2000 msec, 15 msec,


8msec,15msec>
• Φi  time of the first instance200 cycles
• pi period of the task  5 clock
• ei execution time of task –>1 clock
• di  relative deadline  15clks
Sporadic Tasks
Task Schedule
• Valid Schedule
– One task is assigned to a processor at a time
– No task is scheduled before its arrival time
– Precedence and resource constraints of all tasks
are satisfied
• Feasible Schedule
– Valid schedule is a feasible schedule only if,
• All tasks meet their respective time constraints in the
schedule
Scheduling Points
• The scheduling points of a scheduler are the
points on time line at which the scheduler makes
decisions regarding which task is to be run next
• In a clock-driven scheduler, the scheduling points
are defined at the time instants marked by
interrupts generated by a periodic timer
• The scheduling points in an event-driven
scheduler are determined by occurrence of
certain events
Utilization
• Average time for which it executes per unit
time interval (processor)
• For a periodic task Ti, the utilization ui = ei/pi,
where ei is the execution time and pi is the
period of Ti
• Total utilization due to all tasks,
U=
Jitter
• Deviation of a periodic task from its strict
periodic behavior
• The arrival time jitter is the deviation of the
task from arriving at the precise periodic time
of arrival
• Completion time jitter is the deviation of the
completion of a task from precise periodic
points.
Task Scheduler
• Proficient Scheduler
A task scheduler sch1 is said to be more proficient
than another scheduler sch2, if sch1 can feasibly
schedule all task sets that sch2 can feasibly schedule,
but not vice versa. That is, sch1 can feasibly schedule
all task sets that sch2 can, but there exists at least one
task set that sch2 can not feasibly schedule, whereas
sch1 can. If sch1 can feasibly schedule all task sets
that sch2 can feasibly schedule and vice versa, then
sch1 and sch2 are called equally proficient schedulers.
…Continued…
• Optimal
– A real-time task scheduler is called optimal, if it
can feasibly schedule any task set that can be
feasibly scheduled by any other scheduler. In other
words, it would not be possible to find a more
proficient scheduling algorithm than an optimal
scheduler. If an optimal scheduler can not
schedule some task set, then no other scheduler
should be able to produce a feasible schedule for
that task set.
…Continued…
• Preemptive Scheduler
– A preemptive scheduler is one which when a
higher priority task arrives, suspends any lower
priority task that may be executing and takes up
the higher priority task for execution
Classification of Real Time Task Scheduling

• Clock Driven
– Table Driven
– Cyclic
• Event Driven
– Simple Priority
– Rate Monotonic Analysis
– Earliest Deadline First
• Hybrid
– Round Robin
Table Driven Scheduling
• These schedulers precompute which task
should run when – and these details will be
stored in a table
…Continued…
…Continued
Cyclic Schedulers
• Small embedded applications
…Continued…
• While fixing frame size, below constraints to
be considered
– Minimum context switching

– Minimum Table Size

– Satisfaction of Task Deadline


Satisfaction of Task Deadline Constraint
What if there are not any frame size that
satisfies all three constraints?
• Split the task
• Example
Generalized Task Scheduler
• That can schedule, periodic, sporadic and
Aperiodic tasks
• Periodic – scheduled using Table driven / cyclic
• Sporadic, Aperiodic – execute in slack time
Hybrid Schedulers
• Schedules based on clock as well as events

• Example : Time Sliced Round Robin


Event Driven Scheduling
• Scheduling points are defined by task
completion and task arrival events
• Normally preemptive
• Examples
– Foreground-Background Scheduler
– Earliest Deadline First
– Rate Monotonic Algorithm (RMA)
– Deadline Monotonic Algorithm (DMA)
Foreground – Background Scheduler

• Simple Priority driven preemptive

• Real time tasks are foreground tasks

• Sporadic, Aperiodic, non real time  background tasks

• Completion time for Background tasks

Utilization time
Examples
EDF
• A task is schedulable under EDF only if the following condition

is met (assuming di and pi are equal)

• Proven to be optimal uniprocessor scheduling algorithm

• If di < pi, then

• If pi < di, then it is edf schedulable


Examples
MLF Scheduling
• Minimum Laxity First
• A variant of EDF
• At every scheduling point, laxity value is
computed
• Laxity of a task  amount of time that would
remain if the task is taken up for execution
• Task having minimum laxity value is executed
• Considers execution time of task
EDF and Dynamic Priority
• Should be able to determine priority at any
point in time
• Assume, virtual priority of a job increases with
time until the task is taken up for scheduling
• No priority value is computed in EDF at
compile time or runtime
EDF Implementation
• Make all ready tasks wait in a queue
• Freshly arriving tasks  goes to the end of the
queue
• Every tasks’ absolute deadline will also be
maintained
• At every preemption point, the entire queue
would be scanned from the beginning to
determine the task having the shortest deadline
Complexity of EDF implementation
• New Task addition in Queue O(1) /const
time

• Task selection and deletion  O(n), n is the


no.of tasks in queue
More efficient Implementation
• All ready tasks in sorted priority queue
• Using Heap Data Structure
• Task addition to queue  O(logn)
• Task selection and removal  O(1)
Shortcomings of EDF

• Transient Overload Problem

• Resource Sharing Problem

• Efficient Implementation Problem


Rate Monotonic Algorithm (RMA)
• Static Priority Scheduling
• Assigns priorities based on their rate of
occurrence
• Lower the occurrence  lower will be the
priority
• Priority of a task ‘i’ will be, k/pi
– K : constant; pi : period of task
Priority Assignment of Task
Schedulability of RMA
• Whether a set of tasks can be scheduled under
RMA?
– With the knowledge of worst-case execution times
and periods of the tasks
– Through simulation these details need to
ascertained
1. Necessary Condition

2. Sufficient Condition
Examples
What if sufficient condition is not met?

• A test need to performed to ascertain the fact


that the given set of tasks are RMA
schedulable
– Lehoczky Test
Lehoczky Test
RMA Analysis
• Transient Overload Handling
– RMA is good with transient overload handling

• Disadvantage
– Difficult to support sporadic tasks and aperiodic
tasks
– Not optimal when task periods and deadlines
differ
DMA ( Deadline Monotonic Algorithm)

• RMA – not optimal when task deadline and


period differs

• Assign priority based on task deadline


Examples

W.r.t RMA
Pr(T1)>Pr(T2)>Pr(T3)
To check Deadline miss or not under RMA scheduling
T1: e1 <= d110ms<35  Satisfied
T2: e1+e2<=d2  10+15 =25 not less than 20
T2 will miss its deadline if scheduled under RMA

W.r.t DMA
Pr(T2)>Pr(T1)>Pr(T3)
To check Deadline miss or not under DMA scheduling
T2: e2 <= d215ms<20  Satisfied
T1: e1+e2<=d1  10+15 =25 less than 35  Satisfied
T3: e1+e2+e3<=d3  45 <200  Satisfied
Context Switching Overhead
• In RMA  utmost one task preempted (the
task that is currently running
• Worst Case  Each task incurs atmost 2
context switches
– One when it prempts for high priority task (if any)
– Another when it completes and already prempted
task is to be assigned for execution
– where c is the constant time taken for
context switching
Some more Examples

Pr(T1)>Pr(T2)>Pr(T3)

T1: 22 < 100


T2: 22*2+32 = 44+32=76 <150
T3: 22*2 + 32*2 +90 = 198 < 200
(Execution time is added twice to represent the period task could have occurred
twice with in that time period specified)
(Instead of 92, 90 since it is the low priority task)
Self Suspension
• When task suspends itself  OS removes it
from ready queue, places it in blocked queue,
and takes up next eligible task
Effect of Self Suspension
• bi  worst case self suspension time
• btiits own self suspension and self suspension of all
higher priority tasks

• Self suspension time of a higher priority task Tk may


affect the response time of a lower priority task Ti by
as much as execution time of task ek (if ek<bk)

You might also like