Price your future right. 60% off with code BLACKSCHOLES at USD checkout. Offer ends in 8d 09h 54m 26s8 days 9 hours 54 minutes 26 seconds.
Price your future right. 60% off with code BLACKSCHOLES at USD checkout. Offer ends in 8d 09h 54m 26s8 days 9 hours 54 minutes 26 seconds.

Sign in to watch this lesson
Concurrent Data Structures · 3:56
Williams' rules for concurrent data structures: never expose broken invariants, offer whole operations instead of steps, stay exception-safe, and shrink the part that runs one thread at a time (short critical sections, allocate before locking, separate mutexes for separate parts). Applied to a linked-list queue, a dummy node keeps push and pop on different nodes so a head mutex and a tail mutex can work in parallel (the Michael and Scott two-lock queue). On an Apple M3, with four producers and four consumers the two-lock queue moved about 1.4x as many items per second as the same queue with one mutex (14.3 vs 10.0 million/s), while with one of each the single lock won; reading get_tail() outside the head lock would have run off the end of the list in 705 of 1000 stress rounds.