SICP Study

3.4 Concurrency: Time Is of the Essence

3.4.1 The Nature of Time in Concurrent Systems

To quote some graffiti seen on a Cambridge building wall: “Time is a device that was invented to keep everything from happening at once. (Footnote 3.35)

Correct behavior of concurrent programs

3.4.2 Mechanisms for Controlling Concurrency

Serializing access to shared state

(define (swap-value! f)
  (set-value! (f (get-value))))

Serializers in Scheme

Complexity of using multiple shared resources

(define (exchange acc1 acc2)
  (let ((diff (- (acc1 'balance) (acc2 'balance))))
    ((acc1 'withdraw) diff)
    ((acc2 'deposit) diff)))

Implementing serializers

Deadlock

Concurrency, time, and communication