Skip to content

Commit 8b271c9

Browse files
authored
Merge pull request #84 from jty2/github-jty2.swap_mutex.use_store_release
swap_mutex: use store release in lock_release() For issue #81
2 parents 40898b4 + ba7bade commit 8b271c9

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

benchmarks/lockhammer/tests/swap_mutex.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,12 @@ static inline unsigned long lock_acquire (uint64_t *lock, unsigned long threadnu
3535
unsigned long val = 1;
3636

3737
while (val) {
38-
val = swap64 (lock, 1);
38+
val = swap64 (lock, 1); // uses acquire-release semantics
3939
}
4040

4141
return 0;
4242
}
4343

4444
static inline void lock_release (uint64_t *lock, unsigned long threadnum) {
45-
*(volatile unsigned long *) lock = 0;
45+
__atomic_store_n(lock, 0, __ATOMIC_RELEASE);
4646
}

0 commit comments

Comments
 (0)