内容 3.4 Concurrency: Time Is of the Essence · 257
练习 自检推理
Exercise 3.48: Explain in detail why the
deadlock-avoidance method described above, (i.e., the accounts are numbered,
and each process attempts to acquire the smaller-numbered account first) avoids
deadlock in the exchange problem. Rewrite serialized-exchange to
incorporate this idea. (You will also need to modify make-account so
that each account is created with a number, which can be accessed by sending an
appropriate message.)
练习 3.48:请详细说明为何上述死锁规避方法(即对账户编号,并让每个进程总是先尝试获取编号较小的账户)能够在交换问题中避免死锁。请重写 serialized-exchange 以体现这一思路。(你还需要修改 make-account,使每个账户在创建时都带有一个编号,并可通过发送适当消息来访问该编号。)
我的笔记 自动保存