Archive for February 18, 2007

Sunday, February 18, 2007

Memory Barriers

Peter Ammon shows how memory barriers can protect against processor synchronization issues without the expense of locks:

The lesson here is something you already knew, but I’ll state it anyways: Multithreading bugs are very delicate. There is a real bug here, but it was masked by the fact that the kernel scheduled them on the same processor, and then by the fact that the variables were too close together in memory, and once those two issues were removed, (un)lucky timing usually masked the bug anyways.