TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

The Little Book of Semaphores

160 pointsby laexalmost 11 years ago

13 comments

kqr2almost 11 years ago
The author Alan B. Downey has released quite a few free books:<p>Check out <a href="http://www.greenteapress.com/" rel="nofollow">http:&#x2F;&#x2F;www.greenteapress.com&#x2F;</a> including:<p><i>Think Python</i> : <a href="http://www.greenteapress.com/thinkpython/thinkpython.html" rel="nofollow">http:&#x2F;&#x2F;www.greenteapress.com&#x2F;thinkpython&#x2F;thinkpython.html</a><p><i>Think Bayes</i> : <a href="http://www.greenteapress.com/thinkbayes/index.html" rel="nofollow">http:&#x2F;&#x2F;www.greenteapress.com&#x2F;thinkbayes&#x2F;index.html</a><p><i>Think Complexity</i> : <a href="http://www.greenteapress.com/complexity/index.html" rel="nofollow">http:&#x2F;&#x2F;www.greenteapress.com&#x2F;complexity&#x2F;index.html</a><p><i>Think Stats</i> : <a href="http://www.greenteapress.com/thinkstats/index.html" rel="nofollow">http:&#x2F;&#x2F;www.greenteapress.com&#x2F;thinkstats&#x2F;index.html</a>
评论 #8202543 未加载
评论 #8203872 未加载
评论 #8203501 未加载
kazinatorover 10 years ago
Yikes! I&#x27;m appalled by the one-sided justification for semaphores in this book. (2.3, &quot;Why semaphores?&quot;)<p>Semaphores are actually a horrible primitive for building concurrency. I sometimes call them &quot;the goto of synchronization&quot;, which is deliberately ironic since they are a gift to the world from the &quot;goto considered harmful&quot; thinker, Dijkstra.<p>Debugging a problem with semaphores is difficult because they have no useful state beyond their count. You don&#x27;t know how a set of semaphores might have gotten into a given state. (Vaguely analogous to the the argument that in a spaghetti program with backward gotos, it&#x27;s difficult to have an idea of how control arrived at a particular node in the program.)<p>For instance, when we (ab)use a semaphore to simulate a mutex, that semaphore does not actually track the ownership: who is locking it now? It can be signaled by any task at all, whereas a proper mutex can diagnose the fact that it is unlocked by its owner.<p>Semaphores most certainly do not <i>impose deliberate constraints that avoid programmers avoid errors</i>, whatever that is supposed to mean, ouch!<p>When higher level primitives are correctly built on semaphores (condition variables, read-write locks, you name it), the solutions look like Rube Goldberg mousetraps. And that&#x27;s before additional requirements are added like error checking, or handling priority inversion and whatnot.<p>Semaphores have one very good application and that is a situation in which a very fragile context (such as an interrupt service routine) needs to generate a wakeup signal. The semaphore signal operation can be made reentrant fairly easily. This is not only true in OS kernels. Note that in POSIX, for instance, the sem_post operation is noteworthy for being async-signal-safe, meaning that it can be called from a signal handler. By contrast, other things like pthread_cond_signal cannot be.
dccoolgaialmost 11 years ago
Seems interesting. IME, This is one of the topics that people who didn&#x27;t do CS (and even people who did) tend to struggle with and get tripped up on in practice. I think I&#x27;m going to get this book and if it&#x27;s good, I&#x27;ll probably be recommending it to some folks. Glad to see Dining Philosophers mentioned - it was one of my favorite problems in school and it&#x27;s a great allegory for resource sharing problems.
jestinjoy1almost 11 years ago
Interesting thing is, his place of work is not famous as compared to top US institutions (I am from outside US). But his educations says it<p>Ph.D. Computer Science, University of California at Berkeley, May 1997 . M.S. Civil Engineering, Massachusetts Institute of Technology, August 1990. B.S. Civil Engineering, Massachusetts Institute of Technology, June 19 89
评论 #8203295 未加载
nrubinalmost 11 years ago
Allen taught every single software class I took in college,its awesome to see his writing recognized on HN! We actually worked through LBoS during a software systems course this past spring semester, it was a great way to get introduced to the complexities of multithreaded programs.
zorbashalmost 11 years ago
This book is a must read. Helped me a lot score high at the exams for my operating systems exam.
rullopatalmost 11 years ago
Isn&#x27;t it the same book?<p><a href="http://greenteapress.com/semaphores/" rel="nofollow">http:&#x2F;&#x2F;greenteapress.com&#x2F;semaphores&#x2F;</a>
评论 #8202188 未加载
zarkov99almost 11 years ago
This is a <i>really</i> nice book on concurrency. Clear, detailed and assuming very little knowledge on the part of the reader.
jestinjoy1almost 11 years ago
The best I have seen about semaphores. I am using this in my course. It helped me to explain concepts simple and clear
merlinsbrainalmost 11 years ago
A great book which cleared a lot of my concepts about OS back in school. Re-read is due!
gamesbrainiacalmost 11 years ago
I recognize the author, Downey. He&#x27;s usually very clear in his explanations.
graycatalmost 11 years ago
Looks very nicely written.
tonteldoosalmost 11 years ago
Thought it was a book about flags first, but this is waaaay better! :)