This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
SUSv3's "memory location" and threads
- From: "Adam Olsen" <rhamph at gmail dot com>
- To: gcc-help at gcc dot gnu dot org
- Date: Mon, 27 Aug 2007 23:19:52 -0600
- Subject: SUSv3's "memory location" and threads
I am trying to determine how to ensure two objects/variables are at
distinct "memory locations", so as to meet SUSv3's description of what
an application must do to use locks, etc correctly[1].
For example, if I had "struct { char foo; char bar[3]; }", where my
first thread had a pointer to foo and was modifying it, while my
second thread had a pointer to bar and was modifying it, would that
meet the requirements? My understanding is that a C compiler can (and
in many cases, will) use larger writes so long as they appear the same
for a single-threaded program; this obviously breaks threading though.
Is there a specific variable size or alignment at which I can be sure
(portably, etc) that there will be no larger writes, and that I can
use locks correctly?
[1] http://www.opengroup.org/onlinepubs/009695399/basedefs/xbd_chap04.html#tag_04_10
--
Adam Olsen, aka Rhamphoryncus