[Openmcl-devel] [openmcl-devel] atomic-incf
David L. Rager
ragerdl at cs.utexas.edu
Thu Oct 15 11:38:03 PDT 2009
Hello Gary and Co.,
Two questions about atomic-incf:
(1) It's not showing up as external for me (release 1.3). Is it
reasonable to make it external? Is there a reason that it's not
exposed other than just not wanting to make too many promises about an
API?
(2) By "atomic", does it mean that no other threads can read/write
that variable during the actual increment? I'm not worried about all
the code that wraps the increment (perhaps it checks the type of the
argument, etc.). I'm just trying to make sure the increment itself is
thread-safe.
My guess is that atomic-incf calls the X86 instruction that locks the
bus for a particular memory address and increments that variable.
>From looking at the implementation in x86-misc.lisp, it looks like it
does indeed perform a lock on a memory address, performs a compare and
exchange with an atomicity guarantee, and then loops back to the
beginning of the function if that compare and exchange failed. In the
PPC implementation, it looks like the lrarx and strcx instructions
combine to also provide an atomic increment.
Thanks,
David
More information about the Openmcl-devel
mailing list