3.49 Exercise 3.49
Suppose you wanted to write a program to swap the balances of your account and the other account in the bank with the balance closest to yours. Clearly, once you start examining account balances, it would be problematic if your account balance would change at any point before the transaction is complete – this could invalidate your search results, making the end result of the program incorrect. But if you need to lock your account before finding the other account to match it, then you can no longer follow the procedure above – the matching account may have a higher or a lower number, and if it has a lower one, you’ve violated the rules that were attempting to prevent deadlock.