Non-Preemptive and Limited Preemptive Scheduling. LS 12, TU Dortmund

Similar documents
Schedulability and Optimization Analysis for Non-Preemptive Static Priority Scheduling Based on Task Utilization and Blocking Factors

Lecture 13. Real-Time Scheduling. Daniel Kästner AbsInt GmbH 2013

Non-Work-Conserving Non-Preemptive Scheduling: Motivations, Challenges, and Potential Solutions

Multiprocessor Scheduling II: Global Scheduling. LS 12, TU Dortmund

Scheduling Periodic Real-Time Tasks on Uniprocessor Systems. LS 12, TU Dortmund

Real-Time Scheduling and Resource Management

Embedded Systems Development

Task Models and Scheduling

Embedded Systems 15. REVIEW: Aperiodic scheduling. C i J i 0 a i s i f i d i

Real-Time Systems. Lecture #14. Risat Pathan. Department of Computer Science and Engineering Chalmers University of Technology

Aperiodic Task Scheduling

Bounding the Maximum Length of Non-Preemptive Regions Under Fixed Priority Scheduling

Non-preemptive Fixed Priority Scheduling of Hard Real-Time Periodic Tasks

EDF Scheduling. Giuseppe Lipari May 11, Scuola Superiore Sant Anna Pisa

Exact speedup factors and sub-optimality for non-preemptive scheduling

Embedded Systems 14. Overview of embedded systems design

RUN-TIME EFFICIENT FEASIBILITY ANALYSIS OF UNI-PROCESSOR SYSTEMS WITH STATIC PRIORITIES

arxiv: v3 [cs.ds] 23 Sep 2016

EDF Scheduling. Giuseppe Lipari CRIStAL - Université de Lille 1. October 4, 2015

Networked Embedded Systems WS 2016/17

Real-Time Systems. Event-Driven Scheduling

Real-Time Systems. Event-Driven Scheduling

Lecture 6. Real-Time Systems. Dynamic Priority Scheduling

Probabilistic Preemption Control using Frequency Scaling for Sporadic Real-time Tasks

Clock-driven scheduling

arxiv: v1 [cs.os] 28 Feb 2018

CIS 4930/6930: Principles of Cyber-Physical Systems

3. Scheduling issues. Common approaches 3. Common approaches 1. Preemption vs. non preemption. Common approaches 2. Further definitions

Schedulability of Periodic and Sporadic Task Sets on Uniprocessor Systems

Real-Time Scheduling. Real Time Operating Systems and Middleware. Luca Abeni

Multiprocessor Scheduling I: Partitioned Scheduling. LS 12, TU Dortmund

System Model. Real-Time systems. Giuseppe Lipari. Scuola Superiore Sant Anna Pisa -Italy

There are three priority driven approaches that we will look at

2.1 Task and Scheduling Model. 2.2 Definitions and Schedulability Guarantees

Real-time Scheduling of Periodic Tasks (2) Advanced Operating Systems Lecture 3

Real-Time Workload Models with Efficient Analysis

Worst-case response time analysis of real-time tasks under fixed-priority scheduling with deferred preemption revisited

Mixed Criticality in Safety-Critical Systems. LS 12, TU Dortmund

Static priority scheduling

Design and Analysis of Time-Critical Systems Response-time Analysis with a Focus on Shared Resources

Supplement of Improvement of Real-Time Multi-Core Schedulability with Forced Non- Preemption

Real-Time and Embedded Systems (M) Lecture 5

Scheduling Slack Time in Fixed Priority Pre-emptive Systems

A Note on Modeling Self-Suspending Time as Blocking Time in Real-Time Systems

Andrew Morton University of Waterloo Canada

Real-time operating systems course. 6 Definitions Non real-time scheduling algorithms Real-time scheduling algorithm

Schedulability Analysis for the Abort-and-Restart Model

EDF Feasibility and Hardware Accelerators

Controlling Preemption for Better Schedulability in Multi-Core Systems

Dependency Graph Approach for Multiprocessor Real-Time Synchronization. TU Dortmund, Germany

Real-Time Scheduling

Paper Presentation. Amo Guangmo Tong. University of Taxes at Dallas January 24, 2014

Paper Presentation. Amo Guangmo Tong. University of Taxes at Dallas February 11, 2014

Scheduling Algorithms for Multiprogramming in a Hard Realtime Environment

Tardiness Bounds under Global EDF Scheduling on a. Multiprocessor

Segment-Fixed Priority Scheduling for Self-Suspending Real-Time Tasks

Improved Priority Assignment for the Abort-and-Restart (AR) Model

Schedulability analysis of global Deadline-Monotonic scheduling

Uniprocessor real-time scheduling

An Improved Schedulability Test for Uniprocessor. Periodic Task Systems

Cache-Aware Compositional Analysis of Real- Time Multicore Virtualization Platforms

TDDB68 Concurrent programming and operating systems. Lecture: CPU Scheduling II

Rate Monotonic Analysis (RMA)

Analysis and Implementation of Global Preemptive Fixed-Priority Scheduling with Dynamic Cache Allocation*

Real-Time Systems. LS 12, TU Dortmund

Bursty-Interference Analysis Techniques for. Analyzing Complex Real-Time Task Models

Load Regulating Algorithm for Static-Priority Task Scheduling on Multiprocessors

CSE 380 Computer Operating Systems

Online Scheduling Switch for Maintaining Data Freshness in Flexible Real-Time Systems

Mitra Nasri* Morteza Mohaqeqi Gerhard Fohler

CEC 450 Real-Time Systems

Module 5: CPU Scheduling

Tardiness Bounds under Global EDF Scheduling on a Multiprocessor

Rate-monotonic scheduling on uniform multiprocessors

Chapter 6: CPU Scheduling

A Response-Time Analysis for Non-preemptive Job Sets under Global Scheduling

Lec. 7: Real-Time Scheduling

Many suspensions, many problems: a review of self-suspending tasks in real-time systems

Priority-driven Scheduling of Periodic Tasks (1) Advanced Operating Systems (M) Lecture 4

Real-time Scheduling of Periodic Tasks (1) Advanced Operating Systems Lecture 2

A Dynamic Real-time Scheduling Algorithm for Reduced Energy Consumption

Lecture: Workload Models (Advanced Topic)

Optimal Utilization Bounds for the Fixed-priority Scheduling of Periodic Task Systems on Identical Multiprocessors. Sanjoy K.

Bounding the End-to-End Response Times of Tasks in a Distributed. Real-Time System Using the Direct Synchronization Protocol.

The Partitioned Dynamic-priority Scheduling of Sporadic Task Systems

EDF and RM Multiprocessor Scheduling Algorithms: Survey and Performance Evaluation

Contention-Free Executions for Real-Time Multiprocessor Scheduling

The preemptive uniprocessor scheduling of mixed-criticality implicit-deadline sporadic task systems

Laxity dynamics and LLF schedulability analysis on multiprocessor platforms

Schedulability Analysis of the Linux Push and Pull Scheduler with Arbitrary Processor Affinities

Shared resources. Sistemi in tempo reale. Giuseppe Lipari. Scuola Superiore Sant Anna Pisa -Italy

Process Scheduling for RTS. RTS Scheduling Approach. Cyclic Executive Approach

Spare CASH: Reclaiming Holes to Minimize Aperiodic Response Times in a Firm Real-Time Environment

TDDI04, K. Arvidsson, IDA, Linköpings universitet CPU Scheduling. Overview: CPU Scheduling. [SGG7] Chapter 5. Basic Concepts.

Scheduling Lecture 1: Scheduling on One Machine

EECS 571 Principles of Real-Time Embedded Systems. Lecture Note #7: More on Uniprocessor Scheduling

A New Sufficient Feasibility Test for Asynchronous Real-Time Periodic Task Sets

arxiv: v1 [cs.os] 6 Jun 2013

Preemption points placement for sporadic task sets

PASS: Priority Assignment of Real-Time Tasks with Dynamic Suspending Behavior under Fixed-Priority Scheduling

Transcription:

Non-Preemptive and Limited Preemptive Scheduling LS 12, TU Dortmund 09 May 2017 (LS 12, TU Dortmund) 1 / 31

Outline Non-Preemptive Scheduling A General View Exact Schedulability Test Pessimistic Schedulability Tests Limited Preemptive Scheduling (LS 12, TU Dortmund) 2 / 31

Advantage of Preemption Preemption is often seen as a key factor in real-time scheduling Preemption allows to allocate the processor to incoming high priority tasks nearly immediately High priority tasks are not blocked by low priority tasks τ 1 Preemptive τ 2 τ 1 Non Preemptive τ 2 τ 2 blocks τ 1 Deadline Miss (LS 12, TU Dortmund) 3 / 31

Disadvantage of Preemption - Context Switch Costs Context switch introduces overhead to the system: Scheduling costs: Time the scheduling Algorithm needs to suspend the running task, insert it into the ready queue, switch the context, dispatch the new incoming task Pipeline costs: Time to flush and refill the processor pipeline Cache-related costs: Time to reload the evicted cache lines Bus-related costs: Additional bus interference for accessing RAM at cache misses caused by preemption τ τ 2 blocks τ 1 1 Non Preemptive τ 2 Non preemptive WCET C NP i τ 1 Preemptive Additional preemption overhead C2 PO τ 2 Deadline Miss (LS 12, TU Dortmund) 4 / 31

Calculating The Preemption Overhead Essential for real-time systems: good estimation of WCETs WCET normally determined for non-preemptive case: Ci NP Time the processor needs to execute without interruptions Idea: add preemption costs to preempted tasks WCET Costs for one preemption Ci PO has to be estimated Summing up all context switch costs Problem: especially the cache related and bus related costs can change drastically depending on the preemption point The number of preemptions p has to be estimated Depends on the higher priority tasks Ensure the estimated number is safe: p est p But not much over estimation Preemptive WCET: C P = C NP i i + p est C PO i Indirect preemption costs: the extra execution time also increases the number of preemptions It is hard to determine a good WCET (safe but not much over estimation) for the preemptive case (LS 12, TU Dortmund) 5 / 31

Advantages of Non-Preemptive Scheduling It reduces context-switch overhead Making WCETs smaller easier to calculate / more predictable It simplifies the access to shared resources No semaphores are needed for critical sections Deadlock prevention is trivial for non-preemptive scheduling It reduces stack size Task can share the same stack, since no more than one task can be in execution Preemption may be very costly or forbidden for some actions anyways, e.g. I/O Non-preemption allows zero I/O jitter: C i = f i a i (constant) (LS 12, TU Dortmund) 6 / 31

Advantages of Non-Preemptive Scheduling (contd) Also preemption is assumed to be a key factor for schedulability, there are some task sets that are schedulable in the non-preemptive case and not schedulable in the preemptive case, even when the preemption overhead is ignored: RM, τ 1 = (2, 5), τ 2 = (4, 7), U sum = 2 5 + 4 7 = 34 35 0.97 τ 1 Preemptive τ 2 Deadline Miss τ 1 Non Preemptive τ 2 (under the assumption that the arrival times of the jobs are integers) (LS 12, TU Dortmund) 7 / 31

Issues with Non-Preemptive Scheduling If preemption is not allowed, optimal schedules may have to leave the processor idle at certain times. Assume the following periodic constrained deadline task set: τ 1 : C 1 = 2, T 1 = 4, D 1 = 4, Φ 1 = 0 τ 2 : C 2 = 1, T 2 = 4, D 2 = 1, Φ 1 = 1 τ 1 is always available at 4 n and τ 2 always at 4 n + 1 τ 1 Idle Idle τ 2 Deadline Miss τ 2 meets Deadline (LS 12, TU Dortmund) 8 / 31

Hardness for Non-Preemptive Scheduling Optimal schedules may leave processor idle to finish tasks with early deadlines arriving late. Knowledge about the future is needed for optimal scheduling algorithms. No online algorithm can decide whether to keep idle or not. EDF is optimal among workload conserving scheduling algorithms, i.e., algorithms that due not keep the processor idle as long as there is workload to be executed. Recent proof by von der Brüggen, Chen and Huang (ECRTS 2015) shows that (non-preemptive) RM and DM has a resource augmentation factor 1.76322 compared to (non-preemptive) EDF for implicit-deadline and constrained-deadline sporadic task systems. Resource augmentation factors will be explained in a few weeks. Even if arrival times are known a priori, the scheduling problem is still NP-hard in the strong sense. (LS 12, TU Dortmund) 9 / 31

Outline Non-Preemptive Scheduling A General View Exact Schedulability Test Pessimistic Schedulability Tests Limited Preemptive Scheduling (LS 12, TU Dortmund) 10 / 31

Problem - Utilization For preemptive RM scheduling we got easy utilization based schedulability tests (Liu & Layland and Hyperbolic Bound) The utilization bound under non preemptive scheduling drops to zero τ 1 = (ε, T 1 ), τ 2 = (T 1, T 2 ), ε > 0 but very small If τ 2 starts right before τ 1 arrives, τ 1 always misses its deadline We can make ε > 0 arbitrary small and T 2 arbitrary large U sum = ε T 1 + T 1 T 2 = 0 T 1 + T 1 = 0 τ 1 Deadline Miss τ 2 (LS 12, TU Dortmund) 11 / 31

Problem - Self-Pushing Phenomenon Analysis of non-preemptive systems more complex: largest response time may not occur in the first job after the critical instant Definition: Self-Pushing Phenomenon High priority jobs activated during non-preemptive execution of lower priority tasks are pushed ahead and introduce higher delays in subsequent jobs of the same task. τ 1 = (3, 8) τ 2 = (3, 9) τ 3 = (3, 12) τ 4 = (2, 99) Deadline Miss Self-pushing phenomenon for τ 3 (LS 12, TU Dortmund) 12 / 31

General Response Time Analysis - Definitions Definition: hp(τ k ), lp(τ k ): hp(τ k ): set of tasks with priority higher than τ k lp(τ k ): set of tasks with priority lower than τ k Definition: Maximum Blocking Time B k : The maximum blocking time B k = where ε > 0 but arbirtrary small max {C i ε} τ i lp(τ k ) Informal: To determine if a task τ k is schedulable, we have to start at the critical instance and check all jobs of τ k until the processor idles for the first time by summing up the interference from τ i hp(τ k ) summing up the computation amount of previous jobs of τ k add the maximum blocking time B k from lower priority task (LS 12, TU Dortmund) 13 / 31

Formal Definition - Level-k Active Period Definition: Level-k Pending Workload W p k (t) The Level-k Pending Workload W p k (t) at time t is the amount of processing that still needs to be performed at time t due to jobs with priority higher than or equal to τ k released strictly before t Definition: Level-k Active Period A Level-k Active Period L k is an Interval [a, b) such that W p k (t) > 0 t (a, b) and W p k (t) = 0 for t = a and t = b Computing the longest Level-k Active Period: the smallest value where L (s) k = L (s 1) k with L (0) k = B k + C k L (s) k = B k + τ i {hp(τ k ) τ k } (s 1) L k C i T i (LS 12, TU Dortmund) 14 / 31

Exact Schedulability Test Due to Self-Pushing Phenomenon: compute the response time of all jobs τ k,j with j [1, K k ] where K k = Lk T k The start time s k,j of τ k,j can be computed recurrently as well: s (0) k,j = B k + τ i {hp(τ k ) τ k } s (s) k,j = B k + (j 1)C k + C i τ i hp(τ k ) s(s 1) k,j T i + 1 C i As non-preemptive scheduling is used, a job always finishes once it is started f k,j = s k,j + C k Response time of τ k : R k = max {f k,j (j 1)T k } j [1,K k ] A task set is feasible R i D i i = 1,..., n (LS 12, TU Dortmund) 15 / 31

Outline Non-Preemptive Scheduling A General View Exact Schedulability Test Pessimistic Schedulability Tests Limited Preemptive Scheduling (LS 12, TU Dortmund) 16 / 31

Restricting the Analysis to the First Job Due to Self-Pushing Phenomenon: For an exact test we have to test all jobs in the Level-k Active Period We can restrict to only looking at the first job under some (not to restrictive) conditions Theorem [Yao, Buttazzo, and Bertogna, 2010] The worst-case response time of a non-preemptive task occurs in the first job if the task is activated at its critical instant and the following two conditions are both satisfied: 1 the task set is feasible under preemptive scheduling; 2 the relative deadlines are less than or equal to periods. The recurrent relation to determine the start time in this case is: s (s) k,j = B k + C k + ( ) s (s 1) k,j τ i hp(τ k ) T i + 1 C i (LS 12, TU Dortmund) 17 / 31

A Pessimistic Schedulability Test When we restrict ourselves to the first task, we still get an exact test using the recurrent computation of the start time This test still has pseudo-polynomial runtime Idea: sacrifice some precision to get a sufficient but easier test From the theorem by Yao, Buttazzo, and Bertogna we know we have to consider schedulability in the preemptive case Exact schedulability test in the preemptive case: t with 0 < t D k and C k + t τ i hp(τ k ) T i C i t We get a more pessimistic test by testing schedulability for preemptive and non-preemptive in one equation: t with 0 < t D k and B k + C k + t C i t τ i hp(τ k ) T i (LS 12, TU Dortmund) 18 / 31

A Utilization Based Test Problem with utilization based tests for NP: Blocking time has to be taken into account for every task individually Every task has to be tested individually Theorem [Theorem 1 in von der Brüeggen, Chen, and Huang, 2015] A task τ k in a non-preemptive sporadic task system with constrained deadlines can be feasibly scheduled by a fixed-priority scheduling algorithm, if the schedulability for all higher priority tasks has already been ensured and the following condition holds: ( ) Ck + B k + 1 (U j + 1) 2 D k τ j hp(τ k ) If this holds τ k τ the hole task set is schedulable (LS 12, TU Dortmund) 19 / 31

Utilization Bounds for RM-NP General utilization bounds are not possible It is possible to define a utilization bound based on the ratio of the computation time of a task and its blocking time Theorem [Theorem 4 in von der Brüeggen, Chen, and Huang, 2015] { Suppose that γ = max τk {max Ci τi lp(τ k ) C k }}. A task set can be feasibly scheduled by RM-NP if { ( ) γ 1+γ U sum + ln 2 1+γ if γ 1 1 1+γ if γ > 1 (LS 12, TU Dortmund) 20 / 31

Utilization Bound for RM-NP Utilization Bound 0.7 0.65 0.6 0.55 0.5 0.45 0.4 0.35 0.3 Theorem 4 Andersson and Tovar 0.25 0 0.5 1 1.5 2 2.5 3 γ Figure: Comparison of the total { }} utilization bound of RM-NP with respect to γ = max τk {max Ci τi lp(τ k ) C k provided by Theorem 4 in [von der Brüeggen, Chen, and Huang, 2015] with previously known results (Andersson and Tovar, 2009). (LS 12, TU Dortmund) 21 / 31

A Tighter Utilization Based Test Theorem [Yao, Buttazzo, and Bertogna, 2010] The worst-case response time of a non-preemptive task occurs in the first job if the task is activated at its critical instant and the following two conditions are both satisfied: 1 the task set is feasible under preemptive scheduling; 2 the relative deadlines are less than or equal to periods. Testing preemptive and non-preemptive case schedulability is necessary to restrict testing to the first job Theorem 1 performs these in one single test We get tighter by doing two separated tests 1 non-preemptive case: t (0, D k C k ] with B k + k 1 t i=1 T i C i t 2 preemptive case: t (0, D k ] with C k + t τ i hp(τ k ) T i C i t (LS 12, TU Dortmund) 22 / 31

A Tighter Utilization Based Test (contd) Theorem [Theorem 6 in von der Brüeggen, Chen, and Huang, 2015] A task τ k is schedulable by a fixed priority non-preemptive scheduling algorithm A NP if all higher priority tasks are schedulable and the following two conditions hold: C i B k + τ i hp2 NP (τ k ) + 1 D k C k C k + C i τ i hp2 P(τ k) + 1 D k τ j hp NP 1 (τ k ) τ j hp P 1 (τ k) (U j + 1) 2 (U j + 1) 2 (LS 12, TU Dortmund) 23 / 31

A Tighter Utilization Bound for RM-NP Using Theorem 6 the utilization bound for Rate Monotonic Non-Preemptive Scheduling can be made a bit tighter. Theorem [Theorem 9 in von der Brüeggen, Chen, and Huang, 2015] { Suppose that γ = max τk {max Ci τi lp(τ k ) C k }}. A task set can be feasibly scheduled by RM-NP if { ln(2) 0.693 if γ 1 ln(2) ln(2) U sum 1 1+γ if γ > 1 ln(2) ln(2) (LS 12, TU Dortmund) 24 / 31

Utilization Bounds for RM-NP Utilization Bound 0.7 0.65 0.6 0.55 0.5 0.45 0.4 0.35 0.3 Theorem 9 Theorem 4 Andersson and Tovar 0.25 0 0.5 1 1.5 2 2.5 3 γ Figure: Comparison of the total { }} utilization bound of RM-NP with respect to γ = max τk {max Ci τi lp(τ k ) C k provided by Theorem 4 and Theorem 9 in [von der Brüeggen, Chen, and Huang, 2015] with previously known results (Andersson and Tovar, 2009). (LS 12, TU Dortmund) 25 / 31

Outline Non-Preemptive Scheduling A General View Exact Schedulability Test Pessimistic Schedulability Tests Limited Preemptive Scheduling (LS 12, TU Dortmund) 26 / 31

Types of Limited Preemption Problem: We want preemption to ensure high priority tasks meet their deadline but we want as few preemptions as possible Combine the advantages and disadvantages of preemptive and non-preemptive scheduling into limited preemptive scheduling Preemption Thresholds: Each task can be preempted only by tasks with priority higher than a specified threshold. Deferred Preemptions: Each task can defer its preemption up to a specified interval of time. Fixed Preemption Points: Each task can be preempted only at predefined points specified in the code by the programmer. (LS 12, TU Dortmund) 27 / 31

Preemption Thresholds Each task has two priorities P k : Nominal priority used to enqueue the task in the ready queue and to preempt other tasks Θ k : threshold priority used while task is execution. τ k can be preempted by τ i only if P i > Θ k Analysis has to be done in the longest Level-k busy period Response time analysis has to be done in two phases: Blocking time by tasks τ i lp(τ k ) with priority less than τ k but preemption threshold larger than τ k combined with Interference of higher priority tasks with P i > P k until τ k starts to determine the start time S k,j = B k + (j 1)C k + ( ) Sk,j T i + 1 C i τ i :P i >Θ k τ i hp(τ l ) Preemption of tasks with priority larger than the preemption threshold (P h > Θ i ) after the task started to determine the finish time f k,j = s k,j + C k + ( ( )) Ri Sk,j T i T i + 1 C i (LS 12, TU Dortmund) 28 / 31

Deferred Preemptions Each task can defer preemption up to q i if a task τ k with P k > P i wants to preempt τ i B k = max {q i} τ i lp(τ k ) Interesting problem: given a preemptively feasible task set, find the longest non-preemptive interval Q i for each task that still preserves schedulability High priority tasks often have Q i = C i, meaning that they can execute fully non preemptively To compute Q i, we need to find the maximum blocking time that can be tolerated by a task, called blocking tolerance β i Q i can be used to divide a task into non preemptive chunks of length no larger than Q i If all critical regions can be completely included in those non-preemptive chunks the access to shared resources is trivial (LS 12, TU Dortmund) 29 / 31

Fixed Preemption Points Each task τ i is divided in m i chunks q i,1,..., q 1,m The task can only be preempted between chunks B k = max τi lp(τ k ){q max i } Analysis must be carried out up the busy period of each task Preemption points are assumed to be given by the programmer If preemption points are chosen carefully preemption in critical region will not occur preemption overhead due to cache misses can be reduced, e.g. as preemption points will be placed outside loops stack size can be reduced (LS 12, TU Dortmund) 30 / 31

General Remarks Preemption Thresholds are easy to specify, but it is difficult to predict the number of preemptions and where they occur still possibly large preemption overhead Deferred Preemption allows bounding the number of preemptions but it is difficult to predict where they occur number of preemptions bounded overhead per preemption may still be high Fixed Preemption Points allow more control on preemptions and can be selected on purpose number of preemptions bounded overhead per preemption can be bounded if chosen carefully longest non preemptive interval Q i can be used to get an upper bound on the length of the non-preemptive chunks preemption in critical region will not occur if the preemption points are chosen carefully (LS 12, TU Dortmund) 31 / 31