[Openmcl-devel] [openmcl-devel] atomic-incf

David L. Rager ragerdl at cs.utexas.edu
Sun Oct 18 15:50:54 PDT 2009

One more hopefully quick question about atomic-incf/atomic-decf:

Can the return value of an atomic-incf/decf be relied upon as the value
right after that particular incf occurrs?  Given it's a compare and swap,
I'm guessing that the answer to this question is "yes".

Another way to ask the same question is, if I perform two atomic-incf's in a
row (i.e., as simultaneously as the x86 platform will allow me), will one of
the atomic-incf calls return the intermediate value, and the other
atomic-incf return the newest value?

A long time ago, in some thread far far away:
(defvar *x* 3)

In a current time, with two concurrent threads

Thread A:
(atomic-incf *x*) ; sets *x* to 4, returns 4

Thread B:
(atomic-incf *x*) ; sets *x* to 5, returns 5

Of course if Thread B occurred before Thread A, the B transcript would have
"sets *x* to 4, returns 4" and the A transcript would also change to use the
number 5.

Hopefully between my two versions of the question, my real question is

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.clozure.com/pipermail/openmcl-devel/attachments/20091018/18d54053/attachment.htm>

More information about the Openmcl-devel mailing list