// "memory_order_relaxed", run "make" to recompile, and then run:
// "./run.sh ./mcs-lock/testcase -m2 -Y -u3 -tSPEC"
/********** Detected Correctness **********/
+ // This used the stronger mo_acq_rel parameter in old versions, but this
+ // is not necessary.
if ( m_tail.compare_exchange_strong(
tail_was_me,NULL,std::mo_release) ) {
// got null in tail, mutex is unlocked
/********** Detected Correctness (testcase1) **********/
int old_seq = _seq.load(memory_order_acquire); // acquire
if (old_seq % 2 == 1) {
+ // The thrd_yield() operation is just for fairness but won't affect
+ // the correctness (and also the specification).
thrd_yield();
continue;
}
/********** Detected Correctness (testcase1) **********/
atomic_thread_fence(memory_order_acquire);
if (_seq.load(memory_order_relaxed) == old_seq) { // relaxed
+ // The thrd_yield() operation is just for fairness but won't affect
+ // the correctness (and also the specification).
thrd_yield();
return;
}
/********** Detected Correctness (testcase2 with -y -x1000) **********/
int old_seq = _seq.load(memory_order_acquire); // acquire
if (old_seq % 2 == 1) {
+ // The thrd_yield() operation is just for fairness but won't affect
+ // the correctness (and also the specification).
thrd_yield();
continue; // Retry
}
// #2
if (_seq.compare_exchange_strong(old_seq, old_seq + 1,
memory_order_relaxed, memory_order_relaxed)) {
+ // The thrd_yield() operation is just for fairness but won't affect
+ // the correctness (and also the specification).
thrd_yield();
break;
}