Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 17 Sep 2003 16:24:10 +1000 (EST)
From:      Bruce Evans <bde@zeta.org.au>
To:        Frank Mayhar <frank@exit.com>
Cc:        smp@freebsd.org
Subject:   Re: atomicity of unlocked reads
Message-ID:  <20030917161747.Q587@gamplex.bde.org>
In-Reply-To: <200309170303.h8H33HtU083418@realtime.exit.com>
References:  <200309170303.h8H33HtU083418@realtime.exit.com>

next in thread | previous in thread | raw e-mail | index | archive | help
On Tue, 16 Sep 2003, Frank Mayhar wrote:

> 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.

I'll give up micro-optimizing this and use an atomic instruction since
I want it to work in MI code without ifdefs for the target hardware.
atomic_load_ptr() could hide the details, but we currently only have
atomic_load_acq_ptr() which gives more than I need.

Bruce



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20030917161747.Q587>