SUSv3's "memory location" and threads

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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

[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux