MDAT
1.0
|
MDAT is a multithreaded testing and debugging infrastructure designed for students learning to program with multiple threads. MDAT automatically generates random schedules to allow students to more thoroughly test their programs. The design of MDAT takes full control over the scheduling allowing a failing run to be reproduced. To assist debugging, MDAT includes an output trace that shows the status of all threads, locks, and semaphores in the program and has an interactive mode that allows students to try out their own schedules.
MDAT consists of four directories:
doc
: documentationmdat
: MDAT libraryproblems
: three different synchronization problems that use MDATsuds
: SUDS instrumentation toolTo compile the MDAT library, switch to the mdat directory and type: make
To compile the SUDS instrumentation tool, switch to the suds directory and type: make
To compile any of the three synchronization problems, switch to the subdirectory under problems and type: make
(Note: The synchronization problems require that the MDAT library and suds
are already built.)
This section describes the interface for the MDAT library. The interface is defined in mdat.h so all programs using the interface need to include this file. MDAT can be used for C and C++ problems but suds
, the provided instrumentation tool only supports C programs.
From a synchronization perspective, MDAT supports both locks and semaphores. Only the basic synchronization operations are used as shown in the following table:
MDAT function | POSIX function |
---|---|
mdat_mutex_init | pthread_mutex_init |
mdat_mutex_lock | pthread_mutex_lock |
mdat_mutex_unlock | pthread_mutex_unlock |
mdat_sem_init | sem_init |
mdat_sem_wait | sem_wait |
mdat_sem_post | sem_post |
Some implementation notes regarding these functions:
In addition to these synchronization functions, the MDAT interface consists of five additional functions:
This section describes relevant details of the MDAT implementation.
For better or for worse, all errors detected by MDAT cause the program to abort. Errors are handled by the trace facility and the error message will appear both in the trace and on the console. Errors are split up into two categories: internal errors and external errors. Internal errors are due to the result of failed sanity checks within MDAT. They refer to bugs within the MDAT library itself. If you encounter an internal error, please send an email to elars with a description of the problem. on@s eattl eu.e du
External errors either refer to synchronization bugs in the code (such as deadlock) or cases where MDAT was not used properly (such as initializing MDAT with an invalid scheduler mode).
Scheduling decisions are made at the following times:
The next thread to execute (including the very first thread) is determined by the scheduling mode:
If multiple threads are waiting to acquire a lock or semaphore, a similar approach is used to select which thread to wake-up:
Additional notes:
Since each problem or program has their own unique synchronization requirements, the checker is external to MDAT. MDAT provides an interface for interacting with a checker via a callback function. Please consult the CheckerWrapper documentation for further details.
MDAT has been used with three synchronization problems:
All problems are described in the Book of Semaphores. To use MDAT with different problems, we expect that most people would start with an existing problem and modify the code appropriately. Since readers-writers is the most familiar of the three problems, detailed documentation is provided. In addition, a solution is provided in its source code directory. The other two problems are implemented in a very similar fashion – the documentation only describes the differences with respect to the readers-writers problem. Solutions are not provided for these problems.