灯下 登录
计算机科学 / SICP / 3.4.2 Mechanisms for Controlling Concurrency

Exercise 3.46 · 习题

Exercise 3.46: Suppose that we implement

test-and-set! using an ordinary procedure as shown in the text, without

attempting to make the operation atomic. Draw a timing diagram like the one in

Figure 3.29 to demonstrate how the mutex implementation can fail by

allowing two processes to acquire the mutex at the same time.

练习 3.46:假设我们按正文所示,用普通过程实现 test-and-set!,而不试图使该操作成为原子操作。画出类似图 3.29 的时序图,说明互斥体的实现是如何因允许两个进程同时获取互斥体而失效的。