The 12 Commandments of Synchronization
Emin G¨un Sirer
Computer Science Department, Cornell University
October 2, 2011
In the beginning, there was hardware. Now the hardware was formless and
empty, darkness was over the surface of silicon.
And then the creator said “let there be operating systems,” and there were OSes.
The creator saw that OSes were good.
And the creator said “let there be processes, and threads.” OSes were teeming
with processes and threads carrying out different tasks. Then the creator said “let
the processes and threads synchronize with each other.” For this task, the creator
appointed human-kind. But humans were fallible, and weak, and they failed to get
synchronization correct, and fallen angel BSOD (pronounced
), spawn of
Beelzebub, ruled the day with great evil.
So the creator sent the following commandments.
Thou shalt live and die by coding conventions for synchroniza-
Remember the parable of Jebediah the Electrician, who wired up his house using
only pink wires. He said onto the townsfolks “I saved a bundle by not buying properly
color-coded wires; and yet my lights turn on when I flippeth the switch. My wiring is
correct and just right for my needs, and I did not have to worry about blue wires and
green wires and brown wires. I use the book of Good Wiring Conventions as TP in my
outhouse, for I have no use for any rules.” And the townsfolks said “be careful with
your hubris, for the creator might smite thee.” And he respondeth, “I rule over you with
my cheap wiring and you are all weaklings for following well-known good practices.”
Remember when his wife was with child, and he wanted to build an addition to his
house? He made a mistake when tracing the all-pink wires all the way back to the
power plant, cut into a live wire with his metal clippers, and was promptly fried in a
flash of hellfire. Take heed of the story of ex-Jebediah the Electrician, now known as
Jebediah the Crisp.
For that is the fate that awaits you when you do not follow conventions when writing
synchronization code. There will be times, tempting times, when the problem seems
constrained enough to solve with a custom solution that violates the conventions you
have been taught. We sent these to you to test your free will and self-control, and BSOD
lurks behind them. If you give in to the temptation, you will come up with a solution
that may be correct just by the skin of its teeth, but will likely not be understandable to
others in the field. It may be just right, or it may have subtle bugs, but in either case, it