H struct timespec maketimeoutuint secs static

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: ntrolling the trajectories of concurrent programs so that they avoid unsafe regions. The basic idea is to associate a semaphore ×, initially 1, with each shared variable (or related set of shared variables) and then surround the corresponding critical section with È ´×µ and Î ´×µ operations.2 For example, the progress graph in Figure 11.16 shows how we would use semaphores to properly synchronize our example counter program. In the figure, each state is labeled with the value of semaphore × in that state. The crucial idea is that this combination of È and Î operations creates a collection of states, called a forbidden region, where × ¼. Because of the semaphore invariant, no feasible trajectory can include one of the states in the forbidden region. And since the forbidden region completely encloses the unsafe region, no feasible trajectory can touch any part of the unsafe region. Thus, every feasible trajectory is safe, and regardless of the ordering of the instructions at runtime, the program correctly increments the counter. Thread 2 1 1 0 0 0 0 1 1 T2 1 1 0 0 0 0 1 1 V(s) 0 0 Forbidden region -1 -1 -1 -1 -1 -1 -1 0 0 S2 0 0 -1 0 0 U2...
View Full Document

Ask a homework question - tutors are online