CS 241: Deadlock Resilient Mutex

 CS 241: Deadlock Resilient Mutex

Due: Monday, Dec. 3, 2012 at 11:59pm

Introduction

This MP will help you to be familiar with POSIX mutex locks in C. POSIX mutexes are prone to deadlocks and contain no deadlock prevention, detection, or avoidance mechanisms. In this MP, you will be writing a C library that extends POSIX mutexes allowing for deadlock prevention, detection, and avoidance.

To make the programming easier, we split this MP up into two unique parts: the deadlock resilient mutexes part and the wait-for graph part (as detecting deadlocks in mutexes require checking for cycles inside a wait-for graph).

Tasks

[Part 1]

Complete the wait-for graph library (libwfg) functions. You will need to edit both libwfg.c and libwfg.h to complete this part. We have provided testwfg.c to allow you to test your wait-for graph independently of the rest of this MP.

We have also provided you with our standard queue data structure. You can use this as either a queue or a vector if you need to store lists of data for either part of this MP.

[Part 2]

Complete the deadlock resilient mutex (libdrm) functions. You will need to edit both libdrm.c and libdrm.h to complete this part.

As part of implementing libdrm, you will find that the drm_setmode() function takes in four different modes that your library must operate under. Your library should behave in the following way, based on the mode set in drm_setmode():

In order to complete these functions, you will need to create your own mutexes to protect your own access to libwfg from within libdrm. Each drm_t will also need to contain a pthread_mutex_t in order to actually preform the underlying locking and unlocking that is requried as part of the mutex. Since you are preventing or avoiding deadlock, you may not always actaully call the underlying pthread_mutex_lock() if it may cause a deadlock.

Test Files

We have provided you with five test programs for you:

Feel free to modify or change these examples. The only files that are picked up by the autograder for this MP are libwfg.c, libwfg.h, libdrm.c, and libdrm.h.

Compile / Run

To compile, run the following commands from a command prompt on a Linux machine:

$ make clean
$ make

To run the example code:

$ ./testwfg
$ ./example-NDC
$ ./example-DP
$ ./example-DA
$ ./example-DD

Generated on 22 Oct 2012 for Deadlock Resilient Mutex by  doxygen 1.6.1