Master the fundamental concepts of lock-free & wait-free programming through this focused micro-challenge.
The Michael-Scott queue provides FIFO ordering with separate atomic head and tail. Producers CAS the tail forward; consumers CAS the head. It powers many message-passing runtimes where mutex latency spikes under load.
Allocate a dummy node. Enqueue links new node at tail with CAS retry. Dequeue advances head when the next pointer is non-null.
cLoading…
pthread_mutex + std::deque under many producersKeep the relevant documentation open while you implement. When your output disagrees with the reference, trace one failing case by hand before changing random lines.
You will implement the Michael-Scott lock-free queue in C11 atomics. This exercise requires enqueue/dequeue from multiple threads without losing elements.
Implement Michael-Scott lock-free queue.
Requirements:
Three hints are available for this task, revealed one at a time inside the code workspace so you can struggle productively before seeing them.
All starter code and reference implementations are available for your local setup.
View on Github