This is the mail archive of the
mailing list for the GCC project.
Re: RFA: check_dbra_loop
On 13-May-2001, Mark Mitchell <firstname.lastname@example.org> wrote:
> >>>>> "Richard" == Richard Kenner <email@example.com> writes:
> Richard> Is this required even if "volatile" is not specified?
> I don't know, but you're probably correct -- it's probably not
> required if `volatile' isn't specified.
As well as respecting `volatile', memory writes should IMHO also not be
reordered across thread synchronization primitives. Otherwise I suspect
a lot of carefully written programs could break.
I don't know whether the standards are clear on this. The C standard
doesn't say anything much about multithread. Unfortunately the
description is divided between the Posix threads standard (which I don't
have a copy of), and the C standard. That's assuming you're using Posix
threads, of course. If you are instead using e.g. some OS-specific thread
synchronization routines, then the C standard doesn't really guarantee
anything, so it's up to the documentation of the OS-specific thread
stuff (which is probably doesn't say much about compiler reordering),
and the compiler's documentation (which probably doesn't say much about
reordering in the presence of multithreading).
Fergus Henderson <firstname.lastname@example.org> | "I have always known that the pursuit
| of excellence is a lethal habit"
WWW: <http://www.cs.mu.oz.au/~fjh> | -- the last words of T. S. Garp.