0% found this document useful (0 votes)
91 views30 pages

Real Time Systems

The document discusses task assignment and scheduling in real-time systems. It covers common terminology, issues in allocation and scheduling, task characteristics, precedence constraints, and scheduling algorithms like rate monotonic, earliest deadline first, and deadline monotonic. It also discusses handling critical sections, priority inversion, and solutions like priority inheritance and priority ceiling protocols.

Uploaded by

Dheeraj Singh
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
91 views30 pages

Real Time Systems

The document discusses task assignment and scheduling in real-time systems. It covers common terminology, issues in allocation and scheduling, task characteristics, precedence constraints, and scheduling algorithms like rate monotonic, earliest deadline first, and deadline monotonic. It also discusses handling critical sections, priority inversion, and solutions like priority inheritance and priority ceiling protocols.

Uploaded by

Dheeraj Singh
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 30

TASK ASSIGNMENT AND SCHEDULING IN REAL TIME SYSTEMS

BANSIDHAR JOSHI
[email protected]

6/19/2012

Task Assign_Scheduling in RTS

Real Time System


In General: any system where a timely response by the computer to external stimuli is vital Timely Deadline Hard/soft RTS Issues: Tasks scheduling, Database Mgt., fault tolerance etc

6/19/2012

Task Assign_Scheduling in RTS

RTS: Common Terminologies


Release time: The time at which all the data required to begin execution of the task are available Deadline: The time by which the task must complete its execution
Absolute: Time 0 to the actual instant of Deadlines occurrence Relative: Time of arrival to the corresponding deadlines occurrence

Response time: The time duration from the occurrences of the event generating the task to the time the task produces its result
6/19/2012 Task Assign_Scheduling in RTS 3

Allocation And Scheduling Issue


Given:
a set of tasks task precedence constraints resource requirements task characteristics deadlines

Objective: to devise a feasible allocation/schedule

6/19/2012

Task Assign_Scheduling in RTS

Task Precedence
A task is said to precede another task, if the first task must complete before the second task can start If task Tis output is needed as input by task Tj, then task Tj is constrained to be precede by task Ti Precedence constraints can be represented by means of a precedence graph

6/19/2012

Task Assign_Scheduling in RTS

Real Time Task Characteristics


Three types: A. Periodic - Task is released periodically B. Sporadic

Not periodic, but may be invoked at irregular intervals


Characterized by the upper bound on the rate at which they may be invoked Recurs at random instants
Task Assign_Scheduling in RTS 6

6/19/2012

Real Time Task Contd.


C. Aperiodic
Tasks which are not periodic and which also have no upper bound on their invocation rate Can arise at random instants
Minimum separation between two consecutive instances may be 0

6/19/2012

Task Assign_Scheduling in RTS

Scheduling Algorithms
Uniprocessor, Multiprocessor Scheduling Ability to obtain a feasible multiprocessor schedule is directly linked to developing a feasible Uniprocessor schedule Uniprocessor: Rate Monotonic, Earliest Deadline First, Deadline Monotonic etc.

Multiprocessor: Utilization Balancing, Next-fit, Binpacking etc.

6/19/2012

Task Assign_Scheduling in RTS

Rate Monotonic (RM) Algorithm


An Optimal Static- priority Uniprocessor scheduling algo. The task set consists of
Periodic tasks Pre-emptible tasks

whose deadlines = the tasks periods


A task set of n tasks is schedulable under RM if total processor utilization is no greater then Task priorities are static and inversely related to their periods
6/19/2012 Task Assign_Scheduling in RTS 9

Necessary And Sufficient Condition For RMschedulable


If the task set is such that the processor utilization is no greater than n(21/n 1), Then the task set is RM-schedulable Let:- e:: execution time; p:: period such that p1 p2 . pn To prove: start with n = 2: if there are two tasks T1 and T2 and e1/p1 + e2/p2 2(21/2 1), then the tasks are RMschedulable If relative deadlines(d) are given for each task, then U= e/p for a task
6/19/2012 Task Assign_Scheduling in RTS 10

RM- Example
T1(4,1), T2(5,1), T3(10,1), Ui = 1/4 + 1/5 + 1/10 = 0.55 3 (21/3-1) 0.78 Thus, {T1, T2, T3} is schedulable under RM

6/19/2012

Task Assign_Scheduling in RTS

11

Preemptive Earliest Deadline First (EDF) Algorithm


Optimal Dynamic-priority Uniprocessor scheduling algo. Always executes the task whose absolute deadline is the earliest Priorities changes depending on the closeness of their absolute deadline

A special case of Deadline Monotonic algorithm

6/19/2012

Task Assign_Scheduling in RTS

12

Preemptive EDF Contd.


Example: Aperiodic tasks:
Task Arrival Time Execution Abs. Time Deadline

t = 0:
t = 4:

T1 arrives, starts execution


T2 arrives, preempts T1

t = 5:
T1 T2 T3 0 4 5

T3 arrives, waits
10 3 10 30 10

t =7: T2 completes and T3 starts execution

t = 17:
25

t = 23:
6/19/2012

T3 completes and T1 starts execution T1 completes


13

Task Assign_Scheduling in RTS

Preemptive EDF Contd.


Assumptions:
No task has any non-preemptive section and the cost of preemption is negligible Only processing requirements are significant, memory, I/O and other resource requirements are negligible
All tasks are independent; there are no precedence constraints Tasks need not be periodic
6/19/2012 Task Assign_Scheduling in RTS 14

Schedulability Test
U=

P = lcm (P1Pn) hT(t) be the sum of the execution times of all tasks in set T whose absolute deadlines are less than t.

6/19/2012

Task Assign_Scheduling in RTS

15

Schedulability Test Contd.


A task set of n tasks is not EDF feasible iff i) U > 1 or ii) There exists

such that hT(t) > t.

6/19/2012

Task Assign_Scheduling in RTS

16

Deadline Monotonic Algorithm


Static priority algorithm Assigns priorities to tasks according to their relative deadline.
Task T1 T2 T3 Release Time 50 0 0 Period 50 (1) 62.5 (2) 125 (3) Execution Time 25 10 25 Relative deadline 100 20 50 Priority 3 1 2

DM Algorithm Contd.
When the relative deadline of every task is proportional to its period, RM and DM algorithms are identical When the relative deadlines are arbitrary, DM algorithm performs better DM can produce a feasible schedule when RM algorithm fails, While RM algorithm always fails when the DM algorithm fails

Allowing For Precedence And Exclusion Conditions(PREC)


Relaxing the assumptions:
Tasks are independent and Tasks are always pre-emptible by other tasks

E.g. Consider a set of tasks with a precedence graph, which are released at time 0
T1 T2 T4 T6
6/19/2012 Task Assign_Scheduling in RTS 19

T3 T5

Example Contd.
Ti 1 2 Ei 3 3 Di 6 7

3 4
27 6

2 5
6 6

20 21
27 28

Assumption:

Deadline is specified for each task, such that there will be enough time to execute its children in the task graph by their deadlines even if a task completes at its deadline

6/19/2012

Task Assign_Scheduling in RTS

20

Algorithm PREC
Tasks are numbered so that D1 D2 D3 Dn 1. 2. Schedule task Tn in the interval , [Dn-en, Dn] While ( all the tasks have not been scheduled), let A be the set of as-yet-unscheduled tasks all of whose successors if any, have been scheduled Schedule task Tk , k max { m/ m A} as late as possible enddo 3. Move the tasks forward to the extent possible keeping their order of of execution as specified in step 2

6/19/2012

Task Assign_Scheduling in RTS

21

Handling Critical sections


A task that is currently holding the un-sharable resource is said to be in the critical section associated with the resource Binary semaphores can used so that only one task can access the critical section Properly nested Lock S1 Lock S2 Unlock S2 Unlock S1

6/19/2012

Task Assign_Scheduling in RTS

22

Handling CriticalContd.
Assumptions
Once a task starts, it continues until it finishes

It is preempted by some higher priority task It is blocked by lower priority task that holds the lock on a critical section that it needs

6/19/2012

Task Assign_Scheduling in RTS

23

Priority Inversion
Lower Priority task (TL)blocking Higher priority task(TH) Can occur in any priority-based preemptive scheduling scheme Occurs when circumstances within the system force a higher priority task to wait for a lower priority task
Example T1 T2 T3 are tasks ( Descending order of priority which share a processor) S critical section used by T1 and T3 t0 - T3 begins execution t1 - T3 enters CS

6/19/2012

Task Assign_Scheduling in RTS

24

Priority Inversion
t2 - T1 released t3 - T1 wants to enter CS, S is locked by T3 which is suspended, T1 is blocked and T3 continues in S t4 - T2 is released which preempts T3 t5 - T2 completes, T3 resumes t6 - T3 exits CS; T1 preempts T3

6/19/2012

Task Assign_Scheduling in RTS

25

Solution:
Use of Priority Inheritance Protocol: If THigh is blocked by TLow , TLow temporarily inherits the priority of THigh. When blocking ceases TLow resumes its original priority Disadvantages: It can lead to deadlock It is possible for the highest priority task to be blocked once by every other task executing on the same processor

6/19/2012

Task Assign_Scheduling in RTS

26

Example: Priority Inheritance


e.g. Tasks: T1 and T2; Use CS S1 & S2 T1 > T2
T1: Lock S1 LockS2 Unlock S@ Unlock S1 T2: Lock S2 Lock S1 Unlock S1 Unlock S2
t0 - T2 starts execution t1 - T2 locks S2 t2 - T1 is initiated, it preempts T2 t3 - T1 locks S1 t4 - T1 attempts to lock S2 but blocked T2 inherits priority of T1, starts execution t5 T2 tries to lock S1, it cannot do so, since t1 has a lock on it. Both T1 and T2 are deadlocked!

6/19/2012

Task Assign_Scheduling in RTS

27

Priority Ceiling Protocol


Priority ceiling of a semaphore is the highest priority of any task that may lock it Similar to Inheritance except that a task can also be blocked from entering critical section(CS) if there exists any semaphore currently held by some other task whose priority ceiling is greater than or equal to the priority of T Let P(T) denotes the priority of task T and P(S) the priority ceiling of the semaphore of CS S

6/19/2012

Task Assign_Scheduling in RTS

28

Example: Priority Ceiling


Tasks: T1, T2, T3 T1> T2> T3

6/19/2012

Task Assign_Scheduling in RTS

29

Example Contd.
S1 S2 T1 T4 T2, T4, T5 P(T1) P(T2)

6/19/2012

Task Assign_Scheduling in RTS

30

You might also like