Sporadic System

download Sporadic System

of 3

Transcript of Sporadic System

  • 8/14/2019 Sporadic System

    1/3

  • 8/14/2019 Sporadic System

    2/3

    dustrial process from produc-tion mode to safety mode. Thethreads that transition the sys-tem between these two modesare sporadic threads.

    Likewise, many practical ap-plications contain threads withstochastic computation inter- vals such as a data processorthat performs different compu-tations depending on the infor-mation within the data ratherthan a single computation thatis dependent only on the quan-tity of data.

    OverloadA system goes into overload when events interarrival timesare shorter than planned orwhen threads execution inter- vals are longer than planned.Under these conditions, the sys-tem must discard events or allow

    one or more threads to miss theirdeadlines to allow more criticalthreads to complete on time.

    Overload results when pe-ripherals and external agentsconform to their true naturerather than to designers ideal-ized assumptions. Hardware de-vices may fail, generating spuri-ous signals greatly out of linewith proper behavior. Errant ormalicious code, improperlytrained or malicious users andunusual number of externalagents can generate excessiveevent traffic that violates de-signers statistical assumptions.

    Several practical examplesinclude Mothers Day callers,who are notorious for overload-ing the phone network; net-work packet broadcast storms;focused denial of service at-tacks; large files fed at highspeed into serial ports; mal-functioning disk controllers;faulty sensors; electromagnetic

    disturbances; errant, dynami-cally loaded device driver codethat forgets to clear interruptconditions; and the stuck activeinterrupt request signals myteam encountered.

    The choice of schedulingpolicy makes a dramatic differ-ence on how the system behavesin overload, and determineswhether a designer can predict-ably characterize the systemduring overload. For example,the dynamic priority earliestdeadline first (EDF) schedulingpolicy performs poorly in over-load. Since EDF is used to as-sign thread priorities on the fly,the designers of the system can-not predict which specific

    threads will miss their dead-lines during overload condi-tions. Furthermore, an over-running thread may causeother future threads to misstheir deadlines.

    On the other hand, a designerusing a static-priority policy canperform schedulability analysisto assure that the deadlines ofcritical threads will be satisfiedeven in overload. Employing apredictable scheduling policy isespecially important for safety-

    critical systems, which must re-main predictable even in over-load. For example, an overloadedsystem that misses a few user in-terface updates is preferable toone that fails to close controlvalves.

    While poorly designed sys-tems often fail to satisfy theconstraints of critical and lessimportant threads in overload,well-designed systems must se-lectively process events to as-sure that the deadlines of criti-cal threads will always be met.POSIXs sporadic schedulingpolicy makes good design easy.

    Sporadic schedulingIEEEs POSIX specification

    suite describes a programminginterface for portable operatingsystems. In 1999, the POSIX Working Group introducedIEEE 1003.1d to specify addi-tional real-time extensions forthe C language. Section 13.2.4of that standard adds the spo-radic scheduler policy to theround robin and FIFO policiespreviously standardized. ThePOSIX Working Group speci-fied the sporadic schedulingpolicy precisely for handling

    aperiodic and sporadic eventsand threads running within thecontext of a static-priority pre-emptive scheduler.

    In addition to the single,normal-priority level used forFIFO and round-robin schedul-ing, the parameters of a spo-radic policy include a second,lower background priority; areplenishment interval; an ex-ecution budget; and a maxi-mum number of replenish-ments allowed within each re-plenishment interval. To-gether, the replenishment in-terval and execution budget de-fine the maximum processorutilization granted to a threadat its normal priority.

    If a thread ever requires moreprocessor time than its budgetallows, the sporadic schedulingpolicy dynamically lowers thepriority of the thread to itsbackground priority. Whileat either priority, the schedulertreats the thread identically toother threads with the conven-tional FIFO scheduling policy.For example, priority inherit-ance and positioning withinready queues remain the samethe important differences are

    the enforcement of the threadsexecution time and priority re-assignment of the thread.

    By lowering the threads pri-ority, the system allows otherthreads to execute that the spo-radic thread would otherwisepreempt at its normal priority.Dynamic adjustment of threadpriorities is the key capability ofthe policy that enables pro-grammers to build predictablesystems.

    A sporadic thread consumesexecution time whenever it isrunning. The scheduler de-ducts consumed time from thethreads budget each time thethread blocks or the schedulerpreempts it.

    LISTING 1 Sporadic scheduling example

    #define NIC_SPORADIC_BKGD_PRIORITY 5 // just above dirt

    #define NIC_SPORADIC_PRIORITY 21 // above most other I/O

    #define NIC_SPORADIC_MAXREPLENISHMENTS 3 // blocked only 3 times at most

    #define NIC_SPORADIC_PERIOD 1024000 // 1024 microsecs

    #define NIC_SPORADIC_BUDGET 400000 // 400 microsecs

    // initialize an attributes structure and configure it for sporadic scheduling

    if (pthread_attr_init(&pattr) != EOK) {...}

    // override the default of inheriting policies from our parent

    if (pthread_attr_setinheritsched(&pattr, PTHREAD_EXPLICIT_SCHED) != EOK) {...}

    // configure the normal and background priorities, the budget interval, and

    // the maximum number of replenishments

    param.sched_ss_low_priority = NIC_SPORADIC_BKGD_PRIORITY;

    param.sched_priority = NIC_SPORADIC_PRIORITY;

    param.sched_ss_max_repl = NIC_SPORADIC_MAXREPLENISHMENTS;

    nsec2timespec(&param.sched_ss_repl_period, NIC_SPORADIC_PERIOD);

    nsec2timespec(&param.sched_ss_init_budget, NIC_SPORADIC_BUDGET);

    if (pthread_attr_setschedparam(&pattr, &param) != EOK) {...}

    // now set the scheduling policy to sporadic

    if (pthread_attr_setschedpolicy(&pattr, SCHED_SPORADIC) != EOK) {...}

    // create the thread/task and have it explicitly use sporadic parameters

    if (pthread_create(&devData->threadId, &pattr, rtl_EventHandler, devData) != EOK) {...}

    Listing 1: The POSIX C code used to configure a sporadic scheduling policy for the packet reception thread of the network driver is found here.

  • 8/14/2019 Sporadic System

    3/3