Concurrency: How to Find Answers

So you understand serializers. You understand mutexes. You even understand test-and-set!. But how about when your concurrency has problems?

Remember, all problems are caused by mutations (stores into memory). So...

  1. Write down all Reads and Stores for each "thread" (each thing being executed in parallel).
  2. Write down all possible ways to order the Stores.
  3. Now write down all possible ways to insert the Reads. Remember that Reads from one thread usually have to happen before some later Store.

Confusing? Try the problems below.

(define x 3)

(parallel-execute (lambda () (set! x (+ x x)))
                  (lambda () (set! x (* x x))) )
(define x 3)
(define y 0)

(parallel-execute (lambda () (set! x (+ x 2)))
                  (lambda () (set! x (* x x)))
                  (lambda () (set! y x)) )

Back to Jordy's home page | Course home page