You have chosen to sponsor your bid up to a maximum amount of .
1. First compile and execute the distributed program. Note that it deadlocks.
In order to make running it less frustrating, I made it terminate with the
message ``No runnable threads."
2. Modify the program by changing the order of calls to use two-phase locking
and produce a version of the program with modified threads, which doesn't
deadlock. Note that it never terminates, because each thread sits in a rather
pointless infinite loop.
3. Now go back and solve the deadlock problem by modifying the resource management
package, instead of the thread code: Check for deadlock when a thread waits for
a semaphore, and if granting it would cause deadlock, make the thread wait until
things are safe. (In order to check, you'll need to define some new data structures,
and perhaps insert some additional code into each thread to manage them.)
Additional Project Description:
05/19/2013 at 22:56 IST
Please read the description.
Target platform is Linux (pref. CentOS, Ubuntu, SuSE)
Must be completed today 5/19
Changes must be documented with rationale.
Code must be modified/fixed not rewrittten
C "Experts" in concurrent programming need only apply. If you think it's going to take you more than a few hours to finish this (estimated 3-5 hrs) then you're probably not an expert concurrent programming in C.
The code can be found in the attached sync.c
05/19/2013 at 23:25 IST
Do not use Deadlock.c aside from the fact that it has numerous errors, it also includes dce/pthread.h. which does not exist on most systems. Please use sync.c. The first thing you'll notice is when you compile and run it is that it deadlocks. That is part of the problem that is being solved here.
Also, for those of you who haven't figured this out, you'll probably have to use the -pthread flag when compiling with gcc.