Grid Community Toolkit
6.2.1607800521 (tag: v6.2.20201212)
|
Mutual Exclusion. More...
Data Structures | |
union | globus_mutex_t |
Mutex. More... | |
union | globus_mutexattr_t |
Mutex attribute. More... | |
struct | globus_rmutex_t |
Recursive Mutex. More... | |
Typedefs | |
typedef int | globus_rmutexattr_t |
Recursive mutex attribute. | |
Functions | |
int | globus_mutex_init (globus_mutex_t *mutex, globus_mutexattr_t *attr) |
Initialize a mutex. More... | |
int | globus_mutex_destroy (globus_mutex_t *mutex) |
Destroy a mutex. More... | |
int | globus_mutex_lock (globus_mutex_t *mutex) |
Lock a mutex. More... | |
int | globus_mutex_unlock (globus_mutex_t *mutex) |
Unlock a mutex. More... | |
int | globus_mutex_trylock (globus_mutex_t *mutex) |
Lock a mutex if it is not locked. More... | |
int | globus_mutexattr_init (globus_mutexattr_t *attr) |
Initialize a mutex attribute. More... | |
int | globus_mutexattr_destroy (globus_mutexattr_t *attr) |
Destroy a mutex attribute. More... | |
Recursive Mutex | |
int | globus_rmutex_init (globus_rmutex_t *rmutex, globus_rmutexattr_t *rattr) |
Initialize a recursive mutex. More... | |
int | globus_rmutex_lock (globus_rmutex_t *rmutex) |
Lock a recursive mutex. More... | |
int | globus_rmutex_unlock (globus_rmutex_t *rmutex) |
Unlock a recursive mutex. More... | |
int | globus_rmutex_destroy (globus_rmutex_t *rmutex) |
Destroy a recursive mutex. More... | |
Mutual Exclusion.
The Globus runtime includes three portable, related mutual exclusion primitives that can be used in applications and libraries. These are
int globus_mutex_destroy | ( | globus_mutex_t * | mutex | ) |
Destroy a mutex.
The globus_mutex_destroy() function destroys the mutex pointed to by its mutex parameter. After a mutex is destroyed it may no longer be used unless it is again initialized by globus_mutex_init(). Behavior is undefined if globus_mutex_destroy() is called with a pointer to a locked mutex.
mutex | The mutex to destroy |
int globus_mutex_init | ( | globus_mutex_t * | mutex, |
globus_mutexattr_t * | attr | ||
) |
Initialize a mutex.
The globus_mutex_init() function creates a mutex variable that can be used for synchronization. Currently, the attr parameter is ignored.
mutex | Pointer to the mutex to initialize. |
attr | Ignored. |
int globus_mutex_lock | ( | globus_mutex_t * | mutex | ) |
Lock a mutex.
The globus_mutex_lock() function locks the mutex pointed to by its mutex parameter.
Upon successful return, the thread calling globus_mutex_lock() has an exclusive lock on the resources protected by mutex. Other threads calling globus_mutex_lock() will wait until that thread later calls globus_mutex_unlock() or globus_cond_wait() with that mutex. Depending on the thread model, calling globus_mutex_lock on a mutex locked by the current thread will either return an error or result in deadlock.
mutex | The mutex to lock. |
int globus_mutex_trylock | ( | globus_mutex_t * | mutex | ) |
Lock a mutex if it is not locked.
The globus_mutex_trylock() function locks the mutex pointed to by its mutex parameter if no thread has already locked the mutex. If mutex is locked, then globus_mutex_trylock() returns EBUSY and does not block the current thread or lock the mutex. Upon successful return, the thread calling globus_mutex_trylock() has an exclusive lock on the resources protected by mutex. Other threads calling globus_mutex_lock() will wait until that thread later calls globus_mutex_unlock() or globus_cond_wait() with that mutex.
mutex | The mutex to lock. |
int globus_mutex_unlock | ( | globus_mutex_t * | mutex | ) |
Unlock a mutex.
The globus_mutex_unlock() function unlocks the mutex pointed to by its mutex parameter. Upon successful return, the thread calling globus_mutex_unlock() no longer has an exclusive lock on the resources protected by mutex. Another thread calling globus_mutex_lock() may be unblocked so that it may acquire the mutex. Behavior is undefined if globus_mutex_unlock is called with an unlocked mutex.
mutex | The mutex to unlock. |
int globus_mutexattr_destroy | ( | globus_mutexattr_t * | attr | ) |
Destroy a mutex attribute.
The globus_mutexattr_destroy() function destroys the mutex attribute structure pointed to by its attr parameter.
attr | Attribute structure to destroy. |
int globus_mutexattr_init | ( | globus_mutexattr_t * | attr | ) |
Initialize a mutex attribute.
The globus_mutexattr_init() function initializes the mutex attribute structure pointed to by its attr parameter. Currently there are no attribute values that can be set via this API, so there's no real use to calling this function.
attr | Attribute structure to initialize. |
int globus_rmutex_destroy | ( | globus_rmutex_t * | rmutex | ) |
Destroy a recursive mutex.
The globus_rmutex_destroy() function destroys a recursive mutex If the mutex is currently locked, behavior is undefined.
rmutex | Mutex to unlock |
int globus_rmutex_init | ( | globus_rmutex_t * | rmutex, |
globus_rmutexattr_t * | rattr | ||
) |
Initialize a recursive mutex.
The globus_rmutex_init() function initializes a recursive mutex, that is, one which may be locked multiple times by a single thread without causing deadlock.
rmutex | A pointer to the mutex to initialize |
rattr | IGNORED |
int globus_rmutex_lock | ( | globus_rmutex_t * | rmutex | ) |
Lock a recursive mutex.
The globus_rmutex_lock() function acquires the lock controlled by rmutex. This may be called multiple times in a single thread without causing deadlock, provided that a call to globus_rmutex_unlock() is called the same number of times as globus_rmutex_lock(). Once acquired, all other threads calling this function will be blocked until the mutex is completely unlocked.
rmutex | A pointer to the mutex to lock |
int globus_rmutex_unlock | ( | globus_rmutex_t * | rmutex | ) |
Unlock a recursive mutex.
The globus_rmutex_unlock() function decrements the lock count for the lock pointed to by rmutex. If the lock count is reduced to zero, it also unblocks a thread which is trying to acquire the lock if there is one.
rmutex | Mutex to unlock |