• No results found

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

6.3.3 Constraints for P|N Spin Locks

P|N locks ensure that a request is blocked at most once by another request with lower priority at the expense that there is no immediate bound on the number of blocking higher-priority requests. In the following, we denote the locking priority of requests for resource `q issued by jobs of a task Tx as πx,q,

and the set of remote tasks with respect to Ti as τR:

τR, {Tx | P (Tx) 6= P (Ti) } .

We apply response-time analysis [19] on a per-request basis to obtain an upper bound on the delay encountered when issuing a single request for a resource

`q with priority π. For a resource `q and task Ti, let WqP|N(Ti, π) denote the smallest positive value (if any) that satisfies the following recurrence:

WqP|N(Ti, π) = S(`q, π) + LP (`q, π) + 1 where (3) S(`q, π) = X

Tx∈τR∧πx,q≤π

njobs(Tx, WqP|N(Ti, π)) · Nx,q· Lx,q and

LP(`q, π) = max

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

The recurrence can be solved via fixed-point iteration. Since a bound on the delay exceeding Ti’s deadline cannot be used as part of (effective) constraints, the fixed-point iteration can be aborted if no fixed-point with WqP|N(Ti, π) ≤ di is found. If a solution for WqP|N(Ti, π) satisfying the above recurrence can be found, then WqP|N(Ti, π) bounds the delay of a single request. We formalize this property with the following lemma.

Lemma 10. Lett0 be the time a jobJi of taskTi attempts to lock resource

`qwith locking priorityπ, and let t1be the time thatJisubsequently acquires

`q. With P|N locks, t1− t0 ≤ WqP|N(Ti, π).

Proof. Analogous to the response-time analysis of non-preemptive fixed-priority scheduling. The response-time of Ji’s request—that is, the maximum wait time WqP|N(Ti, π)—depends on the sum of the maximum length of one lower-priority request LP (`q, π) and all higher-priority requests of all remote tasks issued during an interval of length WqP|N(Ti, π), that is, S(`q, π). Hence, throughout an interval of length WqP|N(Ti, π), by definition of WqP|N(Ti, π),

resource `q is unavailable for at most WqP|N(Ti, π) − 1 time units. Thus, Ji’s request is served after at most WqP|N(Ti, π) time units after it was issued. 

In the constraints we establish for the analysis of P|N locks, we exploit two simple monotonicity properties of WqP|N(Ti, π), which we next state explicitly for the sake of clarity. First, WqP|N(Ti, π) is monotonic with respect to scheduling priority. That is, the wait time of a request for `q issued by a local higher-priority task Th with the same locking priority π is no longer than the wait time of Ti’s request. (In fact, the per-request wait-time bound is independent of scheduling priority since jobs spin non-preemptably.) Formally,

∀Th ∈ τlh : WqP|N(Ti, π) ≥ WqP|N(Th, π). (4)

The second monotonicity property that we exploit pertains to the locking priority π: in a P|N lock, requests issued with higher locking priority natu-rally do not incur more spin delay than requests issued with lower locking priority:

π0 < π → WqP|N(Ti, π) ≥ WqP|N(Ti, π0). (5)

The above monotonicity properties enables us to use wait-time bounds in constraints computed with the minimum locking priority of any requests issued by local higher and lower priority tasks, respectively. To simplify the notation, we define

πqminLP , max

Tx∈τllx,q|Nx,q > 0} and πminHPq , max

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

to be the minimum locking priority of any lower-priority and higher-priority task, respectively, on Ti’s processor that accesses the global resource `q. These two definitions are needed because Ji might be delayed transitively due to requests of local tasks with locking priorities lower than Ti’s own locking priority. To obtain valid (and simple) constraints, we make the following two simplifications: first, for a given resource `q, we assume that Ji and all higher-priority jobs that preempt Ji issue requests with locking priority πqminHP (the lowest locking priority that any such job uses), and second, we assume that all local lower-priority jobs request `q with locking priority πqminLP (again, the lowest locking priority used by any local lower-priority job). Both of these are safe assumption due to the monotonicity property stated in Equation (5). However, we note that these simplifications are a potential source of pessimism that could be avoided with a significantly more complicated analysis setup, which we leave to future work.

Given WqP|N(Ti, π) (i.e., if it exists), we can constrain the the number of requests for `q that can contribute to Ti’s spin delay. First, we consider requests issued with higher or equal priority.

Constraint 10. In any schedule ofτ with P|N locks:

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

Nx,qi

X

v=1

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

Proof. Let R denote a request for a resource `q by Ti or a local higher-priority task. By the definition of πqminHP, R has at least the locking priority πqminHP and, by Lemma 10 and monotonicity properties of WqP|N stated in Equations (4) and (5), is hence delayed by at most WqP|N(Ti, πqminHP) time units (note that WqP|N(Ti, πqminHP) ≥ WqP|N(Th, πh,q) if Th ∈ τlh and πminHP ≥ π ). During an interval of length WP|N(T, πminHP), jobs of a

remote task Tx issue at most njobs(Tx, WqP|N(Ti, πminHPq )) · Nx,q requests for `q. The stated bound follows as at most ncs(Ti, q) requests for `q with a priority of at least πqminHP are issued by Ti or local higher-priority tasks. 

Requests with lower priority cause Ji to incur (transitive) spin delay at most once for each request by Ti or a task in τlh.

Constraint 11. In any schedule ofτ with P|N locks:

∀`q∈ Qg: X

Tx∈τR πx,qqminHP

Nx,qi

X

v=1

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

Proof. Suppose not. Then at least one request for global resource `q issued by Ti or a local higher-priority task is delayed more than once by a request for `q from a different processor issued with a lower priority. However, by definition P|N locks ensure that each request is blocked at most once by a lower-priority request for the same resource. Contradiction. 

Next, we consider arrival blocking. The number of lower-priority requests that cause arrival blocking is bounded by Aq.

Constraint 12. In any schedule ofτ with P|N locks:

∀`q∈ Qg: X

Tx∈τR πx,qqminLP

Nx,qi

X

v=1

Xx,q,vA ≤ Aq.

Proof. Suppose not. In case Aq = 0, by definition of Aq, Ti incurs transitive arrival blocking due to a request for `q, although no access for `q from a local lower-priority task causes Ti to incur arrival blocking, which is impossible.

In case Aq = 1, a request for `q with priority at least πminLPq is delayed

more than once by requests for `q issued on other processors with a locking priority of less than πminLPq . However, with P|N locks, a request for a re-source `q cannot be delayed by more than one lower-priority request for `q.

Contradiction. 

Next, we constrain the arrival blocking due to requests with higher priority issued from other processors.

Constraint 13. In any schedule ofτ with P|N locks:

∀`q ∈ Qg : ∀Tx ∈ τR, πx,q ≤ πminLPq :

Nx,qi

X

v=1

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

Proof. Let R denote the request by a local lower-priority job that causes Ti to incur arrival blocking. By definition of πqminLP, R has a priority of at least πqminLP, and, by Lemma 10, is hence delayed by at most WqP|N(Ti, πqminLP) time units (note that WqP|N(Ti, πqminLP) ≥ WqP|N(Tl, πl,q) if Tl ∈ τll and πqminLP ≥ πl,q). During an interval of length WqP|N(Ti, πminLPq ), jobs of a remote task Tx issue at most njobs(Tx, WqP|N(Ti, πqminLP)) · Nx,q requests for

`q. The bound follows as Ti is arrival-blocked via `q only if Aq = 1. 

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

Next, we present the constraints for the analysis of PF|N locks.