MDAT  1.0
 All Classes Files Functions Variables Typedefs Pages
LockManager Class Reference

Lock manager. More...

Public Member Functions

void addLock (const char *name, pthread_mutex_t *lock)
 Registers a new lock. More...
 
void acquireLock (int id, pthread_mutex_t *lock)
 Implements the lock operation. More...
 
void releaseLock (int id, pthread_mutex_t *lock)
 Implements the unlock operation. More...
 
string getLockTable () const
 Returns the lock table in a string. More...
 

Detailed Description

The lock manager is responsible for managing the locks used during the concurrent sections of the program. Each lock must first be registered using addLock. The state of locks are adjusted via the acquireLock and releaseLock methods.

Member Function Documentation

void LockManager::addLock ( const char *  name,
pthread_mutex_t *  lock 
)

Registers a new lock.

Parameters
[in]namename of lock
[in]locklock variable
void LockManager::acquireLock ( int  id,
pthread_mutex_t *  lock 
)

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

Parameters
[in]idid of thread trying to acquire lock
[in]locklock variable
void LockManager::releaseLock ( int  id,
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.

Parameters
[in]idid of thread trying to acquire lock
[in]locklock variable
string LockManager::getLockTable ( ) const

Returns the lock table in a string in a trace-friendly format.

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 (www.seattleu.edu/policies).