From: David P G. <gr...@us...> - 2013-04-12 13:01:58
|
"Thomas Preud'homme" <ro...@ce...> wrote on 04/12/2013 08:43:55 AM: > > I indeed understood you wrong. So instead of a remark I have a question. Is > the code proposed supposed to work even in presence of a word store in the > second word? Because then if the reservation granule is exactly > word-size (the > documentation only says it's a power of two at least the size of a word) > nothing would detect the (stw) write to the second word. The following > sequence would then be possible: > > lwarx // first word > lwz // second word > stw // second word > stwcx // first word, succeed. > > If not (the only writes to second word are 64 bits write to the same 2 words > in the same order), then indeed, it depends on the ordering and I didn't find > anything about this in the documentation. > This is exactly the scenario I was thinking of (but did not articulate as clearly). In practice, the reservation granule is often a cache line. So if the two words straddle a cache-line boundary (which they could if there are not 8 byte aligned), I think this sequence could happen, resulting in a non-atomic read. --dave |