+ All Categories
Home > Documents > Lecture07-aperiodic

Lecture07-aperiodic

Date post: 06-Apr-2018
Category:
Upload: nawarajbhandari
View: 215 times
Download: 0 times
Share this document with a friend

of 24

Transcript
  • 8/3/2019 Lecture07-aperiodic

    1/24

    Priority-driven Scheduling of Aperiodic and

    Sporadic Tasks (2)

    Advanced Operating Systems (M)Lecture 7

  • 8/3/2019 Lecture07-aperiodic

    2/24

    Scheduling aperiodic jobs (contd) Sporadic servers Constant utilisation servers Total bandwidth servers

    Weighted fair queuing servers

    Scheduling sporadic jobs

    2

    Lecture Outline

  • 8/3/2019 Lecture07-aperiodic

    3/24

    Limitation of deferrable servers they may delaylower-priority tasks for more time than a periodictask with the same period and execution time:

    3

    Limitations of Deferrable Servers

    0 1 2 3 4 5 6 7 8 9

    T2=(p=6.5, e=0.5)

    T1=(=2,p=3.5, e=1.5)

    TDS=(p=3, e=1)

    0

    1Budget

    JA released

    Budget replenished

    Budget exhausted

    Budget replenished

    T1 blocked for 1.2 units although execution

    time of deferrable server is only 1.0 units

  • 8/3/2019 Lecture07-aperiodic

    4/24

    4

    Sporadic Servers

    A sporadic server is designed to eliminate thislimitation

    A different type of bandwidth preserving server: several different sub-types

    More complex consumption and replenishment rules ensure that asporadic server with periodpS and budget eSnever demands moreprocessor time than a periodic task with the same parameters

  • 8/3/2019 Lecture07-aperiodic

    5/24

    System, T, of independent preemptable periodictasks and a sporadic server with parameters (ps, es)

    Fixed-priority scheduling; system can be scheduled if sporadic serverbehaves as a periodic task with parameters (ps, es)

    Define: TH : the periodic tasks with higher priority than the server (may be empty) tr : the last time the server budget replenished tf : the first instant aftertrat which the server begins to execute

    At any time tdefine: BEGINas the start of the earliest busy interval in the most recent contiguous sequence of

    busy intervals ofTHstarting before t(busy intervals are contiguous if the later one startsimmediately the earlier one ends)

    END as the end of the latest busy interval in this sequence if this interval ends before t;defineEND = if the interval ends aftert

    5

    Simple Fixed-Priority Sporadic Server

  • 8/3/2019 Lecture07-aperiodic

    6/24

    Consumption rule: At any time ttr, if the server has budget and if either of the following two

    conditions is true, the budget is consumed at the rate of 1 per unit time:

    C1: The server is executing C2: The server has executed since trandEND < t

    When they are not true, the server holds its budget

    That is:

    The server executes for no more time than it has execution budget

    The server retains its budget if: A higher-priority job is executing, or It has not executed since tr

    Otherwise, the budget decreases when the server executes, or if it idleswhile it has budget

    6

    Simple Fixed-Priority Sporadic Server

  • 8/3/2019 Lecture07-aperiodic

    7/24

    Replenishment rules R1: When system begins executing, and each time budget is replenished,

    set the budget to eS and tr= the current time.

    R2: When server begins to execute (defined as time tf)ifEND = tf then

    te = max(tr,BEGIN)

    else ifEND < tf thente = tf

    The next replenishment time is set to te +pS

    R3: budget replenished at the next replenishment time, unless:

    Ifte +pS is earlier than tf the budget is replenished as soon as it is exhausted

    IfTbecomes idle before te + pS, and becomes busy again at tb, the budget is replenished atmin(tb, te +pS)

    7

    Simple Fixed-Priority Sporadic Server

    te = effective replenishment time

  • 8/3/2019 Lecture07-aperiodic

    8/248

    Example: Fixed-Priority Sporadic Server

    TSS

    T1

    T2

    0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25

    T3

    T1=(3, 0.5), T2=(4, 1.0), T3=(19, 4.5), Tss=(5, 1.5)

    Rate monotonic schedule; simple sporadic server

    A1: r = 3, e = 1

    A2: r = 7, e = 2

    A3: r = 15.5, e = 2

    A1 A2 A3

    Max. blocking time due

    to sporadic server = 1.5

  • 8/3/2019 Lecture07-aperiodic

    9/24

    Example: Fixed-Priority Sporadic Server

    90.0

    1.0

    Budget

    0.5

    1.5

    No aperiodic jobs

    server suspended

    JobA1 released,

    server blocked

    JobA1 executes

    Budget continues to be usedaccording to rule C2

    JobA2 released

    but no budget

    Budget availablebut blocked

    JobA2 executes

    No budget

    Sporadic server is constrained to executefor at most 1.5 units out of every 5, due toconsumption and replenishment rules

    A1 A2 A3

    9

    TSS

    T1

    T2

  • 8/3/2019 Lecture07-aperiodic

    10/24

    More complex than a polling server or a deferrableserver, but much easier to prove the system can bescheduled

    Theorem: for the purpose of validating a schedule,you can treat a simple sporadic server(ps, es) in a

    fixed-priority system exactly the same as any other

    periodic task Ti withpi=ps and ei = es The actual inter-release times of the sporadic server will sometimes be

    greater thanps, and their execution times less than es, but this does notaffect correctness

    10

    Simple Fixed-Priority Sporadic Server

  • 8/3/2019 Lecture07-aperiodic

    11/24

    It is possible to define a simple sporadic server tooperate in a dynamic-priority environment

    E.g., when using EDF or LST scheduling

    Consumption and replenishment rules conceptuallysimilar to those for a fixed-priority scheduler, withminor modifications that account for the differencein scheduling algorithm

    Provides same scheduling guarantees as the simple sporadic server for

    fixed-priority schedulers

    A simple sporadic server(ps, es) in an EDF or LST system can be treatedexactly the same as any other task Ti withpi =ps and ei = es when testingwhether the system can be scheduled

    11

    Simple Dynamic-Priority Sporadic Server

  • 8/3/2019 Lecture07-aperiodic

    12/24

    Two other bandwidth preserving server algorithmsoften used for process scheduling:

    Constant utilisation server Total bandwidth server

    Used in virtual machine systems, to assign knownfraction of processor time to some task

    Aiming to provide fair sharing, timing isolation, or guaranteed throughput

    12

    Other Bandwidth Preserving Servers

  • 8/3/2019 Lecture07-aperiodic

    13/24

    Constant utilisation server reserves a fraction, s, ofthe processor time for execution of the server

    Like other bandwidth preserving servers, it has abudget and is defined in terms of consumption andreplenishment rules

    When the budget is non-zero, the server isscheduled with other tasks on an EDF basis

    The budget and deadline of the server are chosen such that the utilisationof the server is constant when it executes, and that it is always givenenough budget to complete the job at the head of its queue each time itsbudget is replenished

    The server never has any budget if it has no work to do

    13

    Constant Utilisation Server

  • 8/3/2019 Lecture07-aperiodic

    14/24

    Consumption rule: A constant utilisation server only consumes budget when it executes

    Replenishment rules:

    Initially, budget es = 0 and deadline d= 0 When an aperiodic job with execution time e arrives at time tto an emptyaperiodic job queue

    Ift < d, do nothing ( server is busy; wait for it to become idle)

    Iftdthen set d = t + e/s and es = e

    At the deadline d of the server If the server is backlogged, set d = d + e/s and es = e ( was busy when job arrived) If the server is idle, do nothing

    i.e., the server is always given enough budget to complete the job at thehead of its queue, with known utilisation, when the budget is replenished

    14

    Constant Utilisation Server

  • 8/3/2019 Lecture07-aperiodic

    15/24

    A total bandwidth server improves responsivenessby allowing a server to claim background time notused by the periodic tasks

    Change the replenishment rules slightly, leave all else the same: Initially, es = 0 and d= 0 When an aperiodic job with execution time e arrives at time tto an empty aperiodic job queue,

    set d= max(d, t) + e/s and es = e

    When the server completes the current aperiodic job, the job is removed from the queue and,if the server is backlogged, set d = d + e/s and es = e; if the server is idle, do nothing

    Always ready for execution when backlogged

    Assigns at least fraction s of the processor to a task

    15

    Total Bandwidth Server

  • 8/3/2019 Lecture07-aperiodic

    16/24

    Consider the problem of scheduling sporadic jobsalongside a system of periodic tasks and aperiodicjobs

    Recall the sporadic job scheduling problem: Based on the execution time and deadline of each newly arrived sporadic

    job, decide whether to accept or reject the job

    Accepting the job implies that the job will complete within its deadline,without causing any periodic task or previously accepted sporadic job tomiss its deadline

    Do not accept a sporadic job if cannot guarantee it will meet its deadline

    16

    Scheduling Sporadic Jobs

  • 8/3/2019 Lecture07-aperiodic

    17/24

    When sporadic jobs arrive, they are both acceptedand scheduled in EDF order

    In a dynamic-priority system, this is the natural order of execution In a fixed-priority system, the sporadic jobs are executed by a bandwidth

    preserving server, which performs an acceptance test and runs thesporadic jobs in EDF order

    In both cases, no new scheduling algorithm is required

    Definitions:

    Sporadic jobs are denoted by Si(ri, di, ei) where ri is the release time, di isthe (absolute) deadline, and ei is the maximum execution time

    The density of a sporadic job i = ei/(diri) The total density of a system of n jobs is =1 +2 + +n

    The job is active during its feasible interval (ri, di]

    17

    Model for Scheduling Sporadic Jobs

  • 8/3/2019 Lecture07-aperiodic

    18/24

    Theorem: A system of independent preemptablesporadic jobs can be scheduled using EDF if thetotal density ofallactive jobs in the system 1 atall times

    This is the standard scheduling test for EDF systems, but including bothperiodic and sporadic jobs

    This test uses the density since deadlines may not equal periods; hence itis a sufficient test, but not a necessary test

    What does this mean?

    If we can bound the frequency with which sporadic jobs appear to therunning system, we can guarantee that none are missed

    Alternatively, when a sporadic job arrives, if we deduce that the totaldensity would exceed 1 in its feasible interval, we reject the sporadic

    job (admission control)

    18

    Sporadic Jobs in Dynamic-Priority Systems

  • 8/3/2019 Lecture07-aperiodic

    19/24

    At time tthere are n active sporadic jobs, stored innon-decreasing order of deadline

    The deadlines partition the time from tto into n + 1 discrete intervals:I1,I2, ,In+1

    I1 begins at tand ends at the earliest sporadic job deadline

    For each 1 kn, each intervalIk+1 begins when the intervalIkends, and ends at the nextdeadline in the list (or forIn+1)

    The scheduler maintains the total density s,kof each intervalIk

    LetIlbe the interval containing the deadline dofthe new sporadic job S(t, d, e) The scheduler accepts the job if

    for all k= 1, 2, , l

    i.e. accept if the new sporadic job can be added, without increasing thedensity of any intervals past 1

    19

    Admission Control for Sporadic Jobs/EDF

    Density of new jobe

    d t+s,k 1

  • 8/3/2019 Lecture07-aperiodic

    20/24

    Notes: This acceptance test is notoptimal: a sporadic job may be rejected even

    though it could be scheduled (the result for the schedulable utilisation isbased on the densityand hence is sufficient but not necessary)

    It is possible to derive a much more complex expression taking intoaccount slack time, that is optimal. Unclear if the complexity is worthwhile.

    This acceptance test assumes every sporadic job is ready for executionwhen released

    If this is not the case, must modify the acceptance test to take into account the time when thejobs become ready, rather than their release time, when testing the intervals to see if theirdensity exceeds 1

    20

    Admission Control for Sporadic Jobs/EDF

  • 8/3/2019 Lecture07-aperiodic

    21/24

    Use a sporadic server to execute sporadic jobs in afixed-priority system

    The server(ps, es) has budget es units everyps units of time, so thescheduler can compute the least amount of time available to everysporadic job in the system

    Assume that sporadic jobs ordered among themselves in EDF When first sporadic job S1(t, ds,1, es,1) arrives, there is at least

    (ds,1t)/pses units of processor time available to the serverbefore the deadline of the job

    (ds,1t)/ps = number of server periods available

    Therefore it accepts S1 if slack of job

    [contd]21

    Sporadic Jobs in Fixed-Priority Systems

    Time available

    Execution time

    s,1(t) = b(ds,1 t)/psc es es,1 0

  • 8/3/2019 Lecture07-aperiodic

    22/24

    To decide if a new job Si(t, ds,i, es,i) is acceptable when there are n sporadicjobs in the system, the scheduler first computes the slack s,i(t) ofSi:

    where s,k is the execution time of the completed part of the existing job Sk

    The job cannot be accepted ifs,i(t) < 0 As fors,1(t), but accounting for the already accepted sporadic jobs

    Ifs,i(t) 0, the scheduler then checks if any existing sporadic job Skwithdeadline afterds,i may be adversely affected by the acceptance ofSi

    Check if the slack s,k(t) for each Skat the time is at least equal to the execution time es,i ofSi(i.e., Si is accepted ifs,k(t) es,i 0 for every existing sporadic job Skwith deadline ds,i)

    This acceptance test for fixed-priority systems is more complex than thatfor dynamic-priority systems, but is still of reasonable time complexity tobe implemented on-line

    22

    Sporadic Jobs in Fixed-Priority Systems

    s,i(t) = b(ds,i t)/psc es es,i X

    ds,k

  • 8/3/2019 Lecture07-aperiodic

    23/24

    POSIX Scheduling API: Sporadic Server

    Hybrid sporadic/background server included in realtime extensions to POSIX Use the SCHED_SPORADIC scheduling policy

    When server has budget, runs at sched_priority, otherwise runs as abackground server at sched_ss_low_priority

    Set sched_ss_low_priority to be lower priority than real-time tasks, but possibly higher thanother non-real-time tasks in the system

    Also defines the replenishment period and the initial budget afterreplenishment

    As usual with POSIX, applicable to fixed-priority systems only

    23

    struct sched_param {

    int sched_priority;int sched_ss_low_priority;struct timespec sched_ss_repl_period;struct timespec sched_ss_init_budget;

    };

  • 8/3/2019 Lecture07-aperiodic

    24/24

    Have discussed further: Scheduling aperiodic jobs (contd)

    Sporadic servers Constant utilisation servers Total bandwidth servers

    Weighted fair queuing servers

    Scheduling sporadic jobs

    24

    Summary


Recommended