Real time system tsp

1,596 views

Published on

0 Comments
2 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
1,596
On SlideShare
0
From Embeds
0
Number of Embeds
3
Actions
Shares
0
Downloads
129
Comments
0
Likes
2
Embeds 0
No embeds

No notes for slide

Real time system tsp

  1. 1. Real Time System T S PRADEEP KUMAR VIT University
  2. 2. Key points <ul><li>Real Time System and its types </li></ul><ul><li>Characteristics </li></ul><ul><li>Scheduling Strategies </li></ul><ul><li>RTOS Concepts </li></ul>
  3. 3. What is Real Time System (RTS) <ul><li>A real-time system is any information processing system which has to respond to externally generated input stimuli within a finite and specified period </li></ul><ul><ul><li>the correctness depends not only on the logical result but also the time it was delivered </li></ul></ul><ul><ul><li>failure to respond is as bad as the wrong response! </li></ul></ul>
  4. 4. Terms Associated with RTS <ul><li>Tasks </li></ul><ul><ul><li>Periodic </li></ul></ul><ul><ul><ul><li>Time-driven. Characteristics are known a priori </li></ul></ul></ul><ul><ul><ul><li>E.g.: Task monitoring temperature of a patient in an ICU. </li></ul></ul></ul><ul><ul><li>Aperiod </li></ul></ul><ul><ul><ul><li>Event-driven. Characteristics are not known a priori </li></ul></ul></ul><ul><ul><ul><li>E.g.: Task activated upon detecting change in patient’s condition </li></ul></ul></ul><ul><ul><li>Sporadic </li></ul></ul><ul><ul><ul><li>Aperiodic tasks with known minimum inter-arrival time. </li></ul></ul></ul>
  5. 5. Terms Associated with RTS <ul><li>Release time of a job: </li></ul><ul><ul><li>The time instant the task becomes ready to execute. </li></ul></ul><ul><li>Deadline of a job: </li></ul><ul><ul><li>The time instant by which the task must complete execution. </li></ul></ul><ul><li>Relative deadline of a job: </li></ul><ul><ul><li>Deadline - Release time. </li></ul></ul><ul><li>Response time of a job: </li></ul><ul><ul><li>Completion time - Release time. </li></ul></ul>
  6. 6. Example
  7. 7. Types of RTS <ul><li>Hard real-time — systems where the responses occur within the required deadline. Eg.Nuclear Reactor control Systems. </li></ul><ul><li>Soft real-time — systems where deadlines are important but which will still function correctly if deadlines are occasionally missed. </li></ul><ul><li>Firm real-time — systems which are soft real-time but in which there is no benefit from late delivery of service. </li></ul>
  8. 8. Hard RTS Vs Soft RTS User Assisted Autonomous Error Detection Large Small Size of Data Non Critical Critical Safety Computer Environment Controlled by Degraded Predictable Peak Load Performance Soft- required Hard- Required Response Time Soft RTS Hard RTS Characteristics
  9. 9. Real Time Spectrum
  10. 10. Characteristics of RTS <ul><li>Deterministic </li></ul><ul><ul><li>Operations are performed at predetermined times or within predetermined time intervals </li></ul></ul><ul><li>Responsiveness </li></ul><ul><ul><li>How long, after acknowledgment, it takes the operating system to service the interrupt </li></ul></ul><ul><ul><li>Includes amount of time to begin execution of the interrupt </li></ul></ul><ul><ul><li>Includes the amount of time to perform the interrupt </li></ul></ul>
  11. 11. Characteristics… <ul><li>User control </li></ul><ul><ul><li>User specifies priority </li></ul></ul><ul><ul><li>What processes must always reside in main memory </li></ul></ul><ul><ul><li>Rights of processes </li></ul></ul><ul><li>Reliability </li></ul><ul><ul><li>Degradation of performance may have catastrophic consequences </li></ul></ul>
  12. 12. Characteristics… <ul><li>Fail-soft operation </li></ul><ul><ul><li>Ability of a system to fail in such a way as to preserve as much capability and data as possible </li></ul></ul><ul><ul><li>Stability </li></ul></ul>
  13. 13. Typical RTS Task Model <ul><li>Each task a triplet: (execution time, period, deadline) </li></ul><ul><li>Usually, deadline = period </li></ul><ul><li>Can be initiated any time during the period </li></ul><ul><li>P=(2,8,8) </li></ul>
  14. 14. Scheduling Algorithms <ul><ul><li>Cyclic Executive (Round Robin) </li></ul></ul><ul><ul><li>Static Priority or offline scheduling </li></ul></ul><ul><ul><ul><li>Rate Monotonic Scheduling </li></ul></ul></ul><ul><ul><ul><ul><li>Deadline=period </li></ul></ul></ul></ul><ul><ul><ul><li>Deadline Monotonic Scheduling </li></ul></ul></ul><ul><ul><ul><ul><li>Deadline ≠period </li></ul></ul></ul></ul><ul><ul><li>Dynamic Priority or online scheduling </li></ul></ul><ul><ul><ul><li>Earliest Deadline First </li></ul></ul></ul>
  15. 15. Preemptive and Non preemptive Schedule <ul><li>Preemptive Schedule </li></ul><ul><ul><li>The higher priority task activated when it requires the CPU while the low priority task suspended during the time in which the higher priority tasks run. </li></ul></ul><ul><ul><li>Most of the RTOS provides preemptive schedule </li></ul></ul><ul><li>Non Preemptive Schedule </li></ul><ul><ul><li>The Low priority task will never suspend when any higher priority task require the CPU time. </li></ul></ul>
  16. 16. Cyclic Executive <ul><li>Simplest approach </li></ul><ul><ul><li>for (;;) </li></ul></ul><ul><ul><li>{ </li></ul></ul><ul><ul><li>do part of task 1 </li></ul></ul><ul><ul><li>do part of task 2 </li></ul></ul><ul><ul><li>do part of task 3 </li></ul></ul><ul><ul><li>} </li></ul></ul>
  17. 17. Cyclic Executive <ul><li>Advantages </li></ul><ul><ul><li>Simple implementation </li></ul></ul><ul><ul><li>Very predictable </li></ul></ul><ul><li>Disadvantages </li></ul><ul><ul><li>Can’t handle sporadic events </li></ul></ul><ul><ul><li>Everything must operate in lockstep </li></ul></ul><ul><ul><li>Code must be scheduled manually </li></ul></ul>
  18. 18. Rate Monotonic Scheduling (RMS) <ul><li>Processes with shorter period given higher priority, deadline=period </li></ul><ul><li>Works for Periodic tasks </li></ul><ul><li>RMS Schedule can exists if </li></ul><ul><ul><ul><li>Processor Utilization U < n(2 1/n -1), </li></ul></ul></ul><ul><ul><ul><ul><li>where U= Σ c i /p i </li></ul></ul></ul></ul><ul><ul><ul><li>if U > 1, then no processor can be running 110% of the time. </li></ul></ul></ul>
  19. 19. Rate Monotonic Scheduling <ul><li>Each process has a fixed priority based on its frames/second, value (hence, rate monotonic) </li></ul><ul><li>Select always the highest priority process </li></ul><ul><li>Rule: </li></ul><ul><ul><li>Each periodic process must complete within its period </li></ul></ul><ul><li>If a high priority process becomes ready for execution at any time, it preempts the running process if there is any </li></ul><ul><li>optimal, static, priority-driven real-time scheduling algorithm for preemptive, periodic jobs </li></ul><ul><ul><li>optimal, in the sense that no other static algorithm can schedule a set of tasks that RM cannot schedule </li></ul></ul>
  20. 20. RMS Scheduling <ul><li>Five assumptions necessary: </li></ul><ul><ul><li>all tasks with deadlines are periodic; </li></ul></ul><ul><ul><li>each task must be completed, before the next request occurs; </li></ul></ul><ul><ul><li>all tasks are independent; </li></ul></ul><ul><ul><li>run-time for each request of a task is constant; </li></ul></ul><ul><ul><li>any non-periodic task has no required deadline </li></ul></ul>
  21. 21. RMS Example
  22. 22. RMS Example 2 Task set: T i = (c i , di, p i ) T1 = (2,6,6) and T2 = (4,10,10) Schedulability check: 2/6 + 4/10 = 0.33 + 0.40 = 0.73 ≤ 2(√2 -1) = 0. 82 T 1 1 T 1 2 0 2 6 8 10 T 2 1 T 2 2 0 2 6 10 T1 T2 Hole Background scheduling: basic idea -- Scheduling aperiodic tasks in holes like this Schedule continues
  23. 23. Earliest Deadline First (EDF) <ul><li>Earliest Deadline First (EDF) </li></ul><ul><ul><li>Online </li></ul></ul><ul><ul><li>Preemptive </li></ul></ul><ul><ul><li>Dynamic priorities </li></ul></ul><ul><ul><li>Always run the process that is closest to its deadline </li></ul></ul><ul><li>• Requirements: </li></ul><ul><ul><li>Pi has a max computation time ei </li></ul></ul><ul><ul><li>the process must be finished before its deadline </li></ul></ul><ul><ul><li>processes are independent (do not share resources) </li></ul></ul><ul><ul><li>the process with shortest absolute deadline (di) will run first </li></ul></ul>
  24. 24. EDF Example
  25. 25. EDF Schedule <ul><li>Earliest deadline first scheduling is optimal: </li></ul><ul><ul><li>If a dynamic priority schedule exists, EDF will produce a feasible schedule </li></ul></ul><ul><ul><li>EDF schedule usually achieves 100% processor utilisation. </li></ul></ul><ul><ul><li>If a schedule is not feasible under EDF algorithm, then there is no other algorithm to give a feasible schedule </li></ul></ul>
  26. 26. Comparison between Static and dynamic Scheduling <ul><li>RMA only guarantees feasibility at 69% utilization. </li></ul><ul><li>EDF guarantees it at 100% </li></ul><ul><li>EDF is complicated enough to have unacceptable overhead </li></ul><ul><li>More complicated than RMA </li></ul><ul><li>Less predictable: can’t guarantee which process runs when </li></ul>
  27. 27. <ul><li>Questions!!! </li></ul>

×