Date: Thu, 30 Jul 2015 11:03:43 -0700
   From: Dennis Ferguson <dennis.c.fergu...@gmail.com>

   On 30 Jul, 2015, at 01:53 , Maxime Villard <m...@m00nbsd.net> wrote:
   > Do we have a magic function that can perform two atomic_swap_ptr()
   > atomically?

   I don't think you can have a portable function like that.

Not that hard:

- On i386, use cmpxchg8b.
- On amd64, use cmpxchg16b.
- On ll/sc machines, use ll/sc.
- On uniprocessor machines, use RAS.
- On multiprocessor sparc and anything else not in the above classes,
  use a hashed locking scheme like we already use for sparc.

However, the last case would require making single-word CAS use the
hashed locking scheme too even if there is a native single-word CAS,
in order to cooperate with double-word CAS -- unless we decide that
the two don't have to agree, just as we reject doing both x++ and
atomic_inc_uint(&x).

Reply via email to