MDAT  1.0
 All Classes Files Functions Variables Typedefs Pages
mdat.h File Reference

MDAT library interface functions. More...

Go to the source code of this file.


typedef const char *(* CheckerFuncPtr )(int, const char *, const char *)
 Function pointer type for checker function. More...


void mdat_init (int numThreads, char *traceName, CheckerFuncPtr checkerFunc, int useInteractive, int useSeed, unsigned int seed)
 Initializes MDAT library. More...
void mdat_thread_start (int id, const char *property)
 Starts a thread. More...
void mdat_thread_finish ()
 Mark the currently running thread as completed. More...
void mdat_invoke_scheduler (int location)
 Invokes the scheduler, possibly causing a new thread to run. More...
void mdat_mutex_init (const char *name, pthread_mutex_t *lock, pthread_mutexattr_t *attr)
 Registers a new mutex lock. More...
void mdat_mutex_lock (pthread_mutex_t *lock)
 Implements the lock operation. More...
void mdat_mutex_unlock (pthread_mutex_t *lock)
 Implements the unlock operation. More...
void mdat_sem_init (const char *name, sem_t *sem, int pshared, int value)
 Registers a new semaphore. More...
void mdat_sem_wait (sem_t *sem)
 Implements the wait operation for a semaphore. More...
void mdat_sem_post (sem_t *sem)
 Implements the post operation for a semaphore. More...
void mdat_enter_section (const char *section)
 Enters the specific section. More...

Detailed Description

This file contains the external library functions for MDAT.

Typedef Documentation

typedef const char *(* CheckerFuncPtr)(int, const char *, const char *)

See the CheckerWrapper documentation for more on the checker callback function.

Function Documentation

void mdat_init ( int  numThreads,
char *  traceName,
CheckerFuncPtr  checkerFunc,
int  useInteractive,
int  useSeed,
unsigned int  seed 

This function initializes the MDAT library. The application must call mdat_init before calling any other functions.

[in]numThreadsNumber of threads that will concurrently executing.
[in]traceNameName of the output trace file. Set to NULL to suppress tracing.
[in]checkerFuncProgram-specific checker. Set to NULL for no checker.
[in]useInteractiveIf nonzero (true), interactive scheduling is used. Otherwise, random scheduling is used.
[in]useSeedIf nonzero (true), use the seed parameter as the random seed. If zero (false), generate a random seed based on the current time. This parameter is ignored if interactive scheduling is used.
[in]seedThe specified random seed. This parameter is ignored if interactive scheduling is used or if useSeed is zero.
void mdat_thread_start ( int  id,
const char *  property 

This function registers a thread with MDAT. This function must be called before a thread makes any synchronization calls. MDAT takes over the scheduling of the thread in this function – threads may wait in this function until they are dispatched by MDAT.

[in]idId number. Each thread must have a unique number from 0 to n-1 where n is the number of threads.
[in]propertyString indicating the type of thread. For example, in the reader-writers problem, some threads will have the property “reader” and other threads will have the property “writer”.
void mdat_thread_finish ( )

Marks the currently running thread as complete – the thread will no longer be scheduled by MDAT. Threads cannot be restarted once they have finished.

void mdat_invoke_scheduler ( int  location)

Forces MDAT to make a scheduling decision based on the scheduling mode (see ThreadManager for more details). This call could be inserted manually by the programmer or inserted automatically by the instrumentation tool (recommended).

[in]locationAn id associated with the call. This parameter is used to update the location field in the trace. It is recommended but not required to have each location be unique. (Note: Only use positive integers as negative integers are used for calls internal to MDAT.)
void mdat_mutex_init ( const char *  name,
pthread_mutex_t *  lock,
pthread_mutexattr_t *  attr 

Registers a new mutex lock with the LockManager.

[in]namename of the lock
[in]locklock variable
[in]attrlock attributes (ignored by MDAT)
void mdat_mutex_lock ( pthread_mutex_t *  lock)

Thread takes a lock if available. If the lock is unavailable, the thread will wait until it acquires the lock.

[in]locklock variable
void mdat_mutex_unlock ( pthread_mutex_t *  lock)

Gives up the lock. If one or more threads are waiting, one thread will be woken up and given the lock. If no threads are waiting, the lock is returned to the unlocked state.

[in]locklock variable
void mdat_sem_init ( const char *  name,
sem_t *  sem,
int  pshared,
int  value 

Registers a new semaphore with the Semaphore Manager

[in]namename of the semaphore
[in]semsemaphore variable
[in]psharedsharing value (ignored by MDAT)
[in]valueinitial value of semaphore
void mdat_sem_wait ( sem_t *  sem)

Decrement the semaphore. If the value is negative, the thread must wait until woken up by a subsequent post operation.

[in]semsemaphore variable
void mdat_sem_post ( sem_t *  sem)

Increment the semaphore. If one or more threads are waiting, one thread will be woken up.

[in]semsemaphore variable
void mdat_enter_section ( const char *  section)

Records that a thread has entered a particular section of the code. In addition, it notifies the checker that the current thread has entered the appropriate section.

[in]sectionThe section that the thread has entered. Common sections include “Entry”, “Exit”, “Critical”, and “Remainder”. Note that you do not have to use these particular sections – any set of strings will so as long the strings are recognized by the checker.
This is a personal WEB site developed and maintained by an individual and not by Seattle University. The content and link(s) provided on this site do not represent or reflect the view(s) of Seattle University. The individual who authored this site is solely responsible for the site's content. This site and its author are subject to applicable University policies including the Computer Acceptable Use Policy (