prg_mt_mutex_lock()
Abstract
Attempts to lock a mutex.
Syntax
prg_mt_mutex_lock (mutex_ptr, option, rank_ptr, description, lock_id)
| Argument | Type | Description |
|---|---|---|
mutex_ptr |
PrgT_Mutex * |
Mutex object to lock. |
option |
int |
If the mutex is a reader/writer mutex, this should be one of PRGC_MT_MUTEX_LOCK_READER PRGC_MT_MUTEX_LOCK_WRITER, otherwise ignored |
rank_ptr |
int * |
If mutex is set to check for ranks, this will be filled with the lowest ranked mutex for the process if the lock attempt failed. If set to PRGC_NIL, no rank value will be stored. |
description |
char * |
If the mutex lock attempt failed, this will be a copy of the description of the lowest ranked mutex locked by the process. The argument should be a char array big enough to store any description. If set to PRGC_NIL, no description will be copied. |
lock_id |
int |
ID of the locking process (arbitrary value specified by caller) |
Return Type
Success or failure code; one of the values in Table 6 Mutex Package Symbolic Constants.
Header
prg_mt.h
Details
This function attempts to lock the specified mutex object. If the mutex is already locked in such a way that it can't be shared (e.g., not recursive or not reader locked of reader/writer) the calling process will be blocked until the mutex is unlocked and available. Processes that are blocked waiting for a mutex to be available are blocked and released in the order in which they requested the lock.