This page documents the proof of opacity of the Fastlane algorithm [SEFM18]. The FastLane algorithm itself is from [Wamhoff et al 2013]. We prove that when the STM implementation switches between using a sequential implementation (SEQ) when a single thread is executing, using the FastLane algorithm for a low number of threads, and another (arbitrary) opaque implementation IMPL for a large number of threads, then under some constraints the result is opaque itself. To prove opacity of an algorithm, it is sufficient to encode it as an IO automaton (where each step of the algorithm is a transition of the automaton), and to prove that this automaton refines TMS2. The proof consists of 4 parts:
a) switch(SEQ,FastLane) refines TMS2, and
b) switch(switch(SEQ,FastLane),IMPL) also refines TMS2 under certain constraints on IMPL (one of them being that IMPL refines TMS2 by a forward simulation).
Both proofs are done by discharging (instances of) the assumptions of the generic theorem as proof obligations.
START
S1: if (masterID = pid)
S2: then ttas-lock (master)
S3: if(masterID = pid)
MSNT: then MASTERSTART
S4: else ttas-unlock(master)
HSNT: HELPERSTART
else if(pessimistic)
S5: ttas-lock (master)
S6: masterID := pid
MSNT: MASTERSTART
HSNT: else HELPERSTART
MASTERSTART
MSNT:
MS: return
MASTERREAD
MR1: val = mem(addr)
MR2: return val
MASTERWRITE
MW1: if even(cntr)
MW2: then cntr := cntr +1
MW3: dirty[hash(addr)] := cntr
MW4: mem(addr) := val
MW5: return
MASTERCOMMIT
MC1: if odd(cntr)
MC3: then cntr := cntr + 1
MC3: ttas-unlock(master)
C: return
HELPERSTART
HSNT
HS: start := cntr &~1
HI: return
HELPERREAD
HR1: if CONTAINS(write-set, addr)
HR2 + HR21: then return GET(write-set, addr)
HR3: val := mem(addr)
HR4: if (dirty[hash(addr)] > start)
A1: then ABORT
HR5: ADD(read-set, addr)
HR6: return val
HELPERWRITE
HW1: if (dirty[hash(addr)] > start)
A1: then ABORT
HW2: PUT(write-set, addr, val)
HW3: return
HELPERCOMMIT
HC1: if EMPTY(write-set)
then return
HC2: mcs-lock(helpers)
HC3: ttas-lock (master)
HC4: if ¬(VALIDATE)
HC6: then ttas-unlock (master)
HC7: mcs-unlock (helpers)
A1: ABORT
HC8: cntr := cntr + 1
HC9: foreach(addr,val) in write-set
HC9a: do dirty[hash(addr)] := cntr
mem(addr) := val
HC10: cntr := cntr + 1
HC11: ttas-unlock(master)
HC12: mcs-unlock (helpers)
C: return
VALIDATE
HC4: if(cntr ≤ start)
HC8: then return true
HC5: foreach addr in(read-set ∪ write-set)
HC4: do if(dirty[hash(addr)] > start)
HC6: then return false
HC8: return true
ABORT
A1: CLEAR(read-set, write-set)
A2: return
Back to the overview of all KIV projects.
For general informations on KIV and a download site for the whole system refer to this page.
[SEFM18] | G. Schellhorn, M. Wedel, O. Travkin, J. König, H. Wehrheim. Fastlane is Opaque - A Case Study in Mechanized Proofs of Opacity. (submitted to SEFM 2018) |
[Wamhoff et al 2013] | G. J. Wamhoff, C. Fetzer, P. Felber, E. Riviere, G. Muller. Fastlane: improving performance of software transactional memory for low thread counts. (PPoPP, pp. 113-122, ACM) |