Real time-embedded-system-lec-02

1,348 views

Published on

by Dr. Amitava Gupta

Published in: Education, Technology, Business
1 Comment
1 Like
Statistics
Notes
No Downloads
Views
Total views
1,348
On SlideShare
0
From Embeds
0
Number of Embeds
5
Actions
Shares
0
Downloads
0
Comments
1
Likes
1
Embeds 0
No embeds

No notes for slide

Real time-embedded-system-lec-02

  1. 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. 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
  3. 3. Real-time system:- System External World t t+ ∆t ∆ t is fixed Real-time Embedded Systems- Lecture 02
  4. 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. 5. BLOCKED RUNNING READY Resources Become Available Resources Become Unavailable Higher Priority Task Is READY Task Pre-empted Real-time Embedded Systems- Lecture 02
  6. 6. Scheduling in RTOS <ul><li>Round Robin </li></ul><ul><li>Function Pointer with Interrupts </li></ul><ul><li>Priority based preemptive </li></ul>Real-time Embedded Systems- Lecture 02
  7. 7. Round Robin Real-time Embedded Systems- Lecture 02
  8. 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
  9. 9. Priority Based Real-time Embedded Systems- Lecture 02
  10. 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. 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. 12. <ul><li>Static priority driven preemptive scheduling </li></ul><ul><li>Assumptions </li></ul><ul><li>Tasks become ‘ready’ based on triggers from external events or other tasks </li></ul><ul><li>and such triggers (aka requests) are periodic </li></ul><ul><li>Once triggered, each task is completed before the next trigger comes </li></ul><ul><li>The triggers for individual tasks are independent </li></ul><ul><li>Runtime of a task is constant and does not vary </li></ul><ul><li>Non-periodic tasks like failure recovery routines are special, scheduled </li></ul><ul><li>rarely, displacing all periodic tasks and they do not have hard real-time </li></ul><ul><li>constraints </li></ul>Real-time Embedded Systems- Lecture 02
  13. 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. 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. 15. Real-time Embedded Systems- Lecture 02 Rate Monotonic Scheduling Explained <ul><li>Assumptions: </li></ul><ul><li>No task has any non-preemptable section and the cost of pre-emption is negligible </li></ul><ul><li>The tasks require more processing than memory and I/O access </li></ul><ul><li>The tasks are independent and follow no precedence relation </li></ul><ul><li>All tasks are periodic </li></ul><ul><li>The relative deadline of a task is its period. </li></ul>Rate monotonic scheduling assigns priorities to tasks in the order of their request rates( priority higher if request rate is higher) Significance: If the total processor utilization by a set of tasks in less than or equal to a limiting value, then RM scheduling will schedule all the tasks to meet their respective deadlines.
  16. 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. 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. 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
  19. 19. Real-time Embedded Systems- Lecture 02 Goodbye till next week

×