Summary

This lesson presents concluding remarks for this chapter on locks.

The approach from previous lesson shows how real locks are built these days: some hardware support, in the form of a more powerful instruction, and some operating system support, e.g., in the form of park() and unpark() primitives on Solaris, or futex on Linux. Of course, the details differ, and the exact code to perform such locking is usually highly tuned. Check out the Solaris or Linux code bases if you want to see more details; they are a fascinating read1-“glibc 2.9 (include Linux pthreads implementation)” by Many authors. Available here: http://ftp.gnu.org/gnu/glibc. In particular, take a look at the nptl subdirectory where you will find most of the pthread support in Linux today. 2-“OpenSolaris Thread Library” by Sun. Code: src.opensolaris.org/source/xref/ onnv/onnv-gate/usr/src/lib/libc/port/threads/synch.c. Pretty interesting, al- though who knows what will happen now that Oracle owns Sun. Thanks to Mike Swift for the pointer.. Also see David et al.’s excellent work for a comparison of locking strategies on modern multiprocessors“Everything You Always Wanted to Know about Synchronization but Were Afraid to Ask” by Tudor David, Rachid Guerraoui, Vasileios Trigonakis. SOSP ’13, Nemacolin Woodlands Resort, Pennsylvania, November 2013. An excellent paper comparing many different ways to build locks using hardware primitives. Great to see how many ideas work on modern hardware..

Get hands-on with 1200+ tech skills courses.