huangzworks / SICP-answers

我的 SICP 解题集

Home Page:http://sicp.readthedocs.org/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

练习 3.47

felix021 opened this issue · comments

基于 test-and-set! 的实现是错误的,因为在 release 里的 (set! n (+ n 1)) 仍然会出现竞争,可能导致信号量的实际值逐渐减小到1,因此逻辑上仍然是有问题的。

另外,你的实现已经不是用 test-and-set! 了,而是用你的 "test-and-add!"。按照题目的意思,应当是直接使用书上的 test-and-set! 来实现。

我的实现供参考: https://github.com/felix021/sicp/blob/master/code/3-47.scm