Answer till 3.45
parent
7bb4ba9040
commit
dce7ffebf9
|
@ -2,6 +2,12 @@
|
|||
|
||||
(newline) (display "ex-2.73 - deriv data-directed") (newline)
|
||||
|
||||
(define *op-table* (make-hash-table))
|
||||
(define (put op type proc)
|
||||
(hash-table/put! *op-table* (list op type) proc))
|
||||
(define (get op type)
|
||||
(hash-table/get *op-table* (list op type) #f))
|
||||
|
||||
(display "a. - see comments\n")
|
||||
; a.
|
||||
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
(load "util.scm")
|
||||
|
||||
(display "\nex-3.38\n")
|
||||
(display "[answered]\n")
|
||||
|
||||
|
@ -63,8 +61,8 @@
|
|||
|
||||
; Ben's concern does not apply. Say, we have a withdraw and a balance check.
|
||||
; Depending on the order of execution the balance check would show the balance
|
||||
; before or after the withdraw. This behavior is expectected and would not be
|
||||
; migated by serializing balance.
|
||||
; before or after the withdraw. This behavior is expected and would not be
|
||||
; avoided by serializing balance.
|
||||
|
||||
(display "\nex-3.42\n")
|
||||
(display "[answered]\n")
|
||||
|
@ -73,6 +71,39 @@
|
|||
; model of how the serializer works, yet.
|
||||
|
||||
(display "\nex-3.43\n")
|
||||
(display "[answered]\n")
|
||||
|
||||
; A swap of account balances maintains each individual balance. Hence, only the
|
||||
; order of $10, $20, $30 can change and not the value.
|
||||
|
||||
; a b c
|
||||
; $10 $20 $30 (swap a b = 10) (swap a c = 20)
|
||||
; $20 $10 $30
|
||||
; $40 $10 $10
|
||||
|
||||
; The sum of balances will be preserved because the exchange procedure deposits
|
||||
; what it withdraws. That works because it calculates `difference` before doing
|
||||
; the transactions.
|
||||
|
||||
; If the individual transactions would not be serialized we could run into a
|
||||
; situation where (swap a c) overrides a to be $30, for example, as we have
|
||||
; seen in previous exercises.
|
||||
|
||||
(display "\nex-3.44\n")
|
||||
(display "[answered]\n")
|
||||
|
||||
; Louis Reasoner is wrong. Assuming the balance on from-account is high enough
|
||||
; transfer is going to work. The essential difference is that executing a list
|
||||
; of transactions of absolute amounts is commutative. Exchange, on the other,
|
||||
; is not commutative. On exchange has to finish before another one and the
|
||||
; order matters.
|
||||
|
||||
(display "\nex-3.45\n")
|
||||
(display "[answered]\n")
|
||||
|
||||
; When serialized-exchange is call it tries to serialize the deposit and
|
||||
; withdraw calls that are already serialized by the same serializer. That would
|
||||
; result in a deadlock because because the outer serialized procedure would
|
||||
; have to call the inner serialized procedure and they cannot be executed at
|
||||
; the same time because they are serialized by the same serializer.
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
(load "util.scm")
|
||||
|
||||
(display "\nex-3.46\n")
|
||||
|
||||
(display "\nex-3.47\n")
|
||||
|
||||
(display "\nex-3.48\n")
|
||||
|
Loading…
Reference in New Issue