Exercise 3.43: Suppose that the balances in
three accounts start out as 20, and $30, and that multiple processes run,
exchanging the balances in the accounts. Argue that if the processes are run
sequentially, after any number of concurrent exchanges, the account balances
should be 20, and $30 in some order. Draw a timing diagram like the one
in Figure 3.29 to show how this condition can be violated if the
exchanges are implemented using the first version of the account-exchange
program in this section. On the other hand, argue that even with this
exchange program, the sum of the balances in the accounts will be
preserved. Draw a timing diagram to show how even this condition would be
violated if we did not serialize the transactions on individual accounts.
练习 3.43:假设三个账户的余额初始为 20 和 10、30。画出类似图 3.29 的时序图,说明若用本节第一版账户交换程序实现交换操作,上述条件是如何被违反的。另一方面,请论证:即使使用这个交换程序,各账户余额之和仍将被保持。再画一张时序图,说明若我们不对单个账户的事务加以串行化,则连这一条件也会被违反。