TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

The Little Book of Semaphores

160 点作者 laex超过 10 年前

13 条评论

kqr2超过 10 年前
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 未加载
kazinator超过 10 年前
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.
dccoolgai超过 10 年前
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.
jestinjoy1超过 10 年前
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 未加载
nrubin超过 10 年前
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.
zorbash超过 10 年前
This book is a must read. Helped me a lot score high at the exams for my operating systems exam.
rullopat超过 10 年前
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 未加载
zarkov99超过 10 年前
This is a <i>really</i> nice book on concurrency. Clear, detailed and assuming very little knowledge on the part of the reader.
jestinjoy1超过 10 年前
The best I have seen about semaphores. I am using this in my course. It helped me to explain concepts simple and clear
merlinsbrain超过 10 年前
A great book which cleared a lot of my concepts about OS back in school. Re-read is due!
gamesbrainiac超过 10 年前
I recognize the author, Downey. He&#x27;s usually very clear in his explanations.
graycat超过 10 年前
Looks very nicely written.
tonteldoos超过 10 年前
Thought it was a book about flags first, but this is waaaay better! :)