The deadlock-avoidance method in this case provides a unique id for each account. We can order accounts using these ids when we acquire lock. It means that there is only one way to serialize two different accounts, so we can avoid.....
a. in terms of mutexes define make-semaphore n let cell list n mutex1 make-mutex mutex2 make-mutex define the-semaphore m cond eq? m 'acquire begin mutex1 'acquire set-car! cell - car cell 1 if car cell 0 begin mutex1 'release mut.....
Louiss reasoning is wrong because it can cause a deadlock when serialized-exchange is called. The serialized-exchange procedure makes itself serialized by using two serializer of each accounts. It calls exchange procedure, but the.....
I think that Louis is wrong. The essential difference between the transfer problem and the exchange problem is that the latter one accesses to an account twice, whereas the former one accesses only once. The two accesses in the ex.....
It is a safe change to make, and I think there is no difference of cuncurrency between the original solution and this one. Its because the serialization is done in the call of serialzed procedures, not in their creation.
...
Lets assume that we dont serialize balance procedure. If we call balance procedure when withdraw(or deposit) procedure is executing, balance procedure can returns value that withdraw(or deposit) procedure is not applied yet. Is th.....
P1 sets x to x^2 and?P2 sets x to x^3. 100 : P1 accesses x(twice), then P2 sets x to 1000, then P1 sets x. 1000 : P2 accesses x(three times), then P1 sets x to 100, then P2 sets x. 10000 : P1 changes x from 10 to 100 between the t.....
101 : P1 sets x to 100 and then P2 increments x to 101.
121 : P2 increments x to 11 and then P1 sets x to x times x.
11 : P2 accesses x, then P1 sets x to 100, then P2 sets x.
100 : P1 accesses x (twice), then P2 sets x to 11, the.....
define c- x y
let z make-connector
adder y z x
z
define c* x y
let z make-connector
multiplier x y z
z
define c/ x y
let z make-connector
if = 0 get-value y error divide by 0 -- c/ get-value y multip.....
define squarer a b define process-new-value if has-value? b if get-value b 0 error square less than 0 -- SQUARER get-value b set-value! a sqrt get-value b me if has-value? a set-value! b * get-value a get-value a me define process.....
The primitive multiplier takes three connectors as parameters.(m1, m2, and product). It functions only when we have two values of three connectors. The primitive squarer in the exercise passes two same connectors to the multiplier.....
For the half-adder example, we have to initialize the wire d and e by add-action!. If we create half-adder, the signal of wire e have to be signaled by 1. If we dont run the procedure immediately, in this case, the signal of wire .....
define ripple-carry-adder a b s c if or null? a null? b null? s 'ok let c-in make-wire full-adder car a car b c-in car s c ripple-carry-adder cdr a cdr b cdr s c-in delay = n * full-adder-delay = n * (2 * half-adder + or-gate-dela.....
define or-gate a1 a2 output
let b make-wire c make-wire d make-wire e make-wire f make-wire
and-gate a1 a1 b
and-gate a2 a2 c
inverter b d
inverter c e
and-gate d e f
inverter f output 'ok
or-g.....
Q3 ? 3개의 제곱 모든 자연수는 네개의 자연수(0을 포함) 제곱의 합으로 표현 될 수 있다. 예를 들어 3 = 12 + 12 + 12 + 02 31 = 52 + 22 + 12 + 12 그리고 어떤 자연수는 세개의 자연수(0을 포함) 제곱의 합으로 표현 될 수 있다. 예를 들어 3 = 12 + 12 + 12 17 = 02 .....