220 likes | 359 Views
Sporadic and Aperiodic Processes. Lecture 15. Sporadic and Aperiodic. We can expand on the simple model for periodic processes to include sporadic (and aperiodic) processes by interpreting T the period as the minimum inter-arrival interval.
E N D
Sporadic and Aperiodic Processes Lecture 15
Sporadic and Aperiodic • We can expand on the simple model for periodic processes to include sporadic (and aperiodic) processes by interpreting T the period as the minimum inter-arrival interval. • A sporadic process with a value of 20ms is guaranteed not to arrive more than once in any 20ms interval. • In reality it could arrive less frequently.
Sporadic and Aperiodic • The other requirement concerns the deadline. The simple model assumes D=T for sporadic processes this is unreasonable. • Why might this be unreasonable? Think about what a sporadic process might be used for. • What if it was an error-handling routine or a routine that was responding to a failure. What should its deadline be?
Sporadic and Aperiodic • We must therefore consider D < T for sporadic processes. • Even for periodic processes it may be useful to consider D < T. • It turns out that for periodic processes such as FPS when doing the response time analysis all we need to do is consider win+1 < D.
Hard and Soft Processes • For sporadic processes, average and maximum arrival rates may be defined. • Unfortunately the worst-case figure is considerably higher than the average. • Interrupts may often arrive in bursts and an abnormal sensor reading may lead to additional computations.
Hard and Soft Processes • It follows that measuring schedulability with worst-case figures may lead to very low processor utilization. • Therefore the following rules are used to schedule sporadic processes • Rule 1 - all processes should be scheduled using average execution times and average arrival rates. • Rule 2 – all hard real-time processes should be schedules using worst-case execution times and worst-case arrival rates of all processes (including soft).
Hard and Soft Processes • The consequence of Rule 1 is that there may be a situation in which it is not possible to meet all current deadlines. This condition is known as transient overload. • Rule 2 gives rise to unacceptably low utilizations for normal execution, therefore direct action should be taken to try and reduce the worst-case execution times (or arrival times).
Aperiodic Processes and Fixed Priority Servers • A simple way to schedule aperiodic processes, within a priority-based scheme is to run such processes at a priority below the priorities assigned to hard processes. • This forces these processes into the background. Although a safe scheme the result maybe a lot of soft processes are missing deadlines. • To improve this situation a server model is used.
Aperiodic Processes and Fixed Priority Servers • The Deferrable Server, a server process (S) is setup in the analysis to execute for Cs at a period of Ts. All hard processes are scheduled taking into account this process. • This introduces a gap in the schedule that lasts Cs time units with a period of Ts. Any aperiodic processes that need to execute can execute in this reserve capacity. • The aperiodic process executes until it runs out of capacity or finishes. This capacity is replenished every Ts time units.
Aperiodic Processes and Fixed Priority Servers • A Sporadic Server (SS) differs from the DS in it replenishment policy. • In SS when a process arrives at time t and uses capacity c, then the excess capacity Cs-c is then replenished one Ts time units later. In general SS can furnish higher capacity than DS but has increasing implementation overhead to deal with. • At the task level Ada supports SS and POSIX also supports SS at the library-level.
Aperiodic Processes and Fixed Priority Servers • These servers limit the capacity that is available to aperiodic processes, they also can be used to ensure that sporadic processes do not execute more often than expected. • The servers can be described as bandwidth preserving • Make CPU resources available immediately to aperiodic processes (if there is capacity) • Retain the capacity for as long as possible if there are currently no aperiodic prcesses (by allowing the hard processes to execute)
POSIX Scheduling • http://www.opengroup.org/onlinepubs/007904975/basedefs/sched.h.html
Process Interactions and Blocking • So far we have assumed that all tasks are independent, clearly this is not a reasonable assumption. • Processes interact safely using, shared memory, semaphores, protected objects etc… • All this leads to the possibility that a process is waiting for some future event has happened (gaining access to a lock on a semaphore).
Process Interaction and Blocking • One problem that occurs as a result of process interaction is priority inversion. • Priority inversion is defined as a higher priority process waiting for a lower priority task. • Effectively the higher priority task is blocked.
Example • Consider four periodic processes a,b,c and d. • Assume a deadline monotonic scheme with d having the highest priority and a the lowest. • Further assume d and a and d and c share a critical section denoted Q and V protected by mutual exclusion.
Example E represent a tick of execution time and Q and V represent a tick of execution time with access to Q or V. Therefore process c executes for 4 ticks. Draw the GANTT chart.
Example D blocked by a’s lock on Q a can’t release block due to preemption by b. Lower priority b finishes before higher priority d d c b a 0 2 4 6 8 10 12 14 16 18 20 Executing with V locked Executing Blocked Executing with Q locked Preempted
Priority Inversion and Blocking • To avoid the problem of priority inversion, is to use priority inheritance. • In a priority inheritance scheme a processes priority is no longer static. • If process p is suspended waiting for process q to undertake some computation then the priority of q becomes equal to the priority of p if it is lower to start with. • Therefore in the previous example a gets d’s priority. • Redo the GANTT chart with this in mind.
Example E represent a tick of execution time and Q and V represent a tick of execution time with access to Q or V. Therefore process c executes for 4 ticks. Draw the GANTT chart.
Example Priority Inheritance d is blocked by a’s lock on Q therefore a gets d’s priority giving as preference over c and b d c b a 0 2 4 6 8 10 12 14 16 18 20 Executing with V locked Executing Blocked Executing with Q locked Preempted
Response Time • The maximum blocking time, Bi ,that a process i can suffer depends on the number of critical sections. • An upper bound on B is where usage(k,i)=1 if resource k is used by a least one process with a priority less than Pi and a least one process with a higher priority than Pi otherwise it is 0.
Response Time • R = C + B + I This can be solved using our recurrence relationship. The result assumes a block problem and is therefore pessimistic.