3장 연습문제를 풀다가, 스트림이라는 아이가 나왔다. cons-stream, delay 등등을 이렇게 동작해 라면서 코드를 보여주는데, 얘네들이 보여주는 코드를 가지고 문제를 풀면 스트림이 스트림이 아니게 된다. (stream-enuerate-interval 0 100000) 이런걸 만들면, 만.....
What is the value of sum after each of the above expressions is evaluated?
210
What is the printed response to evaluating the stream-ref and display-stream expressions?
136
10
15
45
55
105
120
190
210
done
...
I would not mention an exact scenario where the deadlock-avoidance mechanism described in the book does not work. However, the mechanism is a simple example of bankers algorithm. There are many cases that this algorithm does not w.....
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.....
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.....
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 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.....