AN EXTENDIBLE APPROACH FOR ANALYSING FIXED PRIORITY HARD REAL-TIME TASKS

Similar documents
Real-Time Systems. Multiprocessor scheduling. Multiprocessor scheduling. Multiprocessor scheduling

Embedded Systems. 4. Aperiodic and Periodic Tasks

Last Time. Priority-based scheduling. Schedulable utilization Rate monotonic rule: Keep utilization below 69% Static priorities Dynamic priorities

Module 9. Lecture 6. Duality in Assignment Problems

Quantifying the Sub-optimality of Uniprocessor Fixed Priority Pre-emptive Scheduling for Sporadic Tasksets with Arbitrary Deadlines

Two Methods to Release a New Real-time Task

Improved Worst-Case Response-Time Calculations by Upper-Bound Conditions

Scheduling Motivation

Computer Control: Task Synchronisation in Dynamic Priority Scheduling

Problem Set 9 Solutions

Clock-Driven Scheduling (in-depth) Cyclic Schedules: General Structure

Quantifying the Sub-optimality of Uniprocessor Fixed Priority Non-Pre-emptive Scheduling

The optimal delay of the second test is therefore approximately 210 hours earlier than =2.

Keynote: RTNS Getting ones priorities right

Outline. Communication. Bellman Ford Algorithm. Bellman Ford Example. Bellman Ford Shortest Path [1]

Improving the Sensitivity of Deadlines with a Specific Asynchronous Scenario for Harmonic Periodic Tasks scheduled by FP

EEL 6266 Power System Operation and Control. Chapter 3 Economic Dispatch Using Dynamic Programming

College of Computer & Information Science Fall 2009 Northeastern University 20 October 2009

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

MMA and GCMMA two methods for nonlinear optimization

Structure and Drive Paul A. Jensen Copyright July 20, 2003

Limited Preemptive Scheduling for Real-Time Systems: a Survey

Appendix B: Resampling Algorithms

Resource Allocation with a Budget Constraint for Computing Independent Tasks in the Cloud

Fixed-Priority Multiprocessor Scheduling with Liu & Layland s Utilization Bound

Resource Sharing. CSCE 990: Real-Time Systems. Steve Goddard. Resources & Resource Access Control (Chapter 8 of Liu)

NP-Completeness : Proofs

Simultaneous Optimization of Berth Allocation, Quay Crane Assignment and Quay Crane Scheduling Problems in Container Terminals

More metrics on cartesian products

Graph Reconstruction by Permutations

Difference Equations

Foundations of Arithmetic

U.C. Berkeley CS294: Spectral Methods and Expanders Handout 8 Luca Trevisan February 17, 2016

Single-Facility Scheduling over Long Time Horizons by Logic-based Benders Decomposition

Fixed-Priority Multiprocessor Scheduling with Liu & Layland s Utilization Bound

Common loop optimizations. Example to improve locality. Why Dependence Analysis. Data Dependence in Loops. Goal is to find best schedule:

Lecture 4: November 17, Part 1 Single Buffer Management

5 The Rational Canonical Form

Real-Time Operating Systems M. 11. Real-Time: Periodic Task Scheduling

CHAPTER 17 Amortized Analysis

Chapter Newton s Method

ELASTIC WAVE PROPAGATION IN A CONTINUOUS MEDIUM

THE SUMMATION NOTATION Ʃ

Chapter - 2. Distribution System Power Flow Analysis

Global EDF Scheduling for Parallel Real-Time Tasks

2E Pattern Recognition Solutions to Introduction to Pattern Recognition, Chapter 2: Bayesian pattern classification

Turing Machines (intro)

Equilibrium Analysis of the M/G/1 Queue

A Simple Inventory System

Grover s Algorithm + Quantum Zeno Effect + Vaidman

Lecture Notes on Linear Regression

Lecture 12: Discrete Laplacian

Analysis of Discrete Time Queues (Section 4.6)

The Order Relation and Trace Inequalities for. Hermitian Operators

ECE559VV Project Report

EDF Scheduling for Identical Multiprocessor Systems

Finding Primitive Roots Pseudo-Deterministically

The Minimum Universal Cost Flow in an Infeasible Flow Network

Case A. P k = Ni ( 2L i k 1 ) + (# big cells) 10d 2 P k.

Chapter 5. Solution of System of Linear Equations. Module No. 6. Solution of Inconsistent and Ill Conditioned Systems

= z 20 z n. (k 20) + 4 z k = 4

CONTRAST ENHANCEMENT FOR MIMIMUM MEAN BRIGHTNESS ERROR FROM HISTOGRAM PARTITIONING INTRODUCTION

Suggested solutions for the exam in SF2863 Systems Engineering. June 12,

3.1 Expectation of Functions of Several Random Variables. )' be a k-dimensional discrete or continuous random vector, with joint PMF p (, E X E X1 E X

Economics 101. Lecture 4 - Equilibrium and Efficiency

Section 8.3 Polar Form of Complex Numbers

Inner Product. Euclidean Space. Orthonormal Basis. Orthogonal

Assortment Optimization under MNL

CS 770G - Parallel Algorithms in Scientific Computing

Lecture 14: Bandits with Budget Constraints

The Study of Teaching-learning-based Optimization Algorithm

Lecture 8: Time & Clocks. CDK: Sections TVS: Sections

Remarks on the Properties of a Quasi-Fibonacci-like Polynomial Sequence

Improving the Quality of Control of Periodic Tasks Scheduled by FP with an Asynchronous Approach

O-line Temporary Tasks Assignment. Abstract. In this paper we consider the temporary tasks assignment

12. The Hamilton-Jacobi Equation Michael Fowler

Critical sections. Using semaphores. Using semaphores. Using semaphores. How long is blocking time? 17/10/2016. Problems caused by mutual exclusion

LINEAR REGRESSION ANALYSIS. MODULE IX Lecture Multicollinearity

princeton univ. F 17 cos 521: Advanced Algorithm Design Lecture 7: LP Duality Lecturer: Matt Weinberg

Compilers. Spring term. Alfonso Ortega: Enrique Alfonseca: Chapter 4: Syntactic analysis

DUE: WEDS FEB 21ST 2018

A 2D Bounded Linear Program (H,c) 2D Linear Programming

CONJUGACY IN THOMPSON S GROUP F. 1. Introduction

Tracking with Kalman Filter

SINGLE EVENTS, TIME SERIES ANALYSIS, AND PLANETARY MOTION

The lower and upper bounds on Perron root of nonnegative irreducible matrices

Quantifying the Exact Sub-Optimality of Non-Preemptive Scheduling

On the Interval Zoro Symmetric Single-step Procedure for Simultaneous Finding of Polynomial Zeros

Mixed-Criticality Scheduling with I/O

Parametric Utilization Bounds for Fixed-Priority Multiprocessor Scheduling

Feature Selection: Part 1

Two-Phase Low-Energy N-Modular Redundancy for Hard Real-Time Multi-Core Systems

On the Repeating Group Finding Problem

2.3 Nilpotent endomorphisms

Using non-preemptive regions and path modification to improve schedulability of real-time traffic over priority-based NoCs

A New Refinement of Jacobi Method for Solution of Linear System Equations AX=b

Overhead-Aware Compositional Analysis of Real-Time Systems

find (x): given element x, return the canonical element of the set containing x;

COMPARISON OF SOME RELIABILITY CHARACTERISTICS BETWEEN REDUNDANT SYSTEMS REQUIRING SUPPORTING UNITS FOR THEIR OPERATIONS

Time-Varying Systems and Computations Lecture 6

Transcription:

AN EXENDIBLE APPROACH FOR ANALYSING FIXED PRIORIY HARD REAL-IME ASKS K. W. ndell 1 Department of Computer Scence, Unversty of York, England YO1 5DD ABSRAC As the real-tme computng ndustry moves away from statc cyclc executve-based schedulng towards more flexble process-based schedulng, so t s mportant for current schedulng analyss technques to advance and to address more realstc applcaton areas. hs paper extends the current analyss assocated wth statc prorty pre-emptve based schedulng; n partcular t derves analyss for tasks wth arbtrary deadlnes that may suffer release tter due to beng dspatched by a tck drven scheduler. We also consder bursty sporadc actvtes, where tasks arrve sporadcally but then execute perodcally for some bounded tme. he paper llustrates how a wndow-based analyss technque can be used to fnd the worst-case response tme of a task set, and shows that the technque can be easly extended to cope wth realstc and complex task characterstcs. 1. INRODUCION One commonly proposed way of constructng a hard real-tme system s to buld the system from a number of sporadc and perodc tasks, each assgned statc prortes, and dspatched at run-tme accordng to the statc prorty pre-emptve schedulng algorthm. he man thrust of research wth ths approach has been to derve a pror analyss that can bound the behavour of the tasks at run-tme. Orgnal work by Lu and Layland [11] provdes a pror analyss to determne f a set of perodc tasks would be guaranteed to meet ther deadlnes. ask deadlnes are taken to be at the end of the perods of the tasks, and tasks are not permtted to block at run-tme. Furthermore, each task s assgned a unque prorty monotoncally wth task perod, and hence the name rate monotonc schedulng. he analyss provdes a schedulablty test by gvng a utlsaton bound. he Lu and Layland analyss s suffcent (an essental property of any schedulablty test f the test passes a set of tasks then those tasks must always meet ther deadlnes) but not necessary (a measure of the effcency of the test f the test s necessary then a reected task set wll be unschedulable n the worst-case); Sha et al [9] extended the analyss to provde an exact test (.e. both suffcent and necessary). Sha et al [15] derved a run-tme algorthm to permt tasks to lock and unlock semaphores accordng to a protocol, termed the prorty celng protocol. Wth ths protocol a system s guaranteed to be free of deadlock (on sngle processor systems), and a gven task can be blocked at most once by a lower prorty task. Sha et al extended the rate monotonc analyss to account for the behavour of ths protocol, addng a blockng factor to the schedulablty equatons (the blockng factor accounts for the worst-case tme a gven task can be blocked). he prorty pre-emptve dspatchng algorthm has also been analysed by Joseph and Pandya [5] to fnd the worst-case response tme of a gven task. Analyss s derved that fnds the worst-case tme between a task beng released (.e. placed n a notonal prorty-ordered run-queue) and the task completng the executon of a worst-case requred computaton tme. hs permts task deadlnes to be less than task perods: the worst-case response tme can be compared to a statc deadlne. he optmal prorty orderng for tasks wth deadlnes less than perods has been shown to be the deadlne monotonc orderng [10]. Allowng task deadlnes to be less than task perods s useful for many real-tme applcatons: n dstrbuted systems deadlnes can be shortened to allow tme for messages to pass between processors [17]; for control systems nput and output tter can be controlled [12]. However, some real-tme applcatons are not so strngent, and can accept task deadlnes greater than task perods: a task s permtted to re-arrve before the prevous nvocaton has fnshed (and s then delayed untl the prevous nvocaton termnates). Lehoczky [8] descrbes qualtatve analyss whch can determne the worst-case response tme of a gven task wth such arbtrary deadlnes. Lehoczky ponts out that nether the rate monotonc 1 he author can be contacted by e-mal at ken@mnster.york.ac.uk 1

nor deadlne monotonc prorty orderng polces are optmal for tasks wth arbtrary deadlnes. We wll reproduce here an algorthm whch fnds the optmal prorty orderng for any task set. Many statc prorty pre-emptve dspatchers are mplemented usng tck schedulng a perodc clock nterrupt runs the scheduler; a budget tmer ensures that control s returned to the scheduler f a task exceeds ts permtted worst-case executon tme. One of the problems wth pure tck schedulng s that sporadc task arrvals are polled by the scheduler, whch means that a sporadc task can arrve (.e. want to run) but be delayed before beng released. It s then possble that ths leads to so-called release tter: varablty n the release of a task (by at most the tck perod). Perodc tasks whch have a perod that s not an nteger multple of the tck perod can also n general suffer a release tter. hs release tter leads to the possblty of a task appearng to arrve sooner than the worst-case nter-arrval tme, and volates the assumptons of current analyss. Rakumar [14] extends the exact rate monotonc analyss of Lehoczky et al [9] to permt tasks to be blocked on an external event (release tter s a specal case of external blockng) n order to permt the prorty celng protocol to be extended to dstrbuted systems. However, these extensons result n a non-exact test; we wll derve exact analyss whch accounts for release tter. Some real-tme systems have tasks that behave as so-called sporadcally perodc tasks [2]: a task arrves at some tme, executes perodcally for a bounded number of perods (called nner perods), and then does not re-arrve for a larger tme (called the outer perod). Examples of such tasks are nterrupt handlers for bursty nterrupts (for example, packet arrvals from a communcatons devce), or certan montorng tasks. Exstng analyss s not exact (and hence pessmstc) for these tasks: tasks would be assumed to execute contnuously at ther nner perod rate. We wll derve exact analyss for tasks wth ths behavour. hs paper wll derve analyss for statc prorty pre-emptve systems that permts tasks to have arbtrary deadlnes, release tter, and behave as sporadcally perodc tasks. he dervaton of ths analyss wll llustrate how usng a wndow approach to fndng worst-case response tmes for these tasks s an approprate way of obtanng an analyss talored to the behavour of real real-tme tasks. hs approach s easly extended to deal wth other applcaton characterstcs. he paper s structured as follows: Secton 2 wll descrbe the computatonal model assumed throughout ths paper, and defne the notaton used. Secton 3 wll derve basc analyss from that of Joseph and Pandya and extend t to permt arbtrary deadlnes, usng the approach of Lehoczky. Secton 4 wll extend the analyss to permt release tter to be accounted for. Secton 5 wll further extend the analyss to be exact for sporadcally perodc tasks. Secton 6 wll also dscuss the mplementaton of statc prorty pre-emptve dspatchng usng tmer nterrupts (.e. tck schedulng); the analyss wll be extended to exactly account for the overheads due to ths means of schedulng. Secton 7 wll gve an algorthm to fnd the optmal prorty orderng for a task set. Secton 8 wll summarse the schedulng theory developed. Secton 9 wll present an example task set and determne the worst-case response tmes of each task n the set. Appendx A gves a table of notaton used n ths paper. Appendx B gves detals on how a program mplementng the analyss descrbed n ths paper can be obtaned. 2. COMPUAIONAL MODEL AND ASSUMPIONS A number of tasks are statcally assgned to a sngle processor. asks have unque prortes; the run-tme system provdes pre-emptve prorty-based dspatchng. Each task may lock and unlock semaphores accordng to the prorty celng protocol [15] (or equvalent [3]); although tasks are assgned unque statc prortes, they may have ther prortes temporarly ncreased due to prorty nhertance (as part of the operaton of the prorty celng protocol). asks can arrve at any tme (.e. want to run), but can be delayed for a varable but bounded amount of tme (termed the release tter) before beng placed n a notonal prorty-ordered run-queue (.e. released). asks are gven a worst-case nterarrval tme, termed the perod (): a task cannot re-arrve sooner than ths tme. For each arrval a task may execute a bounded amount of computaton, termed the worst-case executon tme (C). hs value s deemed to contan the overheads due to context swtchng. he cost of pre-empton, wthn the model, s thus assumed to be zero. he worst-case response tme of a task (r) s the longest tme ever taken by that task from the tme t arrves untl the tme t completes ts requred computaton. If a task has a worst-case response tme greater than ts perod then the possblty exsts for a task to re-arrve before the prevous nvocaton has completed. here are two ways of dealng wth ths 2

stuaton: the prevous nvocaton s deemed to have a lower prorty than the new arrval, and the new arrval pre-empts the old, or the new arrval s deemed to have a lower prorty, and s therefore delayed from executng untl after the prevous nvocaton termnates. We adopt the latter approach for several reasons: the mplementaton of ths approach s easer, snce the run-tme system does not have to support concurrent threads of the same task. Also, t makes lttle sense to have a task processng an event earler n tme delayed by the processng of a later one; a general rule n real-tme systems s to preserve the order of events. Fnally, the worst-case response tme bounds derved are n general lower than those found f an earler nvocaton s pre-empted. Sporadcally perodc tasks are assgned two perods: the nner perod (t) and the outer perod (). he outer perod s the worst-case nter-arrval tme between bursts ; the nner perod s the worst-case nter-arrval tme between tasks wthn a burst. here are a bounded number of arrvals to each burst; furthermore, the total tme for the burst (.e. the number of nner arrvals multpled by the nner perod) must be less than or equal to the outer perod. A task that s not a bursty task s smply modelled as one that has an nner perod equal to the outer perod, and at most one nner arrval. 3. BASIC ANALYSIS AND ARBIRARY DEADLINES hs secton derves smple analyss for the computatonal model descrbed above. We assume that there s no release tter and that tasks are not sporadcally perodc. Joseph and Pandya [5] derved smple analyss to fnd the worst-case response tme of a gven task, assumng sporadc tasks wth mnmum nter-arrval tmes, and worst-case computaton tmes. he analyss assumes a crtcal nstant, where all tasks are assumed to be released together; ths s the worst-case schedulng scenaro for smple tasks. he followng analyss gves the worst-case response tme of a task (r ), assumng that all tasks are released as soon as they arrve, and that tasks do not suspend themselves (see Appendx A for a summary of the notaton used): r = C + hp( ) r C As can be see, the response tme r appears on both sdes of the equaton. Joseph and Pandya gve a method for evaluatng the equaton, but a smple approach can be used by teratng to a soluton: n + 1 r = C + hp( ) r n C (1) Where r 0 = C heorem 3.1 Proof: If the utlsaton of the hghest prorty levels s less than 1, then the sequence r n converges to r (the task completon tme) n a fnte number of steps (.e. there exsts an n such that r n+1 = r n ) See ndell [16] or Joseph and Pandya [5] he task meets ts deadlne f and only f r s less than or equal to D, the deadlne of task. If the sequence converges to a value of r greater than then the value s nvald, snce the computaton of prevous nvocatons of has not been accounted for. For systems wth task deadlnes less than task perods (.e. D ) ths s not a problem, snce such a value of r would result n an unschedulable task anyway. However, for the arbtrary deadlne stuaton the equaton s no longer suffcent. 3

Lehoczky [8] descrbes qualtatve analyss to determne the schedulablty of a task set wth arbtrary deadlnes. he approach uses the noton of busy perods : a level busy perod s defned as the maxmum tme for whch a processor executes tasks of prorty greater than or equal to the prorty of task. Lehoczky shows how the worst-case response tme of a task can be found by examnng a number of wndows, each defned to be the length of the busy perod startng at the wndow, and each wndow startng at an arrval of task (hence at some multple of before the current nvocaton of task ). A number of wndows back n tme need to be examned to fnd the worst-case response tme (n general, the worst-case response tme can be the response tme correspondng to any one of the wndows). Fgure 1 llustrates ths. hgh hgh task hgh C hgh r task C task low 1st 2nd 3rd 4th 5th nvocatons of task level busy perod Fgure 1: a level busy perod over fve nvocatons of task Fgure 1 shows part of the executon of a three task system: task hgh s a hgh prorty task (ncluded merely for llustratng response tmes of task ), task s of medum prorty (and can arrve before ts prevous nvocaton has completed), and task low s the lowest prorty task (ncluded to llustrate the length of the level busy perod). me flows from left to rght across the dagram. A task executng for some tme s depcted as a shaded rectangle. he pre-empton of a task s depcted as a whte rectangle. he response tme of a task s therefore the length of the whole rectangle. he level busy perod s llustrated (the busy perod ends when task low s able to begn executon). o fnd the worst-case response tme all fve nvocatons of task n ths busy perod must be examned (n the dagram, the thrd nvocaton of task s delayed the longest, and ths response tme s the worst-case response tme). In the followng dscusson the current nvocaton of task s assumed to be the last (.e. ffth) nvocaton. For a level busy perod startng at tme q before the release of the current nvocaton of task we can extend the orgnal analyss by fndng the computaton that starts n ths perod: w ( q) w ( q) = ( q + 1 ) C + C (2) hp( ) he value of w (q) can agan be found by teraton, wth w (q) 0 = (q + 1)C ; a faster convergence can be obtaned by observng that w (q + 1) w (q), and hence w (q) 0 = w (q 1) wll converge faster, wth w (0) 0 = C. Notce how all the computaton of prorty or hgher startng n the wndow s accounted for; the term qc accounts for the computaton of prevous nvocatons of task startng n the wndow. Now, the frst q of the level busy perod falls 4

before the current nvocaton of task s released, and hence cannot contrbute to the response tme. he response tme correspondng to the wndow startng q before the current nvocaton of task s therefore gven by: (w (q) q ) Now, as mentoned above, the worst-case response tme can occur at any one of these response tmes, and thus the worstcase response tme s gven by: r = max w ( q ) q q= 0, 1, 2,... he wndows for ncreasng values of q need to be determned. he sequence s fnte, however, because the search can stop f a level busy perod s found whch fnshes before task starts (.e. the processor s released to process lower prorty tasks) snce the processor s executng lower prorty tasks there can be no mpact on task from prevous nvocatons of task n busy perods startng earler. hus the above teraton over ncreasng values of q can stop f: (3) w (q) (q+1) he above analyss s llustrated by consderng agan fgure 1: the thrd nvocaton of task (.e. q = 2) fnshes at tme w, where w s equal to 2C hgh + 3C (ths s the value of w to whch equaton 2 converges when q = 2). he thrd nvocaton of task s released at tme 2, and therefore the response tme of ths nvocaton s 2C hgh + 3C 2. After evaluatng the response tmes for all fve nvocatons startng n the busy perod t can be seen that ths s the largest response tme (.e. the worst-case response tme). We can now see that the orgnal analyss s a specal case of the above analyss: the orgnal equaton (Equaton 1) s equvalent to equaton 2 wth q = 0. No wndows startng earler need be consdered, snce we constran D, and hence w (0), to be less than. At ths pont t s approprate to dscuss the extensons needed to analyse the prorty celng protocol. he protocol has the property that any task can only be blocked at most once by a lower prorty task. In fact, a stronger asserton can be proved: that durng a level busy perod there can be at most one blockng due to a task of lower prorty than. hs can be seen by consderng the operaton of the prorty celng protocol: at any tme only one task of lower prorty than can hold a semaphore wth celng greater (or equal to) the prorty of. hus any task executng n the level busy perod can only be blocked at most once. When ths task termnates the processor wll contnue to execute at a prorty greater than or equal to untl the end of the level busy perod. No task lower than the prorty of can execute (and hence cannot lock a semaphore). herefore the level busy perod can be blocked at most once by tasks of lower prorty than. he wndow denoted w (q) represents the executon of a level busy perod startng at tme q before the release of the nvocaton of we are consderng. he wndow w (q) ncludes computaton from multple nvocatons of task and hgher prorty tasks. o allow for blockng tme we need only add the term B (equal to the longest crtcal secton of a semaphore of celng prorty greater than or equal to that of task, where the crtcal secton s executed by a task of prorty lower than task ). he above analyss leads to the followng theorem: heorem 3.2 he worst-case response tme of a task s gven by: r = max w ( q ) q q= 0, 1, 2,... 5

where w (q) s gven by: w ( q) w ( q) = ( q + 1 ) C + B + C (4) hp( ) Proof: Follows drectly from the dervaton of the relatons descrbed above 4. HE RELEASE JIER PROBLEM So far we have assumed that as soon as a task arrves t s released. In general ths s not the case (a task may be delayed by the pollng of a tck scheduler, or perhaps awatng the arrval of a message), and the above equatons must be extended to nclude ths release tter tme. he release tter problem occurs when the worst-case tme between successve releases of a task s shorter than the worstcase tme between arrvals of a task. Consder the followng scenaro: a task, of hgher prorty than task, arrves at tme 0. At a later tme J later task s released (perhaps s a sporadc whch must be polled for by a tck scheduler). At the same tme task s released. ask mmedately pre-empts task, as expected. At tme task re-arrves. hs tme s mmedately released (perhaps arrved ust before the tck scheduler pollng perod). From the vew of task, task has arrved wth tme J between arrvals (Fgure 2). he current schedulng equatons do not cater for ths stuaton, and hence must be modfed. task J task r Fgure 2: the problem of release tter Over a large number of perods task wll execute at the perod, but over a short perod of tme (between ust two successve nvocatons of ) ths rate s optmstc. Now, the worst-case schedulng scenaro for ths short-term nter-arrval compresson s as descrbed above: a task s released at the same tme as the level busy perod. Wthout release tter the total pre-empton tme would be ac (where a s a postve nteger); f release tter s accounted for an extra preempton could occur, gvng a total pre-empton of tme (a + 1)C. hs occurs f: a < w ( q) + J ( a + 1 ) and ( a 1) < w ( q) a.e.: a < w ( q) + J a + 1 and a 1 < w ( q) a Lemma he pre-empton due to hgher prorty tasks s gven by: hp( ) J + w ( q) C 6

Proof: Follows drectly from the defnton of release tter. hgh J C r w (5) starts here level busy perod 1st 2nd 3rd 4th 5th 6th nvocatons of task Fgure 3: release tter and busy perods We now consder the on effects of D > and release tter. ask tself could potentally suffer release tter (as descrbed n the prevous secton), and thus the level busy perods from prevous nvocatons of task can start J later (Fgure 3). hs does not affect the computaton from startng n w (q) (t remans at (q + 1)C ), but does affect the correspondng response tme: the wndow w (q) needs to start J later than the frst nvocaton of n the busy perod, and hence equaton 3 s updated to: r = max w ( q ) + J q = q 0, 1, 2, 3,... For completeness we menton that the equatons are stll correct n the case when J s large (>> ): the equatons predct that, n the worst-case, a number of nvocatons of could be released smultaneously. hs s exactly what could happen n the worst-case: suppose that task was a packet nterrupt handler (processng packets from a broadcast bus). If a tck scheduler polled for the release of task and had a pollng perod tck >> (.e. several packets could arrve between scheduler tcks) then all outstandng packets would have to be processed by task, takng at most C computaton tme for each packet. hus a lower prorty task released at the same tme would be pre-empted for a long tme, and thus the equatons for release tter handle the case when the release tter s large. (5) 7

5. SPORADICALLY PERIODIC ASKS hs secton descrbes how the schedulablty analyss of the prevous secton can be updated to determne exactly worstcase response tmes when tasks can behave as sporadcally perodc tasks: executng wth an nner perod (t ) and outer perod ( ). Frstly, we have to place some restrctons on the model: we must have the bursty behavour fnshng before the next burst (.e. n t ). We also assume that the release tter J s the nner release tter (.e. each nvocaton of task can suffer ths tter). heorem 5.1 he worst-case response tme of task s gven by: r = max w ( q ) + J mt M q= 0, 1, 2, 3,... where m s gven by: m = q Mn and q M = n and where w (q) s gven by: w ( q) = M n + m + 1 C + B + mn n, hp( ) J + w ( q) F t + F n C and F s gven by: F = J + w ( q) Proof: We adopt the same approach to fndng the worst-case response tme as before: a number of wndows are examned and the response tme correspondng to each s determned. he worst-case response tme s the maxmum of these response tmes. However, nstead of examnng wndows startng at tme J + q before the current release of a task we have to also consder wndows startng at J + qt before the release of task. 8

M=1 J t 2t m=2 wndow w (q) starts here We are examnng ths nvocaton of Fgure 4: sporadcally perod tasks; n = 3, q = 5 Frstly we consder the computaton occurrng n the wndow w (q) from prevous nvocatons of task. We defne two ntegers M and m, where M s the number of outer perods prevously that the wndow w starts at, and m s the number of nner perods (Fgure 4). M and m are gven by: M = q n m = q Mn where q s an nteger 0. From fgure 4 t can be seen that the wndow starts at tme m t + M J before the current release of task. he total computaton from prevous nvocatons of task startng n the wndow w (q) s gven by: M n C + m C (6) Consder now the computaton occurrng n the wndow w (q) from hgher prorty sporadcally perodc tasks. If the wndow w (q) s larger than a number of bursts of then the computaton from each burst amounts to n C. For the partal burst startng n w (q) we can treat as a smple perodc task executng wth perod t over the remanng part of w (q). he whole number of bursts startng and fnshng n w (q) s gven by: F = J + w ( q) the remanng part of the wndow w (q) s of length J + w (q) F, and hence a bound on the number of nvocatons of n ths remanng tme s: J + w ( q) F t Another bound on the number of nvocatons n ths tme s n, snce a burst can consst of at most n nvocatons of task. herefore the least upper bound can be taken: mn n, J + w ( q) F t 9

hus the total computaton from all hgher prorty tasks occurrng n the wndow w (q) s: hp( ) mn n, J + w ( q) F t + F n C (7) and hence the theorem s derved. Note that when evaluatng the worst-case response tme for a task the teraton can stop as soon as w (q) M + m t J 6. ICK SCHEDULING ck schedulng s a common way of mplementng a prorty pre-emptve scheduler: a perodc clock nterrupt runs a scheduler whch polls for the arrvals of tasks; any arrved tasks are placed n a notonal prorty ordered run-queue. he scheduler then dspatches the hghest prorty task on the run-queue. Sporadc tasks can arrve at any tme, and hence suffer a worst-case release tter of clk, the perod of the tck scheduler. Perodc tasks, n the general case, can also arrve at any tme. However, a task wth a perod that s a multple of clk, and defned to arrve at a tck nterrupt, has a release tter of zero. Our motvaton for pollng for sporadcs s a safety one: f sporadcs were released by a processor nterrupt ntated by the arrval condton of the sporadc then some mechansm must exst to prevent the nterrupt re-occurrng before the worst-case re-arrval tme. If sporadcs are polled then the scheduler can decde not to release a sporadc f the mnmum nter-arrval tme has been volated. he overheads due to operatng tck schedulng can be accurately determned by applyng the same schedulng analyss as descrbed n prevous sectons. Before applyng the analyss we wll brefly descrbe some mportant characterstcs of certan tck schedulng mplementatons. A common way of mplementng tck schedulng s to use two queues: one queue holds a deadlne ordered lst of tasks whch are awatng ther start condtons (such as a start tme for perodcs, or a start event such as a value n an I/O regster for sporadcs); we denote ths queue the pendng queue. he other queue s a prorty-ordered lst of runnable tasks, denoted the run queue. At each clock nterrupt the scheduler scans the pendng queue for tasks whch are now runnable and transfers them to the run queue. When a runnng task termnates t executes a system call (on a 68000-famly processor ths s called a trap ) to transfer the task back to the pendng queue to awat the start condton for the next nvocaton (of course, for a task wth deadlne greater than perod the start condton may already be true, and the task can be returned mmedately to the run queue). he overheads due to ths call can be allowed for by treatng the call as a crtcal secton of the callng task, guarded by a semaphore wth a celng equal to the hghest prorty task n the system. Most mplementatons of such a queung system have the followng characterstc: the computaton cost to take a task from the pendng queue to the run queue s lower f more than one task s taken at the same tme. For example, n one mplementaton of a run-tme system at York [4] the worst-case cost to handle a tmer nterrupt s 66µs; the cost to take the frst task from the pendng queue s another 74µs (we denote ths tme C QL ). For each subsequent task removed (as part of the processng wthn the same nterrupt) the cost s 40µs (we denote ths tme C QS ). hs s because there are one-off costs assocated wth settng up loops, etc. hese costs are worst-case computaton tme costs wth the processor cache dsabled. We now develop analyss to accurately account for these overheads. he costs of the perodc tmer nterrupt can be modelled as a smple task, wth worst-case computaton tme C clk and perod clk ; wthn a tme wndow of wdth w the worst-case number of tmer nterrupts s gven by: L = w clk 10

Now, wthn the same wndow the worst-case number of tmes tasks move from the pendng queue to the run queue s (from equaton 7) gven by: K = J + w F mn, n t tasks + n F If, over a wndow of wdth w, the total number of task queue moves, K, s less than the number of clock nterrupts L, then n the worst-case all of the queue manpulatons are full cost (.e. each takng a worst-case computaton tme of C QL ), and the full cost of tck schedulng overheads s: LC clk + KC QL If, over w, K s greater than L then only the frst L task queue moves are at the full cost C QL ; the remanng K L requre only C QS each. Hence the tck schedulng overheads for a task over a wndow of wdth w are: LC clk + mn(l, K)C QL + max(k L, 0)C QS 7. OPIMAL PRIORIY ORDERING As has been mentoned before nether the deadlne monotonc nor rate monotonc prorty orderng polces are optmal 2 for tasks wth arbtrary deadlnes. We reproduce here the optmal prorty orderng algorthm of Audsley [1]. he algorthm works as follows: a prorty orderng s partton nto two parts: a sorted part, consstng of the lower n prorty tasks, and the remanng unsorted hgher prorty tasks. Intally the prorty orderng s an arbtrary one, and all tasks are unsorted. All tasks n the unsorted partton are chosen n turn and placed at the top of the sorted partton and tested for schedulablty. If the chosen task s schedulable then the prorty of the task s left as t s, and the sorted partton extended by one poston. If the task s not schedulable t s returned to ts former prorty. hs contnues untl ether all tasks n the unsorted partton have been checked and found to be unschedulable (n whch case there s no prorty orderng resultng n a schedulable system), or else the sorted partton s extended to the whole prorty map (n whch case the prorty orderng s a feasble one). An arbtrary prorty orderng s chosen n an array, wth 0 beng the hghest prorty, and N 1 the lowest (N denotes the number of tasks n the system; the algorthm assumes N > 1). he followng pseudo-code detals the algorthm: ordered := N repeat fnshed := false faled := true := 1 repeat nsert at prorty ordered f s schedulable then ordered := ordered - 1 faled := false fnshed := true else nsert back at old prorty end f := + 1 untl fnshed or = ordered untl Ordered = 1 or faled 2 optmal n the sense that f the algorthm s unable to fnd a prorty orderng where all tasks are schedulable then no prorty orderng exsts where all tasks are schedulable 11

# %$ " "" & At all tmes the sorted partton s schedulable, snce the prorty orderng wthn the unsorted partton cannot affect the sorted tasks. he sorted partton ncreases n sze untl ether all the tasks are schedulable, or none of the top n tasks are schedulable at prorty n. he analyss has the property that decreasng the prorty of a task cannot lead to a decrease n worst-case response tme (.e. a decrease n prorty cannot ncrease schedulablty). herefore, n the case where none of the top n tasks s schedulable at prorty n no prorty orderng can exst where all tasks are schedulable. herefore the algorthm must be consdered optmal. Furthermore, ths algorthm holds for any schedulng test where worst-case response tme s monotonc wth decreasng prorty (.e. where decreasng the prorty of a task does not lead to a decrease n the worst-case response tme of that task). 8. SUMMARY We reproduce here the equatons for the full schedulablty test: he worst-case response tme of a task s gven by: r = max w ( q ) + J mt M q= 0, 1, 2, 3,... he teraton over values of q can stop as soon as w (q) M + m t J M s gven by: M q = n and m s gven by: m = q Mn w (q) s gven by: w ( q) = M n + m + 1 C + B + mn n, hp( ) + LC + mn L, K C + max( K L, 0) C clk QL QS J + w ( q) F t + F n C where w (q) can be found by teraton as for equaton 1, wth w (q) 0 = w (q 1), and w (0) 0 = 0 F s gven by: F = J + w ( q) K s gven by: K = mn tasks! J + w ( q) F, n t '( + n F and L s gven by: 12

w q L = ( ) clk Other symbols used n the above equatons are defned n the glossary gven n Appendx A. he schedulablty of a task can be assessed by comparng wth the deadlne: r D An optmal prorty orderng can be obtaned usng the algorthm descrbed n the prevous secton. 9. EXAMPLE ASK SE he followng tables summarse an example task set, based upon the GAP task set descrbed by Locke et al [13]. he tasks are lsted n prorty order, as found by the optmal prorty orderng algorthm descrbed earler. All tmes are n mcroseconds. ask 11 s a sporadc task, whose arrval s polled for by the tck scheduler, and therefore has non-zero release tter. All other tasks are strctly perodc, wth perods that are multples of clk, and hence do not suffer release tter. asks lock and unlock semaphores accordng to the followng pattern: semaphore locked by tme held 2 task9 300 4 task9 300 1 task9 900 2 task15 1350 3 task10 400 3 task6 400 4 task3 100 5 task11 750 5 task15 750 When the task set s assgned a deadlne monotonc prorty orderng, the worst-case response tmes are as follows: ID t n C B J D r task1 200000 200000 1 3000 0 0 5000 4180 task2 25000 5000 3 700 0 0 5000 4880 task3 25000 5000 3 1400 300 0 12000 7660 task4 40000 40000 1 1000 300 0 40000 12740 task5 50000 50000 1 3000 300 0 50000 16140 task6 50000 50000 1 5000 400 0 50000 21706 task7 59000 59000 1 8000 400 0 59000 37506 task8 80000 80000 1 9000 400 0 80000 48306 task9 80000 80000 1 2000 1350 0 100000 78450 task10 100000 100000 1 5000 1350 0 115000 117708 task11 200000 200000 1 1000 1350 1000 200000 142184 task12 200000 200000 1 3000 1350 0 200000 144382 task13 200000 200000 1 1000 1350 0 200000 145448 task14 200000 200000 1 1000 1350 0 200000 146514 task15 200000 200000 1 3000 0 0 200000 148296 task16 1000000 1000000 1 1000 0 0 1000000 149362 task17 1000000 1000000 1 1000 0 0 1000000 195330 13

asks are lsted n the table n prorty order. As can be seen, task 10 msses ts deadlne (the worst-case response tme of ths task s marked n bold type). When Audsley s optmal prorty orderng algorthm s appled, and the analyss gven n ths paper used, the followng results are obtaned: ID B r task2 0 1580 task1 0 4880 task3 300 7660 task8 300 21606 task7 300 34960 task4 300 38472 task6 400 45108 task5 400 48306 task10 300 96306 task9 1350 99554 task17 1350 141184 task16 1350 142250 task15 750 144782 task14 750 145848 task13 750 146914 task12 750 195080 task11 0 196330 Agan, tasks are lsted n the table n prorty order. As can be seen, the worst-case response tmes of all tasks are less than the deadlnes, and hence the task set s schedulable. Appendx B detals how to obtan the program that mplemented the analyss gven n ths paper. 10. CONCLUSIONS hs short paper has shown how the wndow approach to fndng worst-case response tmes can gve powerful schedulng theory talored to the behavour of real real-tme systems. o use the wndow approach, all that need be done s to fnd the worst-case amount of hgher prorty computaton startng n a gven wndow, and examne a suffcent number of wndows. hs approach has led to schedulablty analyss for complex task behavour, such as mode changes [7] and task offsets [6]; the latter analyss has been shown to be a superset of statc prorty cyclc schedulng. he overheads due to operatng a tck drven scheduler have also been accurately accounted for. he analyss derved n ths paper permts tasks to be assgned arbtrary deadlnes, suffer release tter, and behave as sporadcally perodc tasks. 11. REFERENCES [1] Audsley, N. C., Optmal Prorty Assgnment and Feasblty of Statc Prorty asks Wth Arbtrary Start mes, Dept. Computer Scence, Unversty of York (December 1991). [2] Audsley, N., A. Burns, M. Rchardson, K. ndell and A. Wellngs, Applyng New Schedulng heory to Statc Prorty Pre-emptve Schedulng, Report RRG/92/120 Department of Computer Scence, Unversty of York (February 1992). [3] Baker,. P., Stack-Based Schedulng of Realtme Processes, Real me Systems 3(1) (March 1991). [4] A.D. Hutcheon, mngs of Run-tme Operatons n Modfed York Ada, ask 8 Volume C, Delverable on ESEC Contract 9198/90/NL/SF, York Software Engneerng Lmted, Unversty of York (July 1992). [5] Joseph, M., P. Pandya, Fndng Response mes n a Real-me System, BCS Computer Journal (Vol. 29, No. 5, Oct 86) pp.390-395. [6] K. ndell, Usng Offset Informaton to Analyse Statc Prorty Pre-Emptvely Scheduled ask Sets, YCS 182, Dept of Computer Scence, Unversty of York (August 1992d). 14

[7] K. W. ndell, A. Burns and A. J. Wellngs, Mode Changes n Prorty Pre-emptvely Scheduled Systems, Proceedngs 13th IEEE Real-me Systems Symposum (2-4 December 1992). [8] Lehoczky, J. P., Fxed Prorty Schedulng of Perodc ask Sets Wth Arbtrary Deadlnes, Proceedngs 11th IEEE Real-me Systems Symposum (5-7 Decmeber 1990) pp.201-209. [9] Lehoczky, J., L. Sha and Y. Dng, he Rate Monotonc Schedulng Algorthm: Exact Charactersaton and Average Case Behavour, Proceedngs of the Real-me Systems Symposum (1989). [10] Leung, J. Y.., J. Whtehead, On he Complexty of Fxed-Prorty Schedulng of Perodc Real-me asks, Performance Evaluaton (Vol. 2, Part 4, Dec 1982) pp.237-250. [11] Lu, C. L., J. W. Layland, Schedulng Algorthms for Multprogrammng n a Hard-Real-me Envronment, Journal of the ACM 20(1) (1973) pp.46-61. [12] Locke, C.D., Software archtecture for hard real-tme applcatons: cyclc executves vs. fxed prorty executves, Real-me Systems 4(1) (March 1992) pp.37-53. Real-me Syst. (Netherlands). [13] Locke, C. D., D. R. Vogel and. J. Mesler, Buldng a Predctable Avoncs Platform n Ada: A Case Study, Proceedngs of the 12th Real me Systems Symposum (December 1991). [14] Rakumar, R., L. Sha and J. P. Lehoczky, Real-me Synchronzaton Protocols for Multprocessors, Proceedngs of the IEEE Real-me Systems Symposum (1988) pp.259-269. [15] Sha, L., R. Rakumar and J. P. Lehoczky, Prorty Inhertance Protocols: An Approach to Real-me Synchronsaton, IEEE ransactons on Computers 39(9) (September 1990) pp.1175-1185. [16] ndell, K., Usng Offset Informaton to Analyse Statc Prorty Pre-Emptvely Scheduled ask Sets, Dept of Computer Scence, Unversty of York (August 1992). [17] ndell, K., A. Burns and A.J. Wellngs, Allocatng Real-me asks (An NP-Hard Problem made Easy), Real-me Systems 4(2) (June 1992) pp.145-165. APPENDIX A GLOSSARY OF NOAION he followng table gves the notaton used n ths paper: tasks hp() C D B J t n r C QL C QS clk C clk w ask denotes the task for whch we are tryng to fnd the worst-case response tme ask generally denotes a task of hgher prorty than he set of all tasks n the system he set of all tasks of hgher prorty than task he worst-case computaton tme of task he statc deadlne of task, measured relatve to the arrval tme of the task he worst-case blockng tme of task, found accordng to the prorty celng protocol he worst-case release tter of task (.e. the worst-case delay between a task arrvng and beng released) he outer perod of task he nner perod of task he worst-case number of arrvals of task per outer perod he worst-case response tme of task, measured from the arrval tme to the completon tme he worst-case computaton tme requred to move a sngle task from the delay queue to the run queue he worst-case computaton tme to move each task from the delay queue to the run queue he perod of the clock tmer nterrupt he worst-case computaton tme requred to servce the perodc clock tmer nterrupt Generally a computaton wndow used to fnd worst-case response tmes 15

APPENDIX B AN ANALYSIS PROGRAM he source code to a program that mplements the analyss descrbed n ths paper can be obtaned va anonymous FP from: mnster.york.ac.uk (IP address: 144.32.128.41) n the drectory: pub/realtme/programs/src/arbdead 16