Library
Module
Module type
Parameter
Class
Class type
Operations on shared memory locations.
make_cas r before after
is an operation that attempts to set the shared memory location r
to the after
value and succeeds if the current content of r
is the before
value.
is_on_loc op r
determines whether the target of op
is the shared memory location r
.
val atomic : t -> bool
atomic op
attempts to perform the given operation atomically. Returns true
on success and false
on failure.
val atomically : t list -> bool
atomically ops
attempts to perform the given operations atomically. Returns true
on success and false
on failure.
The algorithm requires provided operations to follow a global total order. To eliminate a class of bugs, the operations are sorted automatically. If the operations are given in either ascending or descending order of the targeted shared memory location ids, then sorting is done in linear time O(n)
and does not increase the time complexity of the algorithm. Otherwise sorting may take linearithmic time O(n*log(n))
.