[cpp-threads] Alternatives to SC
Chris Thomasson
cristom at comcast.net
Wed Jan 17 01:05:16 GMT 2007
From: "Paul E. McKenney" <paulmck at linux.vnet.ibm.com>
To: "C++ threads standardisation" <cpp-threads at decadentplace.org.uk>
Sent: Tuesday, January 16, 2007 9:46 AM
Subject: Re: [cpp-threads] Alternatives to SC
[...]
>>
>> P1: x = 1;
>> P2: if (x == 1) eieio(), y = 2;
>> P3: if (y == 2) isync(), assert(x == 1);
[...]
Here is a trick you can do on the x86:
vars A=0, B=0, C=0, X=9, Y=9, Z=9;
fence var Fence;
CPU1: A=1; B=2; C=3; Fence=1
CPU2: if(Fence==1) X=1; Y=2; Z=3; Fence=2
CPU3: if(Fence==2) {
assert(A==X);
assert(B==Y);
assert(C==Z);
}
This will not assert on the current x86 because its stores/loads are as
follows:
// store
void atomicword_store(void **p, void *w) {
membar #LoadStore | #StoreStore
*p = w;
}
// load
void* atomicword_load(void **p) {
void *w = *p;
membar #LoadStore | #LoadLoad;
return w;
}
Which means:
vars A=0, B=0, C=0, X=9, Y=9, Z=9;
fence var Fence;
CPU1: A=1; B=2; C=3; Fence.rel=1
CPU2: if(Fence.acq==1) X=1; Y=2; Z=3; Fence.rel=2
CPU3: if(Fence.acq==2) {
assert(A==X);
assert(B==Y);
assert(C==Z);
}
More information about the cpp-threads
mailing list