(define (test-and-set! cell)Let P1 denote the event of first process calling (car cell) and P2 denote the event of first process calling (set-car! cell true). Similarly let Q1 denote the event of second process calling (car cell) and Q2 denote the event of second process calling (set-car! cell true).
(if (car cell)
true
(begin (set-car! cell true)
false)))
Since test-and-set! is not atomic, so following interleaved execution sequence is possible...
P1 Q1 P2 Q2
With this sequence both the processes will aquire the mutex and mutex symantics that only one can aquire it at one time is broken.
No comments:
Post a Comment