-
Notifications
You must be signed in to change notification settings - Fork 28
Open
Description
orig = atomic_load(head) should be moved to while loop. For example, 2 thread exec static void push(_Atomic struct lstack_head *head, struct lstack_node *node), they both run while loop, the first thread succeed, the second thread's orig will always not equal head, because head is updated by the first thread. So orig = atomic_load(head) should be moved to while loop.
static void push(_Atomic struct lstack_head *head, struct lstack_node *node)
{
struct lstack_head next, orig;
do {
orig = atomic_load(head);
node->next = orig.node;
next.aba = orig.aba + 1;
next.node = node;
} while (!atomic_compare_exchange_weak(head, &orig, next));
}Metadata
Metadata
Assignees
Labels
No labels