Unformatted text preview: ory. Conversely, a trajectory that touches any part of the unsafe region is an unsafe trajectory. Figure 11.15 shows examples of safe and unsafe trajectories through the state space of our example badcnt.c program. The upper trajectory skirts the unsafe region along its left and top sides, and thus is safe. The lower trajectory crosses the unsafe region with one of its diagonal transitions, and thus is unsafe. 578 CHAPTER 11. CONCURRENT PROGRAMMING WITH THREADS Thread 2 T2 S2 U2 L2 H2 H1 L1 U1 S1 T1 Thread 1 Figure 11.13: An example trajectory. Thread 2 T2 S2 critical section wrt cnt U2 L2 H2 H1 L1 U1 S1 T1 Thread 1
Unsafe region critical section wrt cnt Figure 11.14: Critical sections and unsafe regions. 11.4. SYNCHRONIZING THREADS WITH SEMAPHORES
Thread 2 579 T2 S2 critical section wrt cnt U2 L2 H2 Safe trajectory Unsafe region Unsafe trajectory H1 L1 U1 S1 T1 Thread 1 critical section wrt cnt Figure 11.15: Safe and unsafe trajectories. Any safe trajectory will correctly update the shared cou...
View Full Document