This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: Volatiles and speculative memory access reordering...
- From: Richard Henderson <rth at redhat dot com>
- To: aspiesrule at mcleodusa dot net
- Cc: gcc at gcc dot gnu dot org
- Date: Thu, 27 Nov 2003 15:48:33 -0800
- Subject: Re: Volatiles and speculative memory access reordering...
- References: <200311272316.hARNG1H29681@mx1.redhat.com>
On Thu, Nov 27, 2003 at 11:16:57PM -0000, aspiesrule@mcleodusa.net wrote:
> On modern CPU's such as Intel's Pentium 4 and Itanium 2, the CPU may reorder
> accesses to volatiles across sequence points if a serializing insn is not
> inserted at the sequence point.
I don't believe you. Intel is very good about maintaining accesses in
order from the point of view of the program. If you think "volatile"
means atomic, you're wrong.
If you're talking about multiple cpus, then yes you have to insert
serializing insns. But this is usually the lock-prefixed atomic
memory update instruction. See any of a dozen thread libraries for
examples of how to do this.
r~