• No results found

6.3 A MILP-Based Blocking Analysis Framework for Spin Locks 119

6.3.4 Constraints for PF|N Spin Locks

PF|N locks are a hybrid of the P|N locks and F|N locks considered previously:

they ensure that within each priority level requests are satisfied in FIFO order, and each request can be delayed at most once by a lower-priority request.

To begin with, similar to our analysis for P|N locks above, we establish a wait-time bound that provides a bound on the maximum delay encountered as part of single request for a resource `q issued with priority π. This wait-time bound is then used in turn to bound the maximum interference due to higher-priority requests. To this end, for a global resource `q, a task Ti, and a priority π, let WqPF|N(Ti, π) denote the smallest positive value that satisfies the following recurrence:

WqPF|N(Ti, π) , HP(`q, π) + SP (`q, π) + LP (`q, π) + 1. (6)

Here, HP (`q, π) denotes the maximum delay remote requests with a priority higher than π can contribute to the wait time of Ji’s request, which can be bounded based on the maximum number of jobs that exist during any interval of length WqPF|N(Ti, π):

HP(`q, π) = X

Tx∈τR π>πx,q



njobs Tx, WqPF|N(Ti, π) · Nx,q· Lx,q .

SP(`q, π) accounts for the delay Ji’s request can incur due to remote requests with priority π, which are served in FIFO order:

SP(`q, π) =

m

X

Pk,Pk6=P (Ti)

Txmax∈τ (Pk){Lx,qx,q = π}.

Finally, LP (`q, π) accounts for the delay Ji’s request can incur due to remote

lower-priority requests, which in a PF|N lock (similar to a P|N lock) is limited to at most one critical section:

LP(`q, π) = max

Tx∈τR{Lx,qx,q > π}.

The fixed-point iteration can be aborted if no fixed-point with WqPF|N(Ti, π) ≤ di is found. If the recurrence for WqPF|N(Ti, π) converges, then it bounds the delay of a single request for `q issued with priority π.

Lemma 11. Let t0 denote the time a jobJi of task Ti attempts to lock a resource`q with locking priorityπ, and let t1 denote the time that Ji subse-quently acquires the lock for `q. With PF|N locks,t1− t0 ≤ WqPF|N(Ti, π).

Proof. Let R denote Ji’s request for `q. In a PF|N lock, at any point in time t ∈ [t0, t1), Ji is spinning non-preemptably because either (i) `q is being used by a job with locking priority (with respect to `q) lower than π, (ii) `q is being used by a job with locking priority equal to π, or (iii) `q is being used by a job with a locking priority greater than π. We bound the maximum duration for which each of these conditions can hold during an interval of length WqPF|N(Ti, π).

Case (i): Since requests are satisfied in priority order when using PF|N locks, R can be delayed by at most one lower-priority request for `q, which is accounted for by LP (`q, π).

Case (ii): Since requests of equal priority are satisfied in FIFO order when using PF|N locks, with respect to each other processor, R can be delayed by at most one remote request for `q with priority π, for a total of at most SP(`q, π) time units.

Case (iii): When using PF|N locks, any number of higher-priority requests can delay R. However, analogous to the response-time analysis of non-preemptive fixed-priority scheduling, the maximum number of higher-priority

requests for `qthat exist during [t0, t1) bounds the length of the interval since Jiceases spinning and acquires `qas soon as `q is no longer contended. In any interval of length WqPF|N(Ti, π), at most njobs Tx, WqPF|N(Ti, π) jobs of each remote task Tx with a locking priority πx,q higher than π exist. Each such job issues at most Nx,q requests for `q, and holds `qfor at most Lx,q time units as part of each request. Each remote task Txwith a higher locking priority (with respect to `q) hence holds `q for at most njobs Tx, WqPF|N(Ti, π) · Nx,q· Lx,q during any interval of length WqPF|N(Ti, π). The term HP (`q, π) thus bounds the cumulative length that Ji is spinning while a job with a higher locking priority uses `q during any interval of length WqPF|N(Ti, π).

Since WqPF|N(Ti, π) is by definition the smallest value that satisfies Equa-tion (6) (if one exists), after at most WqPF|N(Ti, π) time units after Ji started spinning, `q is no longer unavailable due to a lower-priority (with respect to

`q) request (case (i)), `q is no longer unavailable due to earlier-issued equal-priority requests (case (ii)), and `q is no longer contended by jobs of tasks with higher locking priority (case (iii)). Hence, throughout an interval of length WqPF|N(Ti, π), resource `q is unavailable for at most WqPF|N(Ti, π) − 1 time units. Thus, Ji’s request is served after at most WqPF|N(Ti, π) time

units after it was issued. 

If WqPF|N(Ti, π) does not exist, that is, if the recurrence Equation (6) does not converge, then starvation cannot be ruled out and Constraints 14 and 15 do not apply.

Similar to the monotonicity properties of WqP|N(Ti, π) (Equations (4) and (5)), WqPF|N(Ti, π) is monotonic with respect to scheduling priority and locking

priority:

∀Th∈ τlh: WqPF|N(Ti, π) ≥ WqPF|N(Th, π) and (7)

π0 < π → WqPF|N(Ti, π) ≥ WqPF|N(Ti, π0). (8)

Based on the wait-time bound WqPF|N(Ti, π), we next present constraints on the maximum spin delay incurred by any Ji when using PF|N locks. Recall from Section 6.3.3 that πqminLP and πqminHP denote the minimum locking priority of any lower-priority and higher-priority task, respectively, on Ti’s processor that accesses the global resource `q. For convenience, we repeat the definitions here:

πqminLP , max

Tx∈τllx,q|`q∈ Q ∧ Nx,q > 0}, πqminHP , max

Tx∈(τlh∪{Ti})x,q|`q∈ Q ∧ Nx,q > 0}.

Similar to Constraint 10 for P|N locks, we can impose a simple constraint on the maximum spin delay due to higher-priority requests.

Constraint 14. In any schedule ofτ with PF|N locks:

∀Pk, Pk6= P (Ti) : ∀`q ∈ Qg : ∀Tx ∈ τ (Pk), πx,q < πqminHP :

Nx,qi

X

v=1

Xx,q,vS ≤ njobs Tx, WqPF|N(Ti, πqminHP) · Nx,q· ncs(Ti, q).

Proof. Analogous to Constraint 10. Each request R for `q issued by Ji

remains incomplete for at most WqPF|N(Ti, π) time units. Due to the mono-tonicity property stated in Equation (7), this also holds true for any request issued for `q by a job of a higher-priority task that preempted Ji. At most ncs(Ti, q) requests are issued for `q by Ti and local higher-priority tasks while Ji is pending. Hence at most ncs(Ti, q) · njobs Tx, WqPF|N(Ti, π) · Nx,q

requests of each remote task Tx with higher locking priority delay Ji. 

Next, we establish a constraint on arrival blocking due to the non-preemptable spinning of lower-priority jobs that are delayed by remote requests with higher locking priority.

Constraint 15. In any schedule ofτ with PF|N locks:

∀`q ∈ Qg : ∀Tx∈ τR, πx,q < πqminLP :

Nx,qi

X

v=1

Xx,q,vA ≤ njobs Tx, WqPF|N(Ti, πqminLP) · Nx,q· Aq.

Proof. Analogous to Constraint 13. A request R issued by a local lower-priority task (with lower-priority at least πqminLP) can be delayed by all remote requests for `qwith higher locking priorities. Exploiting Equations (7) and (8), R remains incomplete for at most WqPF|N(Ti, πqminLP) time units, which limits the maximum number of jobs of each remote task Tx with a (potentially) higher locking priority to njobs Tx, WqPF|N(Ti, πqminLP). The stated bound on the maximum number of transitively blocking remote requests with higher

locking priorities follows. 

Requests issued with the same locking priority are satisfied in FIFO order.

Hence, the spin delay due to remote equal-priority requests can be constrained similarly to how it is constrained in the analysis of F|N locks.

Constraint 16. In any schedule ofτ with PF|N locks:

∀Pk, Pk6= P (Ti) : ∀`q∈ Qg : X

Tx∈τ (Pk) πx,qminHPq

Nx,qi

X

v=1

Xx,q,vS ≤ ncs(Ti, q).

Proof. Analogous to Constraint 8. Due to the FIFO-ordering of equal-priority requests, it follows that, with respect to each remote processor, at most one

earlier-issued, equal-priority request can delay each of the ncs(Ti, q) requests for `q issued by Ji and local higher-priority jobs. 

As mentioned before, assuming that all requests for `q issued by Ji and local higher-priority jobs are issued with locking priority πminHPq is safe due to the monotonicity property stated in Equation (8); the blocking incurred by any Ji does not exceed the bound implied by Constraint 16 if in the actual schedule some requests of Ji or local higher-priority jobs are issued with a locking priority higher than πqminHP .

Next, we constrain the maximum transitive delay due to the non-preemptable spinning of lower-priority jobs that are delayed by earlier-issued remote requests with equal locking priority.

Constraint 17. In any schedule ofτ when using PF|N locks:

∀`q ∈ Qg : ∀Pk, Pk6= P (Ti) : X

Tx∈τ (Pk) πx,qqminLP

Nx,qi

X

v=1

Xx,q,vA ≤ Aq.

Proof. Analogous to Constraint 9. Since requests with the same priority are served in FIFO-order, at most one request per processor for a resource `q is-sued with the same locking priority can contribute to Ti’s arrival blocking. 

Finally, we constrain the maximum spin delay due to remote requests with lower locking priority.

Constraint 18. In any schedule ofτ with PF|N locks:

∀`q ∈ Qg : X

Tx∈τR πx,qminHPq

Nx,qi

X

v=1

Xx,q,vS ≤ ncs(Ti, q).

Proof. Analogous to Constraint 11. Each request for `q issued by Ti or a local higher-priority job can be delayed at most once by a remote request for

`q issued with a lower priority. 

Similar reasoning applies to the maximum transitive delay due to the non-preemptable spinning of a lower-priority job that is delayed by a remote request with a lower locking priority.

Constraint 19. In any schedule ofτ with PF|N locks:

∀`q∈ Qg : X

Tx∈τR πx,qminLPq

Nx,qi

X

v=1

Xx,q,vA ≤ Aq.

Proof. Analogous to Constraint 12. If Ji is transitively blocked due to a request for `q (i.e., if Aq= 1), then at most one remote request for `q issued with a priority less than πqminLP can contribute to Ti’s arrival blocking. 

This concludes our analysis of PF|N locks. Together with the generic Con-straints 1–7, the PF|N-specific ConCon-straints 14–19 define a MILP that bounds the maximum blocking incurred by any Ji. In the unlikely case that the re-currence given in Equation (6) does not converge for some `q, the constraints that depend on the wait-time bound WqPF|N(Ti, π), namely Constraints 14 and 15, must be omitted from the MILP for this resource `q.

Next, we present constraints for the analysis of preemptable spin locks. We start with generic constraints applicable to all preemptable types considered in this work.