1 C cmpxchg-fail-unordered-2 1 C cmpxchg-fail-unordered-2 2 2 3 (* 3 (* 4 * Result: Sometimes 4 * Result: Sometimes 5 * 5 * 6 * Demonstrate that a failing cmpxchg() operat 6 * Demonstrate that a failing cmpxchg() operation does not act as either 7 * an acquire release operation. (In contrast 7 * an acquire release operation. (In contrast, a successful cmpxchg() 8 * does act as both an acquire and a release o 8 * does act as both an acquire and a release operation.) 9 *) 9 *) 10 10 11 {} 11 {} 12 12 13 P0(int *x, int *y) 13 P0(int *x, int *y) 14 { 14 { 15 int r1; 15 int r1; 16 16 17 WRITE_ONCE(*x, 1); 17 WRITE_ONCE(*x, 1); 18 r1 = cmpxchg(y, 0, 1); 18 r1 = cmpxchg(y, 0, 1); 19 } 19 } 20 20 21 P1(int *x, int *y) 21 P1(int *x, int *y) 22 { 22 { 23 int r1; 23 int r1; 24 int r2; 24 int r2; 25 25 26 r1 = cmpxchg(y, 0, 1); 26 r1 = cmpxchg(y, 0, 1); 27 r2 = READ_ONCE(*x); 27 r2 = READ_ONCE(*x); 28 } 28 } 29 29 30 exists (0:r1=0 /\ 1:r1=1 /\ 1:r2=0) 30 exists (0:r1=0 /\ 1:r1=1 /\ 1:r2=0)
Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.