Presentation is loading. Please wait.

Presentation is loading. Please wait.

REAL TIME SYSTEM Scheduling.

Similar presentations


Presentation on theme: "REAL TIME SYSTEM Scheduling."— Presentation transcript:

1 REAL TIME SYSTEM Scheduling

2 Basics of Scheduling Usually Fewer Processor than tasks
Adherence to timing constraints like deadline In a Multiprocessor (or MultiCore) environment, A scheduling decision is a decision to execute a task, and it has the following three parts: assignment: which processor should execute the task; ordering: in what order each processor should execute its tasks; and timing: the time at which each task executes.

3 Type of schedulers – Offline
Fully static scheduler Doesn't require mutex or semaphore Difficult to realize Difficult to predict execution time Tasks typically have data dependent execution times Static order scheduler Tasks assignment and ordering at design time Defer until run time decision of when in physical time to execute a task Depend on whether locks could be acquired or precedence constraints are satisfied

4 Type of scheduler- Online
Static assignment scheduler Assignment at design time rest at run time Fully dynamic scheduler When a processor become available scheduler decides which tasks should be assigned to it Preemptive scheduler Tasks can be removed while still executing and another task can be assigned the processor Tasks may be blocked if it try to acquire a lock and the lock is not available Non-preemptive scheduler

5 Times associated with a task
Periodic tasks Sporadic tasks- repeat but timing is irregular Priority or precedence constraints Tasks may have preconditions

6 Comparing Schedulers Feasible schedule (fi<di)
Optimal with respect to feasibility Processor utilization Maximum lateness Lmax=max(fi-di) where i belongs to T Help us to analyze infeasible schedules For soft real time system positive Lmax is not a problem Total completion time or Makespan M=max(fi) – min(ri) for all i belonging to T

7 Implementation of a Scheduler
For preemptive scheduling the scheduler is invoked when any of several things occur: A timer interrupt occurs, for example at a jiffy interval. An I/O interrupt occurs. An operating system service is invoked. A task attempts to acquire a mutex. A task tests a semaphore. For interrupts, the scheduling procedure is called by the interrupt service routine In the other cases, the scheduling procedure is called by the operating system procedure that provides the service

8 RM – Rate monotonic Static priority protocol
optimal with respect to feasibility among fixed priority uniprocessor schedulers for the above task model. This scheduling strategy gives higher priority to a task with a smaller period Cannot always achieve 100% utilization. In particular, RM schedulers are constrained to have fixed priority.

9 RM schedule for two tasks

10 RM Schedule Consider two tasks to be executed periodically on a single processor, where task 1 has period p1 = 4 and task 2 has period p2 = 6. Let the execution time of task 1 be e1 = 1. Find the maximum value for the execution time e2 of task 2 such that the RM schedule is feasible. Again let the execution time of task 1 be e1 = 1. Let non-RMS be a fixed-priority schedule that is not an RM schedule. Find the maximum value for the execution time e2 of task 2 such that non-RMS is feasible.

11 EDF simply executes the tasks in the same order as their deadlines, with the one with the earliest deadline going first dynamic priority scheduling algorithm. If a task is repeatedly executed, it may be assigned a different priority on each execution EDF is more expensive to implement than RM, in practice its performance is generally superior First, RM is optimal with respect to feasibility only among fixed priority schedulers, whereas EDF is optimal w.r.t. feasibility among dynamic priority schedulers EDF also minimizes the maximum lateness EDF results in fewer preemptions

12 Priority inversion It is a scheduling anomaly where a high-priority task is blocked while unrelated lower-priority tasks are executing

13 Mars Pathfinder: The Problem
Two tasks were critical for controlling communication on the lander’s communication bus, the scheduler task (bc_sched) and the distribution task (bc_dist). Each of these tasks checked each cycle to be sure that the other had run successfully. time = s bc_sched bc_dist bus active

14 Mars Pathfinder: The problem
bc_dist was blocked by a much lower priority meteorological science task (ASI/MET) ASI/MET was preempted by several medium priority processes such as accelerometers and radar altimeters. bc_sched started and discovered that bc_dist had not completed. Under these circumstances, bc_sched reacted by reinitializing the lander’s hardware and software and terminating all ground command activities.

15 Problem resolution Logging designed into vxWorks enabled NASA and Wind River to reproduce the failure on Earth. This reproduction made the priority inversion obvious. NASA patched the lander’s software to enable priority inheritance.

16 Priority Inheritance protocol
when a task blocks attempting to acquire a lock, then the task that holds the lock inherits the priority of the blocked task

17 Priority ceiling Protocol
every lock or semaphore is assigned a priority ceiling equal to the priority of the highest-priority task that can lock it. A task t can acquire a lock a only if the task’s priority is strictly higher than the priority ceilings of all locks currently held by other tasks

18 Multiprocessor scheduling
Scheduling tasks on multiple processor is even harder then scheduling tasks on a single scheduler Hu level scheduling algorithm Assigns priority to each task t based on the level it emphasizes the path through the precedence graph with the greatest total execution time Once priorities are assigned to tasks, a list scheduler sorts the tasks by priorities and assigns them to processors in the order of the sorted list as processors become available

19 Multiprocessor scheduling
A schedule for task 1-6 on two processors Makespan is 4

20 Scheduling anomalies Unexpected or counterintuitive behaviors emerge due to small changes in the operating condition of a system Improvements in performance at a local level can result in degradations in performance at a global level,

21 Scheduling anomalies Nine tasks scheduled on three processors
Execution time of tasks reduced by one time unit

22 Scheduling anomalies Adding one more processor
Removing precedence between tasks 4,7, and 8

23 Scheduling anomalies Anomaly due to mutual exclusion locks
Tasks 2 and 4 contend for a mutex. If the execution time of task 1 is reduced, then the order of execution of tasks 2 and 4 reverses, which results in an increased execution time.


Download ppt "REAL TIME SYSTEM Scheduling."

Similar presentations


Ads by Google