Integrated Control and Scheduling James Yang, Steve Sheng, Bill Li Instructor: Prof. Insup Lee Outline • • • • Motivation Periodic scheduling Control Concepts Robust scheduling Motivation • Misunderstanding between control and scheduling communities – C: computer platforms provide deterministic, fixed sampling period – S: control tasks have: • fixed periods • hard deadlines • known worst-case execution times (WCETs) The Vision • Dynamic, flexible, interactive integrated control and scheduling environment – Control performance vs. computing resource – Relax known WCET • On-line information exchange – Desired period of control task – Nominal execution time – Desired deadline Delete,Real-Time Scheduling • Concept about task – Periodic, sporadic, aperiodic – Worst case CPU time C, deadline D • Scheduling of CPU time for periodic tasks – Static cyclic executive scheduling • Off-line to generate execution table – Priority-based scheduling • Assumption: Di=Ti, no communication, ideal kernel • Earliest deadline first(EDF) • Rate-monotonic(RM) Periodic Task Scheduling • EDF – If U<=1, then all deadlines will be met – Processor fully utilized with deadlines met • RM – – – – Tasks with shorter period get higher priority If U<=n(2^1/n-1) Iff Ri<Di for all tasks Bad performance when Di<<Ti Implementation and Scheduling of Periodic Control Loops • What is control loop? – Three parts: data collection, algorithm computation, output transmission – Periodical in most cases • Implementation – Single-task approach – Multiple-task approach Loop Timing Constrains sample control period sample control latency • The period should be constant • Input-output latency – Decrease stability, limits performance – Ignore if minimized, otherwise be considered Single-task Implementation LOOP Await clock interrupt Data collection Algorithm calculation Output transmission END CurrentTime(t) LOOP Data collection Algorithm calculation Output transmission t = t+h WaitUntil(t) END Control Delay • Separate algorithm calculation – Calculate output: make use of current sample information – Update state: update controller states CurrentTime(t) LOOP Data collection calculate output Output transmission update state t = t+h WaitUntil(t) END Timing Requirement • Data collection: same instant every period • Calculate output: ASA sample available • Output transmission: immediately after CO, or at fixed instant after data collection • Update state: before next period, or before release of next “calculate output” Scheduling of Control Tasks • Fixed-priority scheduling – Describe controller as period tasks – Rate-monotonic is optimal if D=T – Deadline-monotonic is optimal if D<=T, used to improve important long period control tasks Deadline Assignment • Period T and execution time C are known • Deadlines D must be assigned, optimal deadline assignment is NP-hard • Effective-deadline-monotonic assignment – Later subtasks given just enough time Dij=Di-Sum[j+1<=k<=ni]Cik Scheduling Under Overload Conditions • Relaxation of known worst-case execution time – Treat longer-than-worst actual execution time as overload conditions – Algorithm: associate positive value with task • Complete the most important tasks • Avoid domino effect Robust Aperiodic Scheduling • Real-time systems should handle – Periodic tasks • Hard deadlines – Aperiodic tasks—irregular arrival times • Soft deadlines – minimize average response time • Firm deadlines – Reject tasks going to be late – Maximize completed tasks – Maximize system value Assumptions • All periodic tasks have hard deadlines, known constant period and WCET • Arrival time of aperiodic tasks is unknown • WCET of aperiodicities is known on arrival • Aperiodicities have firm deadlines and can be rejected Terminology • J: a set of aperiodic Ji ordered by deadline • ri:arrival time of Ji • Ci:max computation time of Ji • Ci’:actual computation time of Ji • di:deadline of Ji • mi:deadline tolerance • vi:task value(relative importance) • fi:finishing time • Ei:exceeding time Total Bandwidth Algorithm • Assign a suitable deadline – dk=max(rk, dk-1)+Ck/Us – d0=0 • Schedule it as periodic tasks TB Algorithm: Example Resource Reclaiming • TB behavior depends on est. max time – What if the value is overestimated? • Correct the assigned deadlines – di=ri’+Ci/Us – ri’=max(ri, d’i-1, fi-1) – At task completion, di’=ri’+Ci’/US Resource Reclaiming: example Schedulability • Theorem: given a set n of periodic tasks with Up and a TB server with Us, the whole set is schedulable iff Up+Us<=1 • Lemma: in [t1,t2], if Cape is the total execution time of aperiodic tasks, then Cape<=(t2-t1)Us Robust Scheduling What if overload? – Assign large bandwidth to server – Introduce overload awareness • RED algorithm