This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: C++0x Memory model and gcc


Andrew MacLeod <amacleod@redhat.com> writes:

> They are independent as far as dependencies within this compilation unit.
> The problem is if thread number 2 is performing
>  a.j = val
>  b.i = val2
>
> now there are data races on both A and B if we load/store full words
> and the struct was something like: struct {
>  char i;
>  char j;
> } a, b;
>
> The store to B is particularly unpleasant since you may lose one of
> the 2 stores.  The load data race on A is only in the territory of
> hardware or software race detectors.

In this exmaple, if we do a word access to a, then we are running past
the boundaries of the struct.  We can only assume that is OK if a is
aligned to a word boundary.  And if both a and b are aligned to word
boundaries, then there is no problem doing a word access to a.

So the only potential problem here is if we have two small variables
where one is aligned and the other is not.  This is an unusual
situation because small variables are not normally aligned.  We can
avoid trouble by forcing an alignment to a word boundary after every
aligned variable.

Or so it seems to me.

Ian


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]