RTOS task scheduling models. Scheduling Definition: It is the method by which threads, processes or...

download RTOS task scheduling models. Scheduling Definition:  It is the method by which threads, processes or data flows are given access to system resources.

If you can't read please download the document

Transcript of RTOS task scheduling models. Scheduling Definition: It is the method by which threads, processes or...

  • Slide 1

RTOS task scheduling models Slide 2 Scheduling Definition: It is the method by which threads, processes or data flows are given access to system resources (e.g. processor time, communications bandwidth). By use of Proper algorithm of scheduling, we can perform multiple task in a given time. The scheduler is concerned mainly with: Throughput - The total number of processes that complete their execution per time unit. Response time - amount of time it takes from when a request was submitted until the first response is produced. Waiting Time - Equal CPU time to each process (or more generally appropriate times according to each process' priority). It is the time for which the process remains in the ready queue. Slide 3 Preemptive vs. Non- Preemptive A scheduling algorithm is: Preemptive: if the active process or task or thread can be temporarily suspended to execute a more important process or task or thread. Non-Preemptive: if the active process or task or thread cannot be suspended, i.e., always runs to completion. 3 Slide 4 RTOS task scheduling models 1.Cooperative Scheduling of ready tasks in a queue. 2.Cyclic and round robin (time slicing) Scheduling. 3.Preemptive Scheduling. 4.Rate-Monotonic Scheduling (RMS). 5.Scheduling using Earliest deadline first (EDF). Slide 5 1.Cooperative Scheduling of ready tasks in a queue. Dis-advantages: Longer execution time of a low priority task makes a higher priority task wait until it finishes. Slide 6 2.Cyclic and round robin (time slicing) Scheduling. Cyclic Scheduling Slide 7 Round Robin (time slicing) Scheduling Slide 8 Example Slide 9 Tasks programs contexts at the five instances in the Time Scheduling Scheduler for C1 to C5 Slide 10 Priority-based Scheduling Typical RTOS based on fixed-priority preemptive scheduler Assign each process a priority At any time, scheduler runs highest priority process ready to run Process runs to completion unless preempted Slide 11 Typical RTOS Task Model Each task a triplet: (execution time, period, deadline) Usually, deadline = period Can be initiated any time during the period Execution time Period Deadline Time Initiation Slide 12 Priority-based Preemptive Scheduling Always run the highest-priority runnable process P1 P2 P3 P1 P3 P1 P2 P3 Deadline Initiation Priorities 1 2 3 tt P2 tt Scheduling After completing other high priority process, switch to next interrupted low priority process Slide 13 RMS Scheduling Slide 14 Rate-Monotonic Scheduling Slide 15 The utilization bound (UB) test allows schedulability analysis by comparing the calculated utilization for a set of tasks and comparing that total to the theoretical utilization for that number of tasks: If this equality is satisfied, all of the tasks will always meet their deadlines. If the total utilization calculates to greater than 100%, the system will have scheduling problems. Slide 16 Assumes rate monotonic priority assignment Task with smaller period is assigned higher priority Guaranteed to be schedulable if test succeeds. Utilization Bound Test Slide 17 Utilization Bound Test Example No. Tasks Utilization Bound (in % ) 1100% 282.8% 378.0% 475.7% 574.3% 1071.8% Slide 18 Example: Checking for Schedulability using of RMS. And Time period P1 process = 4 secs. Means P1 repeat after every 4 secs Solution: Golden Rule : 1.Shortest test period = Highest Priority 2.Check for Schedulability ProcessesComputation/ Execution Time (Ci) Time Period (Ti) P114 P226 P3312 Slide 19 Processes Computation/ Execution Time Time Period Priority P114High(1) P226Medium(2) P3312Low(3) 2. Checking for Schedulability 1. Deciding Priority Level Here U(n) < 1, so we can schedule the process by using RMS scheduling algorithm Slide 20 Scheduling Timing Diagram Total time = take LCM of Period of Process = 12 1 2 3 4 5 6 7 8 9 10 11 12 P1 P2 P3 Processes P3 P2 P1 P2 Next period P3 Processes Computation/ Execution Time Time Period P114 P226 P3312 1 st period continue Slide 21 Example: Checking for Schedulability using of RMS. Solution Here clearly the CPU Utilization is more than 1 (i.e. 1.25). So these is not Scheduled. ProcessesComputation/ Execution Time (Ci) Time Period (Ti) P124 P236 P3312 Slide 22 Earliest deadline first Scheduling RMS assumes fixed priorities First check for Schedulability by using Utilization formulae Earliest deadline first: Processes with soonest deadline given highest priority Slide 23 ProcessesComputation/ Execution Time (Ci) Time Period (Ti) P113 P214 P325 Example: Checking for Schedulability using of EDF. Solution Step 1: Check for Schedulability U = 1/3 + 1/4 + 2/5 = 0.98 which is less than 1 So we can schedule the given task Slide 24 Solutions 12345678910111213141516 d(1)d(2)d(3)d(1)d(2)d(1)d(3)d(1) d(2) d(1) d(3) P1P2P3 P1P2P1P3P1P2P1P3 Period (UPTO 60) ProcessesComputation / Execution Time (Ci) Time Period (Ti) P113 P214 P325 Scheduled Process according to their Execution time Slide 25 OS SECURITY ISSUES SELF STUDY!!!!