17 - Scheduling (4)OutlineReal-Time SchedulingSchedulabilityReal-Time AlgorithmsRate Monotonic SchedulingEarliest Deadline FirstAnnouncementsReading:Real-Time SchedulingSchedulabilityRate Monotonic SchedulingEarliest Deadline FirstEvaluating Scheduling AlgorithmsTypical Situation:Scheduling Goals:Categories:Assumption:For task k:Tasks can be periodic or sporadicA set of periodic tasks is schedulable <==>A set of periodic tasks is schedulable<==> a feasible schedule exists(a schedule in which no task misses its deadline)periodic tasksis utilization of a single task kWhere:Is this system schedulable?If we can add a 4th task, what would its maximumallowable processing time be?Single-core CPU, periodic tasks.is Utilization in single-coreUtilization is written with differentvariables in the book:Release Time: earliest time task can beginProcessing Time: expected execution timeDeadline: time processing must finish byPeriod: time to next deadline = release timePA 3 instructions still pending a few things.currently due in 2 weeks (same day as midterm)PA 2 due today1)2)3)4)5)MOS 2.5-------- Patient vital monitoring- Aircraft controls (fly-by-wire)- Industrial automation controls-Physical device(s) generate eventsDeadlinesHard Real-Time: missed deadlines unacceptableSoftware is written specially for easy analysisTasks run regularly, for limited timeno malloc, no recursion - provable upper limits on resource usagesporadic = aperiodic, deadline not known until release.(not in this class)Task behavior is predictable and known in advanceSoft Real-Time: missed deadlines are tolerablePredictabilityComputer must react within fixed timeReacting too late can be as bad as not reacting!e.g.1005030100200500Variants:Fixed Priority - priorities are precomputedDynamic Priority - priorities are recomputed----------Cyclic Executive (nonpreemptive superloop)Earliest Deadline First (EDF)Least Laxity First (LLF)Simple algorithm, easy to implementLower schedulable utilization:Short period always preempts long period tasksDoes not account for next deadline!long period tasks delayed/preempted can cause missed deadlineslong period tasks often delayed/preempted can cause missed deadlinesUtility-based schedulingRate Monotonic (based on period)Deadline Monotonic (when deadline != period)Preemptive.Always run current task with shortest period.Advantages:Disadvantages:Example:Periods:Schedule:4135P1P1P1P2012345678910111213141516P2P2012345678910111213141516~ 0.83 for m=2~ 0.69 for large mLiu & Layland 1973Preemptive.Dynamic PriorityAlways run task with earliest deadline relative tocurrent time.Example:Periods:Schedule:4135P1P1P2P2012345678910111213141516P1P2012345678910111213141516-------------Optimal: Minimizes maximum latenessRequires known worst-case execution timeCollect process behavior data from real usersStochastic models of process behaviorBuild the thing and do incremental rolloutCollect user feedback and iterateVery slow to modify things...Model accuracy is difficult...Compare algorithm performance on samplesCommon research methodology,but representative sampling is very difficult...Unschedulable tasks are less predictableRepresenting deadlines in hardware non-trivial(dealing with integer overflow?)Advantages:Disadvantages:whereGuaranteed to hit all deadlines when:> set of tasks is schedulable> deadline = start of next periodLinux EDF implementation:How do you choose a scheduling algorithm?Need performance data to compare...Deterministic Modeling:Queuing Models:Implementation:A very good read:SCHED_DEADLINEtontinton - Scheduling InternalsEvaluating Scheduling AlgorithmsExercise:PollEvA) YesB) No