Re: SUSv3's "memory location" and threads

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

 



Adam Olsen wrote:

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

You can use a zero-length bitfield to indicate that two struct members
are not to be coalesced: "struct { char foo; int : 0; char bar[3]; }". 
Now I'm not sure this would actually fix whatever problem you're
encountering (and if it did, it would probably be by happenstance, not
guarantee); and I'm fairly sure this is a nonstandard extension so it
might not be very portable, so caveat emptor.

Brian

[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