Example of deadlock and race conditions:
An example of deadlock:
An example of a race condition:
Thread A Thread B
lock mutex 1 lock mutex 2
lock mutex 2 lock mutex 1
Time Thread A Thread B
Time 1 g=g+5;
Time 2 Context switch to Thread B
Time 3 g=(a**2)+(b**2);
Time 4 Context switch to Thread A
Time 5 val = g;
From THREADTIME: by Norton/Dipasquale Prentice-Hall.
Previous slide
Next slide
Back to first slide
View graphic version