diff options
author | Glenn Elliott <gelliott@cs.unc.edu> | 2014-11-08 21:26:27 -0500 |
---|---|---|
committer | Glenn Elliott <gelliott@cs.unc.edu> | 2014-11-08 21:26:27 -0500 |
commit | 5383cc81a37a3d30524e9dae64afc0cd2afe23c2 (patch) | |
tree | 84d08fb9eff11256bf151cfdaf8c5ec87f5a9c33 | |
parent | 6131b3f254fc28e61f77c9c25715abfd95d85451 (diff) |
BUG: Reverse logic for compare-and-swap calls.
This patch fixes a bug in the queuelock code where
the logical treatment of the return code of
compare-and-swap is backwards.
-rw-r--r-- | include/queuelock.h | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/include/queuelock.h b/include/queuelock.h index 1eab9a3..d55bd75 100644 --- a/include/queuelock.h +++ b/include/queuelock.h | |||
@@ -54,7 +54,7 @@ static inline void __ql_lock(queuelock_t* q, queuenode_t* self) | |||
54 | do | 54 | do |
55 | { | 55 | { |
56 | prev = (struct __queuenode*)((volatile ptr_t) q->tail); | 56 | prev = (struct __queuenode*)((volatile ptr_t) q->tail); |
57 | } while(__sync_bool_compare_and_swap(&q->tail, (ptr_t)prev, (ptr_t)self)); | 57 | } while(!__sync_bool_compare_and_swap(&q->tail, (ptr_t)prev, (ptr_t)self)); |
58 | 58 | ||
59 | /* was there someone ahead of us? */ | 59 | /* was there someone ahead of us? */ |
60 | if (prev) | 60 | if (prev) |
@@ -84,7 +84,7 @@ static inline void __ql_unlock(queuelock_t* q, queuenode_t* self) | |||
84 | __sync_synchronize(); | 84 | __sync_synchronize(); |
85 | 85 | ||
86 | /* try to dequeue from the end of the line */ | 86 | /* try to dequeue from the end of the line */ |
87 | if (!self->next && __sync_bool_compare_and_swap(&q->tail, (ptr_t)self, (ptr_t)0)) | 87 | if (!self->next && !__sync_bool_compare_and_swap(&q->tail, (ptr_t)self, (ptr_t)0)) |
88 | { | 88 | { |
89 | /* we really weren't at the end of the line! */ | 89 | /* we really weren't at the end of the line! */ |
90 | 90 | ||