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

Real time system tsp

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