Question: Detecting Deadlock: Assume you have created two threads A and B. These threads must share two resources, we control the access to these resources through

Detecting Deadlock: Assume you have created two threads A and B. These threads must share two resources, we control the access to these resources through mutexes Pi and Vi where i represents the resource. Write a series of programs to demonstrate each of the following possibilities. In a comment field before your code prove deadlock exists or not. Proving deadlock is an example of an existence proof. Proving no deadlock requires an exhaustion proof. I recommend that you use mutexes1.cpp as a framework for s1-s7.
Case 1: (s1.cpp)
Process A Process B
P1 P1
P2 P2
V1 V1
V2 V2
Case 2: (s2.cpp)
Process A Process B
P1 P1
P2 P2
V2 V2
V1 V1
Case 3: (s3.cpp)
Process A Process B
P1 P1
V1 V1
P2 P2
V2 V2
Case 4: (s4.cpp)
Process A Process B
P1 P2
P2 P1
V1 V1
V2 V2
Case 5: (s5.cpp) Process A Process B
P1 P2
V1 V2
P2 P1
V2 V1
Case 6: (s6.cpp)
Process A Process B
P1 P2
V1 V2
Case 7: (s7.cpp)
Process A Process B
P2 P1
V2 V1
P1 P2
V1 V2
Problem 8. Red, White and Blue Gadgets. In this program you will create a blue thread, a white thread and k-red thread. Each color thread can produce a color part for assembly. The assembly thread requires that at least 3 blue, 3 red and 2 white gadgets are in the bins. The total of number of gadgets in the red, blue and white bins can not exceed more than 12. Only one gadget can be assembled at a time. Write a pthreads program to simulate the production of one-hundred products. Name your program rwb.cpp

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!