Chapter 2: Background and Prior Work
2.1 Real-Time Scheduling
2.2.2 Blocking Analysis
Brandenburg and Anderson (Brandenburg and Anderson, 2014) formalized two classes of techniques to incorporate the effects of priority-inversion blocking into schedulability analysis for suspension-based locking protocols:suspension-oblivious(s-oblivious)analysis, in which suspensions due to pi-blocking are modeled as computation, andsuspension-aware(s-aware)analysis, in which suspensions due to pi-blocking are incorporated directly into schedulability analysis. These techniques rely upon different definitions of pi-blocking given next, which are visually compared in Figure 2.5.
Definition 2.1. Unders-awareschedulability analysis, a jobJiincurss-aware pi-blockingat timetifJiis pending but not scheduled and fewer thanmhigher-priority jobs areready.
Definition 2.2. Unders-obliviousschedulability analysis, a jobJiincurss-oblivious pi-blockingat timetif Jiis pending but not scheduled and fewer thanmhigher-priority jobs arepending.
For spin-based locking protocols, there is a third type of pi-blocking.
Definition 2.3. A jobJiincursspin-based blocking(s-blocking)at timetifJiis spinning (and thus scheduled) waiting for a resource.
Note that spin-based blocking is computation, as the task actually occupies a processor while spinning. In comparison, both s-oblivious and s-aware pi-blocking bound times in which the task is suspended and therefore not executing.
Example 2.4. Consider the exampleEDFschedule depicted in Figure 2.5. At timet=1, three tasks are released and taskτ1andτ2begin executing. At timet=2,τ2issues a request that is satisfied, and taskτ1 also issues a request that is blocked byτ2.τ1suspends to wait until the resource is available, and relinquishes its processor toτ3. Att=3,τ3also issues a request, which is blocked byτ2. Whenτ2completes its critical section at timet=5,τ1acquires the resource and executes its critical section untilt=7 when it completes andτ3executes its critical section.
0
5
10
⌧1
⌧2
⌧3
CPU 0
CPU 1 S-oblivious Pi-Blocking
S-aware Pi-Blocking Critical Section
time
Figure 2.5: Illustration adapted from (Brandenburg and Anderson, 2010a) of the difference between s- oblivious and s-aware analysis.G-EDFscheduling is assumed.
Now let us consider the blocking that occurs in this schedule. First, consider the blocking byτ1during t∈[2,5).τ1is the highest priority job and therefore there are no higher-priority pending or ready jobs, so by Definitions 2.1 and 2.2,τ1is both s-aware and s-oblivious pi-blocked during this interval.
Next consider the blocking byτ3duringt∈[3,5).τ1is pending but not ready, as it is suspended, and therefore only one higher-priority task,τ2is ready. By Definition 2.1,τ3is s-aware pi-blocked during this interval. However, bothτ1andτ2are pending duringt∈[3,5), and therefore by Definition 2.2,τ3 is not s-oblivious pi-blocked. Afterτ2completes at timet=5,τ3becomes both s-aware and s-oblivious pi-blocked.
♦
An intuitive way to think about s-oblivious vs. s-aware pi-blocking is to consider the suspensions of higher-priority jobs as if they occupied a processor. If a taskτiis blocked but allmprocessors are busy, either with actual computation, or the suspensions of higher-priority jobs, which we are thinking of as occupying a processor, thenτiis not s-oblivious pi-blocked. This observation is reflected in the following corollary to Definition 2.2
Corollary 2.1. A jobJimay only be s-oblivious pi-blocked if it is among the topmhighest-priority pending jobs.
This corollary in particular informs the design of many locking protocols, which we will discuss later in this section.
Causes of pi-blocking. Pi-blocking can occur in one of two scenarios. First, a job that has issued a request and is blocked waiting to acquire a resource is said to experiencerequest blocking. Second, many locking
protocols employ a progress mechanism such as priority inheritanceor priority boosting (described in more detail later) to ensure that a resource-holding job is scheduled. These progress mechanisms work by increasing the priority of a task from its original or base priority, to a highereffective priority. For example, if a low-priority resource-holding job is priority boosted (or scheduled at the highest priority) to ensure progress, then a high-priority non-resource-accessing job may be pi-blocked, as it is pending but not scheduled. This gives rise toprogress-mechanism-related(PMR)pi-blocking,3as a lower-priority job can execute while a higher-priority job is forced to wait, even if it has not issued a resource request. This second source of blocking can introduce a great deal of analysis pessimism, as it affects all tasks, regardless of whether they access shared resources or not. Brandenburg (2013a) defined a locking protocol with no progress-mechanism-related pi-blocking to beindependence preserving, because independent tasks are not affected by the progress mechanism of the dependent, resource-using tasks.
Incorporating blocking into schedulability analysis. S-oblivious and s-aware pi-blocking bounds are used in different schedulability tests. S-oblivious pi-blocking bounds can be incorporated into schedulability tests that do not explicitly model suspensions by inflating the execution time of each task by its s-oblivious pi-blocking bound. Analytically treating suspensions as computation is safe as the corresponding schedule without suspensions will have response-time bounds at least that of the schedule with suspensions. This s-oblivious approach allows for blocking bounds to be easily applied in the context of many schedulability tests developed for independent systems, discussed in the previous section.
Alternatively, schedulability analysis may besuspension-aware. In such s-aware schedulability tests, the maximum suspension length is incorporated into the task model, and the effects of those suspensions are dealt with explicitly in the schedulability test. Such tests can be used to account for the effects of blocking by treating s-aware blocking bounds as the suspension lengths. For example, Liu and Anderson (2013) extended the schedulability test of Baruah (2007) to consider tasks that suspend. Suspensions are notoriously difficult to tightly analyze, and indeed such analysis is NP-complete in the strong sense (Ridouard et al., 2004). Consequently, there exist fewer s-aware schedulability tests, especially for multiprocessor systems. Furthermore, many studies have shown s-oblivious blocking analysis to be competitive, if not preferable to, s-aware analysis in many cases (Brandenburg, 2011, 2014; Ward, 2015). For a more complete discussion 3Under some locking protocols and analysis assumptions, PMR pi-blocking can only occur at job release, and in such cases is
Scheduled T1 T2 T3 Deadline Release TCompleted 0 5 10
Scheduled with resource
T
T T
time
Figure 2.6: Example of an unbounded priority inversion, described in Example 2.5.
of suspensions and suspension-aware schedulability analysis, we refer the interested reader to (Chen et al., 2016) and (Liu, 2013).