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

David L. Rager ragerdl at cs.utexas.edu
Thu Oct 15 21:42:05 UTC 2009


Hi Gary,

I'm pretty sure I understand the multi-threading issue.  Even if it
were a single CISC instruction, there would be no "atomicity"
guarantee without the lock on the memory address (where the lock
prohibits reading/writing of that address).

> ATOMIC-INCF basically tries to guarantee that the
> read-modify-write sequence happens atomically.
> I think that we could actually implement it as
>
>  (lock)
>  (addq ($ fixnumone) (@ loc))
>
> or
>
>  (movq increment-by (% reg))
>  (lock)
>  (addq (% reg) (@ loc))
>
> on x86; we actually do a similar compare-and-swap loop on both
> architectures.

So do we know whether the atomic-incf in CCL version 1.3 of
x86-misc.lisp is thread-safe?  I'm happy to go read more about the X86
assembly "specification" in order to better understand the code myself
if that's what's required.

Thanks,
David



More information about the Openmcl-devel mailing list