In a mathematical sense we can think of each host

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: eger ID. Outline a different approach that does not call the malloc or free functions. B. What are the advantages and disadvantages of this approach? 11.7.2 Deadlocks Semaphores introduce the potential for a nasty kind of runtime error, called deadlock, where a collection of threads are blocked, waiting for a condition that will never be true. The progress graph is an invaluable tool for understanding deadlock. For example, Figure 11.32 shows the progress graph for a pair of threads that use two semaphores for sharing. From this graph, we can glean some important insights about deadlock: Thread 2 V(s) ... V(t) ... deadlock state A trajectory that does not deadlock ... Forbidden region for s P(s) ... P(t) Initially s=1 t=1 ... ... d Forbidden region for t Deadlock region A trajectory that deadlocks P(s) ... P(t) ... V(s) ... V(t) Thread 1 Figure 11.32: Progress graph for a program that can deadlock. 600 CHAPTER 11. CONCURRENT PROGRAMMING WITH THREADS ¯ The programmer has incorrectly ordered the È and Î operation...
View Full Document

Ask a homework question - tutors are online