Presentation is loading. Please wait.

Presentation is loading. Please wait.

Introduction to Embedded Systems Rabie A. Ramadan 5.

Similar presentations


Presentation on theme: "Introduction to Embedded Systems Rabie A. Ramadan 5."— Presentation transcript:

1 Introduction to Embedded Systems Rabie A. Ramadan rabieramadan@gmail.com http://www.rabieramadan.org/classes/2014/embedded/ 5

2 Real Time Systems

3 Correctness of the system may depend not only on the logical result of the computation but also on the time when these results are produced Tasks attempt to control events or to react to events that take place in the outside world These external events occur in real time and processing must be able to keep up Processing must happen in a timely fashion, neither too late, nor too early Some examples include, Air Traffic Control, Robotics, Controlling Cars/Trains, Medical Support, Multimedia.

4 Types of Real Time Systems Hard real time systems Must always meet all deadlines System fails if deadline window is missed Soft real time systems Must try to meet all deadlines System does not fail if a few deadlines are missed Firm real time systems Result has no use outside deadline window Tasks that fail are discarded

5 Real time tasks Periodic - Each task is repeated at a regular interval - Max execution time is the same each period - Arrival time is usually the start of the period - Deadline is usually the end Aperiodic - Each task can arrive at any time

6 Real-Time Scheduling Determines the order of real time task executions Dynamic vs. Static Dynamic schedule computed at run-time based on tasks really executing, priorities computed on the fly Static schedule done at compile time for all possible tasks, priorities are already known

7 Rate Monotonic Simplest type of real time scheduling Simplest type of real time scheduling - Tasks are periodic, with hard deadlines - Tasks are completely independent and do not communicate with each other - Tasks are scheduled according to priority and task priorities are fixed - Computation time is known and constant

8 Rate Monotonic  Higher priorities usually assigned to tasks with smaller periods  If t(h) PR(l), where t indicated period and PR indicates the priority. This is called rate monotonic priority assignment.  Calculates the critical instant for each task.  Occurs when task Ti and all higher priority tasks are scheduled simultaneously  If tasks deadline scheduled at critical instant, then the task can always meet its deadline.

9 Deadline Monotonic Tasks with shorter deadlines get higher priority. Static Scheduling. If D(h) PR(l), where D indicates the deadline. This is called Deadline Monotonic priority assignment.

10 EDF: Earliest Deadline First Dynamic Scheduling Assume a preemptive system with dynamic priorities Like deadline monotonic, the task with shortest deadline gets highest priority, but the difference is real time priorities can vary during the system’s execution. Priorities are reevaluated when events such as task arrivals, completions occur

11 Real Time Synchronization Required when tasks are not independent and need to share information and synchronize If two tasks want to access the same data, semaphores are used to ensure non-simultaneous access. Potential Issues Priority Inversion – A situation in which a higher priority job is blocked by lower priority jobs for an indefinite period of time Chain Blocking – A situation in which more than two resources are available and a high priority task is blocked off from both because of two or more lower priority tasks holding locks on one or both of the resources.

12 Priority Inversions Low priority task holds resource that prevents execution of higher priority tasks. - Task L acquires lock - Task H needs resource, but is blocked by Task L, so Task L is allowed to execute - Task M preempts Task L, because it is higher priority - Thus Task M delays Task L, which delays Task H

13 Priority Inheritance Protocol PIP eliminates priority inversion problem The algorithm will increase the priority of a task to the maximum priority of any task waiting for any resource the task has a resource lock on - i.e. if a lower priority task L has a lock on a resource required by a higher priority task H, then the priority of the lower task is increased to the priority of the higher task - Once the lock is released the task resumes back its original priority.

14 Priority Ceiling Protocol Each resource is assigned a priority ceiling, which is a priority equal to the highest priority of any task which may lock the resource. PCP eliminates chain blocking which considers the use of more than one resource or semaphore A task can acquire a lock on resource S only if no other task holds a lock on resource R. Thus higher priority tasks will not be blocked through both S and R If a high priority task is blocked through a resource, then the task holding that resource gets the priority of the high priority task. Once the resource is released, the priority is reset back to its original

15 15 Priority inversion - A scheduling scenario where a high priority task is indirectly preempted by a medium priority task because it is blocked waiting for a shared resource. Priority inheritance - A scheduling policy that attempts to solve the problem of priority inversion as follows: whenever a high priority task has to wait for some resource, shared with an executing low priority task, the low priority task is temporarily assigned the priority of the highest waiting priority task for the duration of its own use of the shared resource. This strategy prevents medium priority tasks from preempting it. When the shared resource is released the low priority task continues to execute at its original priority level.

16 16 Priority ceiling inheritance - An enhancement of the priority inheritance policy. A priority ceiling is defined for each resource. The scheduling policy is the same as for priority inheritance except that tasks can only acquire a resource if their static priority is higher than the ceiling of any currently locked resource (excluding that it has already blocked itself).


Download ppt "Introduction to Embedded Systems Rabie A. Ramadan 5."

Similar presentations


Ads by Google