-
Notifications
You must be signed in to change notification settings - Fork 770
Synchronization Concepts: Review Questions
Note thread-programming synchronization problems are on a separate wiki page. This page focuses on conceptual topics. Question numbers subject to change
What do each of the Coffman conditions mean? (e.g. can you provide a definition of each one)
- Hold and wait
- Circular wait
- No pre-emption
- Mutual exclusion
Give a real life example of breaking each Coffman condition in turn. A situation to consider: Painters, paint and paint brushes. Hold and wait Circular wait No pre-emption Mutual exclusion
Identify when Dining Philosophers code causes a deadlock (or not). For example, if you saw the following code snippet which Coffman condition is not satisfied?
// Get both locks or none.
pthread_mutex_lock(a);
if (pthread_mutex_trylock(b)) { /* failed */
pthread_mutex_unlock(a);
...
}
How many processes are blocked?
- P1 acquires R1
- P2 acquires R2
- P1 acquires R3
- P2 waits for R3
- P3 acquires R5
- P1 acquires R4
- P3 waits for R1
- P4 waits for R5
- P5 waits for R1
How many of the following statements are true for the reader-writer problem?
- There can be multiple active readers
- There can be multiple active writers
- When there is an active writer the number of active readers must be zero
- If there is an active reader the number of active writers must be zero
- A writer must wait until the current active readers have finished
Legal and Licensing information: Unless otherwise specified, submitted content to the wiki must be original work (including text, java code, and media) and you provide this material under a Creative Commons License. If you are not the copyright holder, please give proper attribution and credit to existing content and ensure that you have license to include the materials.