Reentrant functions are typically more efcient than

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

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

Ask a homework question - tutors are online