Real-Time Operating System Chapter – 8 Embedded System: An integrated approach Real Time Tasks • What is Real Time? – Simply, the time measured by physical clock. – Anything is ‘real time’ means it has direct relation with actual time. • Real time task: – Performance is judged on basis of time. – Correct result = correct output + correct time • Incorrect timing of result leads to : – System failure OR – Reduced QoS Real Time Operating System(Chapter 8) • Real Time Tasks – – – – – – – – – Process control in industrial plants Robotics Air Traffic control Telecommunications Weapon guidance system e.g. Guided missiles Medical diagnostic and life support system Automatic engine control system Real time data base Mars Rovers • Curiosity : OS – VxWorks, Processor BEA’s RAD 750 Real time speech or video processing • A speech or moving picture sample of 1 second, if processed in 1 second or in less, makes it real time processing RTOS • Question: Is real time systems and embedded systems are same? Terms and definition • Release time (or ready time): This is the time instant at which a task(process) is ready or eligible for execution • Schedule Time: This is the time instant when a task gets its chance to execute • Completion time: This is the time instant when task completes its execution • Deadline: This is the instant of time by which the execution of task should get completed. • Runtime: The time taken without interruption to complete the task, after the task is released Terms and Definitions • Tardiness: Specifies the amount of time by which a task misses its deadline. Its is equal to the difference between completion time and deadline • Laxity: Is defined as deadline minus remaining computation time. The laxity of task is the maximum amount of time it can wait and still meets its deadline Soft and Hard Real Time task • Hard Real time task: – Task must complete before or at deadline. – Value of completing the task after deadline is zero. • Software Real Time – Missing deadline is penalty – Penalty increases as tardiness increase Real Time Operating System(Chapter 8) • Types of Real Time Tasks – Hard Real-time task • Air traffic control • Vehicle subsystems control • Nuclear power plant control – Soft Real-time Task • • • • – – – – – Multimedia transmission and reception Networking, telecom (cellular) networks Web sites and services Computer games. Firm Real Task Periodic Task Aperiodic Task Sporadic Task Preemptible/Non-Preemptible Tasks RTOS • Do an embedded system need an operating system? Real Time Operating System(Chapter 8) • Real time in operating systems: – The ability of the operating system to provide a required level of service in a bounded response time. – It responds to inputs immediately(Real-Time). – Here the task is completed within a specified time delay. – In real life situations like controlling traffic signal or a nuclear reactor or an aircraft, – The operating system has to respond quickly. Real Time Operating System(Chapter 8) • Characteristic of Real time in operating systems: – Consistency – Reliability – Scalability – Predictability – Performance Real Time Operating System(Chapter 8) • Functions of Real time in operating systems: – Task management – Scheduling. – Resource Allocation. – Interrupt Handling. Real Time Operating System(Chapter 8) • Scheduling in Real time in operating systems: – No of tasks – Resource Requirements – Release Time – Execution time – Deadlines • Rate Monotonic Algorithm • Earliest Deadline First Algorithm Real Time Scheduling Algorithms • General Purpose Operating System’s Scheduling Algorithms: • FCFS, SJF, SRTF, Priority Scheduling, Round Robin • Some of them are applicable for RTOS. • There more specific RTOS algorithms RTOS Scheduling Classification Real Time Scheduling Off-line On-line Static Priority Preemptive Non Preemptive Dynamic Priority Planning Based Best Effort Off Line Scheduling (Pre Run time scheduling) • They generate scheduling information prior to system execution (Deterministic System Model) • This scheduling is based on : – Release time – Deadlines – Execution • Disadvantage: Inflexibility, If any parameter changes, the policy will have to be redone On-Line Scheduling • Number and types of tasks, associated parameters are not known in advance. • Scheduling must accommodate dynamic changes • Online Scheduling are of two types: – Static Priority – Dynamic Priority Static Priority • Tasks with highest priority gets the chance to execute first • This can be preemptive or Non-preemptive • Non preemptive: task with highest priority runs till it completes. • Preemptive: The execution of task can be preempted when higher priority task appears in ready queue. Dynamic Priority • Priority can be allowed to change at run time • Scheduling needs more computation • Pre-emption may or may not be used • Flexibility is quite high in such system • Two subsets: 1. Planning Based: – Guarantees deadline for all accepted task. 2. Best effort algorithm does its best to maximize performance. – Guarantees meeting deadline for hard time task. – Optimizes the performance of soft time task Problem: Static Priority Tasks Priority Period CPU Burst T1 1 7 2 T2 2 17 4 T3 3 24 8 • Draw the Gantt-chart for scheduling these tasks. • Assume the all jobs have same release time • Schedule the process to meet their deadline – Without Pre-emption – With Pre-emption • Note: Deadline of task is the time when its next burst arrive Rate Monotonic Algorithm • Introduced by Liu and Layland in 1973 • Assigning priorities as a monotonic function of the rate of a process. • (Monotonic means either increasing or decreasing) • Priorities are assigned according to increased period of a process. • As period increases the priority decreases. • The process with lowest period will have highest priority RM Algorithm • RM provides simple inequality, to verify the sufficient condition for RM algorithm • Where C is CPU Burst , P or T is Period • If the condition satisfied, RM will schedule tasks within their respective deadline • This is sufficient, but not necessary condition Example • • • • • Tasks Priority Period (T) CPU Burst(C) T1 1 7 2 T2 2 17 4 T3 3 24 8 CPU utilization for the set of task: LHS : 2/7 + 4/17 + 8/24 = 0.812 RHS : = 3 X (2 1/3 -1)= 3 x .26 = .78 LHS> RHS :RM does not get satisfied But the task still might get schedulable by RM technique Problem 1 Tasks Period (P or T) CPU Burst(C) T1 15 4 T2 12 2 T3 20 5 Problem 2 Tasks Period CPU Burst Release Time T1 3 1 0 T2 10 3 1 T3 15 4 3