(define x 10)
(define s (make-serializer))
(parallel-execute (lambda () (set! x ((s (lambda() (* x x))))))
(s (lambda () (set! x (+ x 1))))
Let P1 be the process which squares x and P2 the process which increments x. P1
consists of two atomic steps: read the value of x and evaluate (* x x), write
the result back to x. P2 consists of an atomic step. Thus there are three
possible interleavings: P2 runs before P1, P2 runs between the two steps for
P1, and P2 runs after P1 completes. These produce the following values:
121: P2 increments x to 11 and then P1 sets x to x times x.
100: P1 accesses x (twice), then P2 sets x to 11, then P1 sets x.
101: P1 sets x to 100 and then P2 increments it 101.