vikas clock driven final

Upload: vkurdia8504

Post on 09-Apr-2018

217 views

Category:

Documents


0 download

TRANSCRIPT

  • 8/8/2019 Vikas Clock Driven FINAL

    1/41

    Clock-Driven Scheduling&

    Weighed Round Robin Scheduling

    Vikas Kurdia

    (Asst. Professor C.S. Department)

    (M.Tech Coordinator C.S. & I.T. Department)

  • 8/8/2019 Vikas Clock Driven FINAL

    2/41

    2

    Jobs & Tasks job : a unit of workthat is carried out by the

    system (Ji )

    task: a set of related jobs that provide somesystem function ( Xi = { Ji,1, Ji,2 , , Ji,N } )

    task a generalization of a class of jobs

    tasks are specified at design-timejob Ji,k k

    th instance of task i

    jobs occur at run-time

  • 8/8/2019 Vikas Clock Driven FINAL

    3/41

    Oct 19/09 3

    Job & Task Parameters temporal: timing constraints and behaviour

    interconnec

    tion

    :

    dependencies among jobs(or among tasks)

    functional: intrinsic parameters of work

    resource: active (processor) and passive

    (resource) components required

  • 8/8/2019 Vikas Clock Driven FINAL

    4/41

    4

    Temporal Parameters of

    Jobs includes ri , di and Di

    feasible interval: (ri, d

    i)

    It does not include ri

    but includes di

    also includes execution time (ei)

  • 8/8/2019 Vikas Clock Driven FINAL

    5/41

    5

    Scheduling T

    heory

    ideal goal : alljobs are always allocated requiredresources to complete execution within their feasibleregions ( r, d )

    scheduling algorithm : decides the order in whichjobs are allocated resources

    scheduler : a module that implements a schedulingalgorithm

    scheduling decision point: point in time whenscheduler decides which job to execute next

  • 8/8/2019 Vikas Clock Driven FINAL

    6/41

    6

    Schedule

    schedule : assignment of jobs to available

    processors

    feasible schedule : every job starts at or after

    its release time and completes by its deadline

    optimal scheduling algorithm : always

    produces a feasible schedule if at least onefeasible schedule exists

  • 8/8/2019 Vikas Clock Driven FINAL

    7/41

  • 8/8/2019 Vikas Clock Driven FINAL

    8/41

    8

    Clock-Driven

    Scheduling

    job parameters are known a priori

    job scheduleprecomputed off-line and

    stored as a table for use at run-time table-driven scheduler

    scheduling decision times in clock-drivensystem is defined a priori;

    scheduler periodically wakes up and generatesnext portion of the schedule

  • 8/8/2019 Vikas Clock Driven FINAL

    9/41

    9

    Clock-Driven

    Scheduling

    Applicable when system is deterministic

    only a few aperiodic and sporadic jobs

    Some assumptions

    Require periodic tasks in the system

    task parameters known a priori

    each job is ready for execution as soon as it is

    released

  • 8/8/2019 Vikas Clock Driven FINAL

    10/41

    10

    Simplifying Assumptions

    Each task denoted by the tuple

    (i, p

    i, e

    i, D

    i)

    Sometimes only the period and execution

    time is provided

    relative deadline = period

    phase = 0 critical instant at time = 0 !

    denote tasks as pair(pi, ei)

    all tasks have a

    job ready at time 0

  • 8/8/2019 Vikas Clock Driven FINAL

    11/41

    11

    T1 T1 T1 T1 T1T3 T2T4 T2T2T2

    schedule was designed arbitrarily!

    Lets take an example we have four independent periodic task.

    T1=(4,1) T2=(5,1.8) T3=(20,1) T4=(20,2)

  • 8/8/2019 Vikas Clock Driven FINAL

    12/41

    12

    0 4 6 8 10 122 14 16 18 20

    cycles every

    hyperperiodH =20

    slack time

    T1 T1 T1 T1 T1T3 T2T4

    criticalinstant

    T2

    T2

    T2

    critical

    instant

    schedule was designed arbitrarily!

    Lets take an example we have four independent periodic task.

    T1=(4,1) T2=(5,1.8) T3=(20,1) T4=(20,2)

  • 8/8/2019 Vikas Clock Driven FINAL

    13/41

    Clock-Driven approach

    Consider four independent periodic task.

    T1=(4,1) T2=(5,1.8) T3=(20,1) T4=(20,2)

    HERE hyper periodic is L.C.M of p1,p2,p3,p4, mean L.C.M. of4,5,20,20then 20.

    It mean after t=20 the entire schedule consist of replicated segment of length xhere

    N is 20/4 + 20/5 + 20/20 + 20/20 =5+4+1+1=11

    Here hyper periodic is 20 and number of jobs that is scheduled under hyperperiod is 11

  • 8/8/2019 Vikas Clock Driven FINAL

    14/41

    14

    Simple Table Driven

    Scheduler Implementationfor Example:

    organize blocks of activities in hyperperiod

    0 4 6 8 10 122 14 16 18 20

    T1 T1 T1 T1 T1T3 T2T4 T2T2T2

    B1 B2 B3 B4 B5

    B1

    :

    call T1

    call T3

    call T2

    B2:

    call T1

    B3

    :

    call T4

    call T2

    call T1

    etc.

    0 4 6.5 12 16 18

    burst start times:

    B6

  • 8/8/2019 Vikas Clock Driven FINAL

    15/41

    15

    Organize Blo

    cks in HTable

    Block StartTime

    B1 4

    B2 2.5

    B3 5.5

    B4 4

    B5 2

    B6 2

    time until start

    of next burst

  • 8/8/2019 Vikas Clock Driven FINAL

    16/41

    16

    FrameSch

    edulingpartition hyperperiod H into equal-sized frames

    each frame has constant length f=frame size

    H is an integral multiple off

    scheduling decision for a frame made at the start

    of the frame

    no preemption within frame

    phase of each task is an integer multiple off

  • 8/8/2019 Vikas Clock Driven FINAL

    17/41

    17

    Frame Monitoring at start of each frame, scheduler must

    ensure:

    1. jobs scheduled for execution in frame

    have been released and are ready

    2. overrun does not occur

    i.e. jobs in previous frames completed

  • 8/8/2019 Vikas Clock Driven FINAL

    18/41

    18

  • 8/8/2019 Vikas Clock Driven FINAL

    19/41

    19

    FrameS

    izeC

    onstraints every job must be able to start and complete

    within a frame:

    fu max (ei)

    for at least one task Ti: - pi/f pi / f = 0

    -floor function

    (round down,

    integer result)

    Why?

    frame divides into

    hyperperiod

  • 8/8/2019 Vikas Clock Driven FINAL

    20/41

    20

    FrameS

    izeC

    onstraints (2) to ensure that every job completes by itsdeadline: want fsmall enough that there is

    at least one frame between the release time

    and deadline of each job

    Liu concludes constraint met when:

    2f gcd( pi , f ) Di

    r d D

    frame

    ensures that job

    has a frame in

    which to execute

    gcd = greatest

    common divisor

  • 8/8/2019 Vikas Clock Driven FINAL

    21/41

    21

    CyclicSchedule Creation

    for Previous ExampleT = {(4, 1), (5, 1.8), (20, 1), (20, 2)}

    Constraints on possible values off

    f max (1, 1.8, 1, 2) 2

    f=

    a divisor of one pi one of 2, 4, 5, 10, 20

    2f gcd (pi,f) Di ????

    all satisfy first

    constraint

  • 8/8/2019 Vikas Clock Driven FINAL

    22/41

    22

    Determining fconsider2f gcd (pi,f) Di for 2, 4, 5, 10, 20

    pi Di 2f gcd(pi, f=2 f=4 f=5 f=10 f=20 )

    4 4 4-2 8-4 10-1 20-2 40-2

    5 5 4-1 8-1 10-5 20-5

    20 20 4-2 8-4 10-5 20-10 therefore, f=2only case to satisfy!

  • 8/8/2019 Vikas Clock Driven FINAL

    23/41

    23

    Problems with Frame

    Constraints? what if tasks wont all satisfy constraints?

    e.g. cant meet both:

    minimum f to ensure a frame between release

    and deadline, and

    f greater than execution time

    cant ensure that a job will be able tocomplete in one frame! ???

  • 8/8/2019 Vikas Clock Driven FINAL

    24/41

    24

    JobS

    lic

    es solution: partition jobs of a task into slices

    with smaller execution times

    schedule slices in different frames

    planned preemption!

    ei

    execution time

    before

    execution time

    after

    ei1 ei2

  • 8/8/2019 Vikas Clock Driven FINAL

    25/41

    25

    Design Decisions:

    1. choose frame size f

    2. partition jobs into slices

    3. places slices in frames

    choices are not independent !

    algorithm for choices in Liu 5.8

  • 8/8/2019 Vikas Clock Driven FINAL

    26/41

    26

    Cyclic

    Executives

    modify clock-driven scheduler to makescheduling decisions on frame boundaries

    dont need to adjust timerjob slices are organized into blocks

    use slack time to execute aperiodic/sporadicjobs

    special servers ?

    run in background ?

  • 8/8/2019 Vikas Clock Driven FINAL

    27/41

    27

    Overrun

    if current block not completed by time next

    block starts frame overrun !

    options:

    abort the offending block

    let block complete in background

    finish the job and force others to be late

    exception handling! (gnarly)

  • 8/8/2019 Vikas Clock Driven FINAL

    28/41

    28

    Improving Response of

    Aperiodic Jobs can use knowledge of deadlines to

    advantage!

    all slices in a block must complete withintheir frame

    no advantage to completing earlier vs. later inthe frame

    instead of allocating slack at end of frame,could use it at beginning!

  • 8/8/2019 Vikas Clock Driven FINAL

    29/41

    29

    SlackS

    tealing execute aperiodic jobs ahead of periodic

    jobs in a frame whenever possible

    required

    for block

    available for

    aperiodic

    frame

    vs.

  • 8/8/2019 Vikas Clock Driven FINAL

    30/41

    30

    SlackS

    tealing Furth

    er scheduler can allow aperiodic jobs to

    execute whenever there is slack in a frame

    could interleave between slices in a block

    increases aperiodic throughput

    increases overhead !

    s1 vs.s2 s1 s2

  • 8/8/2019 Vikas Clock Driven FINAL

    31/41

    31

    Sporadi

    cJobs

    hard deadlines!

    assume minimum release, max execution

    and deadline times are known

    when sporadic job released perform an

    acceptance test:

    if jobs already scheduled + new job are feasible

    then admit the job

  • 8/8/2019 Vikas Clock Driven FINAL

    32/41

    32

    Sporadi

    cJob Deadline

    sporadic job can use any slack available inany frame prior to its deadline

    if enough slack exists to meet deadline, thenadmit and schedule the job

    if insufficient slack reject the job

    immediately if more than one sporadic job waiting

    order them earliest deadline first

  • 8/8/2019 Vikas Clock Driven FINAL

    33/41

    33

    Implementation sporadic job queue EDF ordering

    in each frame:

    1. execute the periodic block first

    2. then dynamically accept (or reject) from

    sporadic job queue

    3. then allow aperiodic jobs

    Liu text has more details (5.6.3)

  • 8/8/2019 Vikas Clock Driven FINAL

    34/41

    34

    ModeCh

    anges changes in operational mode can impact

    schedule

    mode change reconfigure system

    possibly different set of jobs

    possibly different job parameters

    may need initialization phase to create/deletejobs

  • 8/8/2019 Vikas Clock Driven FINAL

    35/41

    35

    ModeCh

    anges (c

    ont) change scheduling table for periodic jobs

    how to handle outstanding sporadic jobs

    from old mode?

    must still meet their deadlines (?)

    may not be possible due to reduced amounts of

    slack available (?) requires careful handling

  • 8/8/2019 Vikas Clock Driven FINAL

    36/41

    36

    Summary ofCyclic

    Executiveloop forever : wake up and execute at tfintervals (frame boundaries)

    retrieve the data structure which defines a frame

    wake up the periodic task server

    service the sporadic job queue

    service the aperiodic job queue

    perform general maintenance

    manage slack time, perform error checking

  • 8/8/2019 Vikas Clock Driven FINAL

    37/41

    37

    Pros ofClock-Driven

    Schedulingadvantages of clock-driven scheduling:

    simple to understand

    the validation problem is very easy

    (deterministic)

    precedence and dependency can be dealt

    with off-line by choice of the schedule

  • 8/8/2019 Vikas Clock Driven FINAL

    38/41

    38

    Cons ofClock-Driven

    Schedulingdisadvantages of clock-driven scheduling:

    not well suited for applications with varying

    temporal & resource requirements exact nature of the workload model is not known

    a priori

    not always easy to design, usually hard tochange !

    sophisticated approaches overheads

  • 8/8/2019 Vikas Clock Driven FINAL

    39/41

    Weighted Round-Robin

    approach Weighted Round-robin (WRR) is a best-effort

    connection scheduling discipline.

    WRR serves a number of packets for eachnonempty connection.

    Number= normalized ( weighted / mean packet size)

    Drawbacks:

    Mean packet size must be known;

    In a scale of one round WRR doesnt provide fair link

    sharing.

    This

    page

    is

    from WIKIPED

  • 8/8/2019 Vikas Clock Driven FINAL

    40/41

    WRR Example

    The mean packet sizes of class A, B, C are

    2, 3, 4

    The weights of A, B, C are 0.5, 0.3, 0.2

    The normalized weights of A, B and C are:

    A: 0.5/2= 0.25

    B: 0.3/3 = 0.1

    C: 0.2/4= 0.05

    Minimal normalized weight is 0.05

  • 8/8/2019 Vikas Clock Driven FINAL

    41/41

    WRR Example (

    Cont)

    The number of packets serviced for A, B

    and C are:

    NPC = (MNW / weighted)

    A: 0.25/0.05=5

    B: 0.1/0.05=2

    C: 0.05/0.05= 1

    A possible schedule is:

    A A A A A BB C .