sicp-3-4
Posted on 2015-03-02 01:03:22 +0900
in SICP
Lisp
3.39
- 101: P1 , P2
- 121: P2, P1
- 100: P1 computes
(* x x)
, then P2 completes and sets x to 101, then P1 executes the assignment.
3.41
As withdraw
and diposit
are both single modification operations,
it is not necessary to protect the balance
value, as it would always be valid.
3.42
It seems both of them would work.
3.43
The sum would be kept just because each account is consistent individually.
3.44
Ben is correct.
Exchange requires consitent states for both accounts, while transfer
would be fine as long as the sum of two accounts is correct.
3.45
serialized-exchange
has locked both accounts, which makes it impossible to
run deposit
or withdraw
.
3.46
If atomic is not guaranteed, then multiple process can gain the same mutex at the same time which
would result in wrong result.
3.47
3.48