Presentation is loading. Please wait.

Presentation is loading. Please wait.

EEE 6494 Embedded Systems Design

Similar presentations


Presentation on theme: "EEE 6494 Embedded Systems Design"— Presentation transcript:

1 EEE 6494 Embedded Systems Design
Real-Time Scheduling Algorithms 서강대학교 전자공학과

2 Agenda Real-Time System Classifications of Scheduling Assumption
RM (Rate Monotonic) EDF (Earliest Deadline First) LLF (Least Laxity First) Shared Resources Conclusion

3 Real-Time System What is a real-time system?
Correctness of system operation depends on temporal characteristics as well as logical/functional characteristics Characteristics definition of each task for analyzing a real-time system Core execution time (or computation time) Activation time (or release time) Deadline A point in time by which the task must complete Hard real-time system vs. Soft real-time system Relative deadline vs. Absolute deadline

4 Response Time = TimeActuation – TimeSensed (from Release to Response)
A Service Release and Response WCET (Ci) Input/Output Latency Interference Time Interrupt Dispatch Preemption Interference Completion (IO Queued) Actuation (IO Completion) Input- Latency Dispatch- Execution Output- Response Time = TimeActuation – TimeSensed (from Release to Response) Event Sensed Time

5 Real-time Scheduling Algorithms
Static/dynamic priority preemptive scheduling Static schedulability analysis : Results used at run-time - Good for periodic tasks but inflexible Dynamic : No explicit schedule, at run-time execute highest priority task first Period driven - Rate monotonic (RM), Deadline Monotonic Deadline driven - Earliest deadline first (EDF), Slack driven - Least slack (LLF) Flexible, but potentially dangerous I Priority inversion Shared resources – Deadlock possibility Event-driven non-preemptive Tasks represented by functions (event handlers) Safe, but limited

6 Assumptions Liu and Layland assumed (in RM and EDF)
All tasks are periodic Tasks are ready to run at their release time Tasks are independent : No shared resources, no synchronization No overhead costs for preemption, scheduling or interrupt handling Processing is fully preemptable

7 Rate Monotonic Scheduling Algorithm
Idea of RM algorithm A lower-priority task is executing and a higher-priority task becomes available to execute, it will preempt the lower-priority task Static scheduling Shorter period tasks get higher priority

8 Priority : S1 > S2 > S3
Example of RM Scheduling Tasks Deadline (ms) Computation Time (ms) S1 D1 = 30 C1 = 10 S2 D2 = 55 C2 = 10 S3 D3 = 60 C3 = 5 10/30+10/55+5/60 S1 time 5 15 25 35 45 55 65 75 activation S2 S3 85 Priority : S1 > S2 > S3 deadline Preemption S2 S1

9 Rate Monotonic Scheduling Algorithm
Schedulability Analysis( ) A set of n periodic tasks is schedulable by the RM algorithm if , where and meaning that any task set can be scheduled by RM if , but not all task sets can be scheduled if Ex) 10/30+10/55+5/60 p p

10 EDF Scheduling Algorithm
Idea of EDF algorithm The scheduler reevaluates the deadlines of all tasks any time an interrupt occurs (a new task is activated or a task is finished), and allocates the resource to the task having the earliest deadline Dynamic scheduling Deadline-based preemption

11 Example of EDF Scheduling
Task Period Relative Deadline Computation Time S1 T1 = 30 D1 = 30 C1 = 10 S2 T2 = 40 D2 = 40 C2 = 15 S3 T3 = 50 D3 = 50 C3 = 10 10/30+15/40+10/50 activation time 5 15 25 35 45 55 65 75 T1=30 S1 85 S2 S3 T2=40 T3=50 윤디자인연구소

12 EDF Scheduling Algorithm
Schedulability Analysis( ) A set of n periodic tasks is schedulable by the EDF algorithm if (computation time Ci , period Ti ) meaning that any task set can be scheduled by EDF if Ex) 10/30+15/40+10/50

13 Shared Resources Critical section Priority inversion
Program section where a shared resource is accessed No other task can access this resource : Mutual exclusion Priority inversion A situation in which a higher priority job is blocked by lower priority jobs for an indefinite period of time

14 Priority : S1 > S2 > S3
Priority Inversion Protocol priority inversion Priority : S1 > S2 > S3 Can’t meet the deadline !! activation S1 time 5 15 25 35 45 55 65 75 85 activation S2 time 5 15 25 35 45 55 65 75 85 activation S3 time 5 15 25 35 45 55 65 75 85 Critical section

15 Two solutions of priority inversion problem
PIP (Priority Inheritance Protocol) PCP (Priority Ceiling Protocol)

16 PIP (Priority Inheritance Protocol)
If a task execution in a critical section blocks one or more higher priority tasks, then it temporarily inherits the highest priority of the blocked tasks When a task exits the critical section, it resumes the original priority it had when it entered that critical section

17 Priority : S1 > S2 > S3
Example of PIP Priority : S1 > S2 > S3 activation priority inheritance P(S1) P(S3) S1 time 5 15 25 35 45 55 65 75 85 activation S2 time 5 15 25 35 45 55 65 75 85 activation S3 time 5 15 25 35 45 55 65 75 85 Critical section

18 The PIP may also cause problems when more than one shared resource is used, by producing a chained blocking Chained blocking Execution: Task 4-> task 3 -> Task 2 -> Task1 Lowest-priority tasks execute first: may miss deadline

19 PCP (Priority Ceiling Protocol)
Solution for chained blocking If a task execution in a critical section blocks, then it temporarily inherits the priority ceiling The priority ceiling is equal to the highest priority of the tasks that concurrently hold or will hold that resource (Lookahead) ‘Ceiling’ may be misleading

20 Priority : S1 > S2 > S3 > S4
Another Example (PIP applied) activation priority inheritance P(S2) P(S4) priority inheritance P(S1) P(S4) S1 time 5 15 25 35 45 55 65 75 85 95 activation S2 time 5 15 25 35 45 55 65 75 85 95 activation S3 time 5 15 25 35 45 55 65 75 85 95 activation S4 time 5 15 25 35 45 55 65 75 85 95 Critical section Priority : S1 > S2 > S3 > S4

21 When PCP is applied Critical section activation S1 time activation S2
5 15 25 35 45 55 65 75 85 95 activation S2 time 5 15 25 35 45 55 65 75 85 95 activation S3 time 5 15 25 35 45 55 65 75 85 95 the highest priority(S1) is inherited S4 time 5 15 25 35 45 55 65 75 85 95 Critical section Priority : S1 > S2 > S3 > S4

22 Schedulability Analysis( )
A set of n periodic tasks is schedulable by the EDF algorithm if (computation time Ci , period Ti ) And schedulable by the EDF based PCP algorithm if We denote this worst case blocking time of a job in task ti by Bi Ex) 10/60+10/75+5/75+25/95+25/75

23 Conclusion The scheduling of jobs with hard deadlines is an important area in real-time systems The choice of scheduling algorithm is very important in real-time systems


Download ppt "EEE 6494 Embedded Systems Design"

Similar presentations


Ads by Google