Jump to ratings and reviews
Rate this book

The Little Book of Semaphores: The Ins and Outs of Concurrency Control and Common Mistakes

Rate this book
The Little Book of Semaphores is a textbook that introduces the principles of synchronization for concurrent programming. In most computer science curricula, synchronization is a module in an Operating Systems class. OS textbooks present a standard set of problems with a standard set of solutions, but most students don't get a good understanding of the material or the ability to solve similar problems. The approach of this book is to identify patterns that are useful for a variety of synchronization problems and then show how they can be assembled into solutions. After each problem, the book offers a hint before showing a solution, giving students a better chance of discovering solutions on their own. The book covers the classical problems, including "Readers-writers," "Producer-consumer," and "Dining Philosophers." In addition, it collects a number of not-so-classical problems. *** Published under the terms of the GNU Free Documentation License. Money raised from the sale of this book supports the development of free software and documentation.

279 pages, Paperback

First published March 20, 2009

37 people are currently reading
572 people want to read

About the author

Allen B. Downey

36 books236 followers
Allen Downey is a Professor Emeritus at Olin College and the author of a series of freetextbooks related to software and data science, including Think Python, Think Bayes, and Think Complexity, which are also published by O’Reilly Media. His blog, Probably Overthinking It, features articles on Bayesian probability and statistics. He holds a Ph.D. in computer science from U.C. Berkeley, and M.S. and B.S. degrees from MIT.

Ratings & Reviews

What do you think?
Rate this book

Friends & Following

Create a free account to discover what your friends think of this book!

Community Reviews

5 stars
40 (50%)
4 stars
32 (40%)
3 stars
7 (8%)
2 stars
1 (1%)
1 star
0 (0%)
Displaying 1 - 13 of 13 reviews
Profile Image for A. Jesse.
31 reviews27 followers
October 12, 2010
Whenever I write code to synchronize multiple threads, I always think, "There must be some method to this." I've been warned by the popular adage, "Any non-trivial multithreaded program has bugs," but I have no systematic way to think about synchronization that assures me I've handled all the cases. This book does not provide that method. What it *does* is to provide exercises, with solutions, that have developed my facility with thinking about synchronization, and have shown common synchronization patterns that should be applicable to almost any real-world problem.

Starting from the most basic cases, the book leads the reader step-by-step through a series of increasingly complex synchronization problems, each followed by a hint and finally a solution written in a Python-like pseudocode. Appendices show how to "clean up" Python's and C's threading libraries to better suit the author's tastes, and to better match the pseudocode solutions.

The classic synchronization problems included in most Computer Science curricula tend to use real-world objects to describe their constraints: E.g., philosophers are dining at a round table, and each needs two forks. Or, men and women form two lines and they must dance in pairs. In fact, the synchronization problems don't arise on dance floors but in operating systems and software applications, so the classic descriptions do more to confuse than to clarify. The author promises to present both the classic description and the actual software system it arose from, but in fact only the first few problems are presented this way. The more advanced problems (such as the dining philosophers) are not tied to software applications at all. I couldn't think of any use for the solutions so I felt comfortable skimming those later sections.

If you thoroughly absorb the first 10 problems or so, thinking hard and working out your own solutions, you'll gain some confidence and familiarity with synchronization which will serve you in nearly all software challenges you'll actually face. The book's "long tail" of theoretical puzzles is best left to grad students.

It's available as a free PDF download, so if you ever write multithreaded code you should give it a look.
Profile Image for MANISH.
64 reviews1 follower
March 21, 2024
I thought it would be boring. I am completely wrong. How could it be? It is filled with engaging puzzles based on a single almighty concept of semaphores. It contains classical puzzles and also the author's own puzzles. It is the ideal way to learn. If you love puzzles and you deal with multithreading, this is a must ~read~ solve
Profile Image for Dmitry.
192 reviews8 followers
October 13, 2021
Честно говоря, примерно с пятой главы я перестал решать задачи, потому что 6 семафоров на задачу уже перебор(особенно для человека, который в продакшн не отправил ни одного семафора), но книга действительно понравилась, оставлю последние главы на пенсию.
1 review
December 31, 2024
I found this book helpful for passing my operative systems undergraduate exams, it is full of common semaphor use cases. Accompanied with pseudocode solutions this book made it easier for me to follow and understand the concept of syncrhonus and concurrent programming.
Profile Image for Arun.
211 reviews67 followers
April 8, 2018
first four chapters covers the basic synch primitives and model problems/solutions.
Profile Image for Gaurav.
10 reviews7 followers
July 17, 2020
Excellent book on semaphore, with lots of exercises.
Profile Image for Remigijus Jodelis.
46 reviews3 followers
August 19, 2020
DNF, but it's a very nice book about concurrency primitives and some cool problems.
6 reviews
January 1, 2023
I have been reminded that I read this. Thank you for saving my MTE 241 grade
Profile Image for Jay.
42 reviews
April 29, 2024
Knížka fajn ale semafory a synchronizaci procesů po zkoušce už nechci ani vidět 😭
Profile Image for Ashok Rajpurohit.
1 review
October 2, 2020
If you like to solve problems and at the same time understand the concurrency problems, this books is for you. Allen teaches semaphores and concurrency patterns through problems and solutions and best part is, you don't need to be computer science graduate to solve these problems.
Profile Image for Kartik Singhal.
68 reviews73 followers
January 6, 2015
Nice book for understanding semaphores, covers a lot of patterns and examples.
Profile Image for David.
27 reviews13 followers
February 23, 2013
If you are taking an Intro to Operating Systems course this short and concise book is far superior to the 1 or 2 lectures that you will get on the subject.
Displaying 1 - 13 of 13 reviews

Can't find what you're looking for?

Get help and learn more about the design.