atomicity of unlocked reads

Frank Mayhar frank at exit.com
Tue Sep 16 20:03:34 PDT 2003


Bruce Evans wrote:
> What guarantees, if any, are there that an unlocked read provides a
> valid value (either the current value or a previous value)?  Obviously
> there are no guarantees if the size of the object being read is different
> from the natural memory access size.

I think that this may depend on the architecture of the target, but as I
understand it, in general an entity that is read in one (bus) operation
is guaranteed to be valid.  These days that entity is generally 32 or 64
bits.  The key is that the bus is locked during the entire read or write
cycle so that reads and writes are serialized by the hardware.

So the answer is that yes, there are guarantees, but you still have to
be careful and aware of the semantics of the target hardware.
-- 
Frank Mayhar frank at exit.com	http://www.exit.com/
Exit Consulting                 http://www.gpsclock.com/
                                http://www.exit.com/blog/frank/


More information about the freebsd-smp mailing list