projects
/
model-checker-benchmarks.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
changes
[model-checker-benchmarks.git]
/
seqlock
/
seqlock.h
diff --git
a/seqlock/seqlock.h
b/seqlock/seqlock.h
index c5a965cb8243bbb191ebe0620a72bdc50c0e4105..73e471f350618e6310e9eb8cea8e942a0802c0ea 100644
(file)
--- a/
seqlock/seqlock.h
+++ b/
seqlock/seqlock.h
@@
-1,5
+1,6
@@
#include <stdatomic.h>
#include <threads.h>
#include <stdatomic.h>
#include <threads.h>
+#include "common.h"
typedef struct seqlock {
// Sequence for reader consistency check
typedef struct seqlock {
// Sequence for reader consistency check
@@
-25,14
+26,16
@@
typedef struct seqlock {
}
void write(int new_data) {
}
void write(int new_data) {
- int old_seq = _seq.load(memory_order_acquire); // acquire
while (true) {
while (true) {
+ // #1: either here or #2 must be acquire
+ int old_seq = _seq.load(memory_order_acquire); // acquire
// This might be a relaxed too
if (old_seq % 2 == 1)
continue; // Retry
// This might be a relaxed too
if (old_seq % 2 == 1)
continue; // Retry
+ // #2
if (_seq.compare_exchange_strong(old_seq, old_seq + 1,
if (_seq.compare_exchange_strong(old_seq, old_seq + 1,
- memory_order_
acq_rel, memory_order_acquire
))
+ memory_order_
relaxed, memory_order_relaxed
))
break;
}
break;
}