Download as a PDF

Transcript
oldvals[i]. By Lemma 5, this value is the abstract value of
a[i] at that point, which therefore is not expvals[i].
Lemma 7. Immediately before the linearization point of
a successful KCSS(a[1..k], expvals[1..k], newval) operation, the
abstract value of each specified location had the corresponding value from the expvals array, and the abstract value of
a[1] becomes newval at the linearization point.
Proof. The definition of the KCSS operation implies that
the abstract value of a[1] becomes newval at the linearization
point of a successful KCSS operation.
Because the KCSS linearizes at the linearization point of
its last SNAPSHOT, we know that at that point, the abstract
values of locations a[2]..a[k] are the values returned by the
SNAPSHOT, which we check in the loop at line K4 are equal to
the corresponding values in the expvals array. Because the
subsequent SC operation succeeds, by Lemma 4, we know
the abstract value of a[1] is the value returned by the preceding LL operation—which we also check is expvals[1]—for
the entire interval between the LL and SC operations.
A.2 Obstruction-freedom proof
We now argue that all the operations are obstruction-free.
We also argue that an SC(a) operation by thread p succeeds
whenever no other operations that access the location take
any steps between p’s invocation of the preceding LL(a) operation and the completion of the SC operation. This latter
property is required so that these operations are useful for
implementing obstruction-free data structures.
That RESET and SC are obstruction-free is straightforward
to see, as they have no loops.
Lemma 8. If a RESET(a) operation executes without any
other threads accessing location a then immediately after the
RESET operation, the value field of a contains an application
value.
Proof. If the value field of a contains an application
value before the RESET operation, then the RESET operation
does not change it. If the value field of a contains a tagged
id, then the RESET operation CAS’s that field from its old
value to the value in the corresponding entry of the VAL SAVE
array, which always contains an application value. Because
no other thread changes the value field of a, this CAS always
succeeds, so after the RESET operation, the value field of a
contains an application value.
Lemma 9. READ is obstruction-free.
Proof. Suppose thread p executes a READ(a) operation,
and that after some point in that operation execution, only
thread p takes steps. If p’s current attempt at that point is
inconclusive then it executes another attempt, during which
no other thread takes steps. If p sees an application value in
the value field of a then this new attempt will be conclusive.
Otherwise, p invokes RESET(a), after which, the value field
of a contains an application value. Thus, p’s next attempt
will succeed as long as no other thread accesses a.
Lemma 10. If a READ(a) operation executes without any
other threads accessing location a then immediately after the
READ operation, the value field of a contains the value returned by the READ operation, which is an application value.
Proof. The READ(a) operation returns only if the value
it read in the value field of a was an application value, which
it returns. Because no other thread accesses a, immediately
after the READ operation, the value field of a still contains
that application value.
Lemma 11. LL is obstruction-free.
Proof. Suppose that thread p executes an LL(a) operation, and that after some point during the execution of
this operation, only thread p takes steps. If p’s current
attempt at that point is inconclusive then it executes another attempt, during which no other thread takes steps. By
Lemma 10, immediately after the READ operation on line 6 of
this attempt, the value field of a contains the value returned
by that READ. Therefore, the CAS in line 8 succeeds, and LL
operation terminates.
Lemma 12. SNAPSHOT is obstruction-free.
Proof. Suppose that thread p executes a SNAPSHOT operation, and that after some point during the execution of
that operation, only thread p takes steps. If p’s current
attempt at that point is inconclusive then it executes another attempt, during which no other thread takes steps.
By Lemma 10 and inspection of the code, after the first
COLLECT TAGGED IDS and COLLECT VALUES operations of this
attempt, the tag and value fields contain the values returned
by those operations. Thus, the second COLLECT TAGGED IDS
and COLLECT VALUES operations will return the same values
and this attempt will be conclusive.
Lemma 13. If p executes an LL(a) operation without any
other threads accessing location a then immediately after the
LL operation, the value field of a contains p’s MY TAGGED ID
value.
Proof. This is straightforward because the LL operation
terminates only if p successfully CAS’s the value field of a
to its MY TAGGED ID value.
Lemma 14. If a thread p invokes LL(a) and then SC(a)
with no intervening LL, SC or KCSS operations (but possibly other operations), and no thread (including p) takes any
steps for any operation that accesses a in the interval between p’s LL(a) and SC(a) operations, then the SC operation
succeeds.
Proof. By Lemma 13, immediately after the LL(a) operation, the value field of a contains p’s MY TAGGED ID value.
Because no thread accesses a until p’s subsequent SC operation, this field does not change in that interval, and because
p does not invoke LL, SC or KCSS, p’s MY TAGGED ID value also
does not change in that interval. Thus, the CAS in the SC
operation succeeds.
Lemma 15. KCSS is obstruction-free.
Proof. Suppose only thread p executing a KCSS operation takes steps after some point. If its current attempt is
inconclusive then it executes another attempt, during which
no other thread takes steps. Thus, the only abstract operation that takes steps between the LL and SC operations of
this attempt is the SNAPSHOT of this attempt, which does
not access the location of the LL and SC operations. So, by
Lemma 14, the SC operation succeeds, and the KCSS operation terminates.