RTOS Scheduling Essentials for Real-Time Embedded Systems
1. Real-time Embedded Systems- Lecture 02 Real-time Embedded Systems Lecture 2 RT Systems Essentials Part I RTOS-Scheduling Prof. Dr. Amitava Gupta Department of Power Engineering Jadavpur University , India
2. What have we learnt….. What is a Real-time System? (we know this) Hard & Soft RT systems What are embedded systems? ((know this too!) Real-time Embedded systems? (know this as well!) What we learn now? OS features which make each unit or module run i.e. RTOS This is just basic RTOS stuff (Vorspeise) Real-time Embedded Systems- Lecture 02
4. Hard Real Time Soft Real Time Soft Real Time is a property of timeliness of a computation where the value of computation decreases according to its tardiness. EXAMPLE: Data Acquisition Systems A Hard Real Time system is one where the computation has no value whatsoever if the time constraint is not met. EXAMPLE: Control Systems for Industrial Processes Real-time Embedded Systems- Lecture 02
5. BLOCKED RUNNING READY Resources Become Available Resources Become Unavailable Higher Priority Task Is READY Task Pre-empted Real-time Embedded Systems- Lecture 02
8. Function Pointer based scheduling While(1) { If (queue not empty) execute queue head ; } void isr1( ) { Place function pointer one in queue; } Void isr2( ) { Place function pointer two in queue; } Real-time Embedded Systems- Lecture 02
10. Priority driven scheduling algorithms A scheduling algorithm or a ‘scheduler’ is a set of rules which determines which task in a set of tasks is executed by a processor at any particular instant. We assume a scenario where a number of tasks are executed on a single processor. Static: Task priorities are assigned once and for all (aka fixed priority based preemptive scheduling) Dynamic: Task priorities change from time to time Hybrid: Combination of both Real-time Embedded Systems- Lecture 02
11. Recap: Comparison of different scheduling techniques Real-time Embedded Systems- Lecture 02 Does not depend on code Dependent on code Dependent on code Code Dependence Context switch latency Maximum of runtimes Sum of runtimes Worst case wait time for highest priority task possible possible Not possible Prioritization Pre-emptive Function Pointer Round-robin
12.
13. A few definitions For a set of tasks τ 1 , τ 2 , τ 3 , … τ m , let C 1 , C 2 , C 3 ,…C m be the runtimes ( maximum time taken by a task to execute without being preempted) T 1 ,T 2 ,T 3 ,…T m be the periods at which the tasks receive triggers (requests) (Task periodicity) Response time : Time interval between the instant at which request for a task arrives and the instant at which the response for the request is completed. Critical Instant : The instant at which the response time for a task is maximum Task deadline : The instant at which the next request for the task arrives Critical Timezone : Interval between the critical instant and the instant at which response is completed Overflow : If a request remains unfulfilled for a deadline Real-time Embedded Systems- Lecture 02
14. Theorem 1 A critical instant for a task occurs whenever the request for the task arrives along with other higher priority tasks. (proof: chalk and board) Real-time Embedded Systems- Lecture 02
15.
16. Real-time Embedded Systems- Lecture 02 Significance of RM scheduling Let C 1 , C 2 , ….,C n be the execution times of a set of n tasks T 1 , T 2 , ….,T n be the periodicity of a set of n tasks Then the task set is RM schedulable if C 1 /T 1 + C 2 /T 2 +…+C n /T n ≤ m(2 1/m – 1) Again, the RM scheduling algorithm is an optimal one. I Thus, if any static priority scheduling algorithm can produce a feasible schedule for a set of n tasks, so can RM scheduling. Converse is not true. Digging dipper? Real-time Systems: C.M. Krishna & K. G. Shin McGraw-Hill ISBN 0-07-114243-6
17. Real-time Embedded Systems- Lecture 02 Multiprocessor Scheduling Algorithms Utilization balanced : The algorithm assigns tasks to processors one by one in such a way that at the end of each step, the processor utilization remains balanced. Next-fit: Works in conjunction with RM. Tasks are broken into classes and each processor handles a set of tasks belonging to a particular task. Bin-packing: Assigns tasks to processors such that the total processor threshold is never exceeded. The threshold is set in such a way that uniprocessor scheduling generates a feasible schedule. Bidding algorithm : Tasks arrive at processors. A processor which is unable to meet the demand, offloads it to others. A variant of this is the buddy strategy- an underloaded processor is a buddy to an overloaded one. Assignment with precedence constraints: Takes task precedence into account
18. Real-time Embedded Systems- Lecture 12 Something which we have left out: RMS with blocking where b i is the blocking time associated with task T i