6.001 Structure and Interpretation of Computer Programs
Recitation
#23
Friday, December 3, 2004
Review
- lazy evaluation
- concurrency
Practice
Give all possible values of x that can result from the following
code. (As a help, the important atomic operations are labeled by
letters.)
(define x 10)
C A B
(parallel-execute (lambda () (set! x (* x x)))
(lambda () (set! x (* x x x)))
G D E F
What
possible values of x remain if the
procedures are serialized, as below?
(define x 10)
(define s (make-serializer))
C A B
(parallel-execute (s (lambda () (set! x (* x x))))
(s (lambda () (set! x (* x x x))))
G D E F
What
if the procedures are serialized in a different way, as shown below?
(define x 10)
(define s (make-serializer))
(define t (make-serializer))
C A B
(parallel-execute (s (lambda () (set! x (* x x))))
(t (lambda () (set! x (* x x x))))
G D E F