What is the point in replacing a mutex lock with block like this
void stack_push(stack* s, node* n)
{
node* head;
do
{
head = s->head;
n->next = head;
}
while ( ! atomic_compare_exchange(s->head, head, n));
}
Can't understand what benefit we can get by replacing mutex with this atomic excange?
atomic_compare_exchange(&s->head, &head, n)
– Austin