• No results found

R 2 DGLP

In document Ward_unc_0153D_16612.pdf (Page 143-147)

Chapter 3: Real-Time Nested Locking Protocol ( RNLP )

5.1 k-exclusion

5.1.3 R 2 DGLP

The clusteredk-exclusion OMLP (CK-OMLP) (Brandenburg and Anderson, 2011), which employs JRPD, uses a single FIFO-ordered queue to order the acquisition of replicas. Under JRPD, every replica- holding job is scheduled, and thus all requests make progress and the maximum duration of pi-blocking is O(m/k). This design does not extend to RRPD. Under RRPD, a replica-holding job is not guaranteed to be scheduled (if higher-priority work is present), and thus if only one jobJi with an incomplete replica request has sufficient priority to be scheduled, only one replica-holding job would be scheduled. Thus it is possible for all requests to be serialized on a single resource, which results in an max(0,(m−k1)Lmax)blocking bound, which is suboptimal, as shown in Figure 5.3. Instead theR2DGLPemploys a similar queue structure to theO-KGLP(Elliott and Anderson, 2013) and thek-FMLP(Elliott, 2015), in which there arekaqueues for each resource`a, one per replica.

Structure. In theR2DGLP, access to each replica of a resource`ais arbitrated by an individual FIFO ordered replica queue denoted KQx. Within each replica queue, priority inheritance is used to ensure progress. As will be proven later, this design limits the maximum queue length todm/ke, and thus the maximum duration of pi-blocking isO(m/k), which is optimal given the known lower bound ofΩ(m/k)(Brandenburg, 2011, Lemma 6.13). The queue structure of theR2DGLPis shown in Figure 5.4. In the following rules and analysis, we consider, without loss of generality, only a single resource`a, withkreplicas.

Figure 5.4: Queue structure of theR2DGLP.

K1 Ji is enqueued on the shortest KQx when it issuesR. Ji suspends untilRis satisfied (if KQx was non-empty).

K2 Ris satisfied whenJibecomes the head of KQx. A resource-holding job is ready.

K3 The head of KQxinherits the highest effective priority (which could be a donated priority) of any job in KQx.

K4 Jiis dequeued from KQxwhenRis completed. The new head of KQx, if any, acquires replicax.4 Ji’s priority donor (if any) may then issue a replica request subject to Rule D1.

Example 5.1. Consider a G-EDF-scheduled system onm=4 processors with a single resource`a with ka=2 replicas as depicted in Figure 5.5. At timet=0, jobsJ1andJ2are released with deadlines ofd1=10 andd2=14. At timet=1,J3andJ4are released with deadlinesd3=15 andd4=13. Also at timet=1, bothJ1andJ2request and acquire a replica of`a. At timet=2,J3requests a replica of`a, and is enqueued in KQ2and suspends by Rule K1. Then at timet=3,J5andJ6are released with deadlines ofd5=d6=12. At this time, J1,J4,J5, andJ6have the four highest effective priorities, and therefore are scheduled, even thoughJ2is holding a replica of`a. At timet=4,J4requests a replica of`a, enqueues in KQ1and suspends by Rule K1. Also at timet=4,J5requests a replica of`aand because there arem=4 jobs with incomplete replica requests, by Rule D2,J5must donate toJ3, the job with the lowest effective priority among the jobs with incomplete requests for a replica of`a.J2then inheritsJ3’s effective priority, orJ5’s priority, by Rule K3. At timet=5,J1releases its replica of`a, allowingJ4, the next job in KQ1to acquire a replica of`a. Also at timet=5,J6requests a replica of`a, and is enqueued in KQ1. J4also inheritsJ6’s priority by Rule K3. 4As an implementation optimization, if KQ

xis left empty afterJidequeues, a request from another KQycan migrate to KQxand

KQ1 KQ1 KQ2 KQ1 KQ1 KQ2 KQ2

time

Figure 5.5: Figure depicting the task system in Example 5.1. In this example,k=2 andm=4.

At timet=6,J2releases its replica of`a, andJ3acquires it. At timet=7,J4releases its replica, which allowsJ6to begin its critical section. Att=8,J3 finishes its critical section, andJ5’s donation obligation is finally completed by Rule D6, and it therefore is allowed to request a replica of`a. At this time,J5can immediately acquire its replica and begin its critical section. Finally, at timest=9 andt=10,J6 andJ5 respectively complete their critical sections and the example returns to ordinary G-EDF scheduling. ♦

Analysis. Next, we analyze the worst-case pi-blocking of theR2DGLP. By Lemma 5.4, if a job is pi-blocked it either has an incomplete replica request or it is a priority donor. Thus, the total duration of pi-blocking is equal to the maximum duration of time a job can be pi-blocked while it is a priority donor as well as the maximum duration of time a job can be pi-blocked while it has an incomplete replica request. We analyze each of these times separately.

Proof. By Lemma 5.2, there are no more thanmjobs with incomplete replica requests. By Rule K1, jobs are enqueued in the shortest queue upon request, and thus a jobJiwill never be enqueued on a queue of length longer thandm/ke, otherwise there would have been a shorter queue on whichJiwould have enqueued. Lemma 5.7. Rule K3 ensures Property RRP1.

Proof. If a jobJiwith an incomplete request in KQxhas sufficient effective priority to be scheduled, then by Rule K3, the job at the head of KQx inheritsJi’s effective priority. Thus the replica holder is scheduled, and Jimakes progress.

Lemma 5.8. A jobJican be pi-blocked for(dm/ke −1)LmaxinKQx.

Proof. By Lemma 5.7, a job that is pi-blocked makes progress. By Lemma 5.6, there are at mostdm/ke −1 jobs that are enqueued ahead ofJiin KQx. Thus, the maximum duration of pi-blocking in KQx is(dm/ke − 1)Lmax.

Lemma 5.9. A jobJd can be pi-blocked for a maximum duration ofdm/keLmaxwhile it is a priority donor.

Proof. Follows from Lemmas 5.5 and 5.8.

Theorem 5.1. The maximum duration of pi-blocking a jobJican experience waiting for a replica per request is(2dm/ke −1)Lmax.

Proof. Follows from Lemma 5.4, 5.8, and 5.9.

Note that the O-KGLP(Elliott and Anderson, 2013), the only other known asymptotically optimal k-exclusion locking protocol under s-oblivious analysis that does not cause release-blocking, has a worst-case pi-blocking bound of(2dm/ke+2)Lmax. Thus, the locking protocol we present has a worst-case blocking bound that improves upon theO-KGLPby 3Lmax. These blocking bounds can be seen in Table 5.1. As we show next in Section 5.1.4, this improvement can be quite significant when critical sections (i.e.,Lmax) are long.

Additionally, note that whenk=1, the blocking bound is(2m−1)Lmax, which is the same as that of the globalOMLP(Brandenburg and Anderson, 2010a). TheR2DGLPis therefore a more flexible locking protocol in that it can be used either for a mutex lock, or ak-exclusion lock, both with good blocking bounds.

Release-blocking Request-blocking

R2DGLP 0 (2dm/ke −1)L

max

O-KGLP 0 (2dm/ke+2)Lmax

CK-OMLP dm/keLmax (dm/ke −1)Lmax k-FMLP dn/keLmax (dn/ke −1)Lmax

Table 5.1: Blocking bounds of severalk-exclusion suspension-based locking protocols.

In document Ward_unc_0153D_16612.pdf (Page 143-147)