op_prg_mt_mutex_lock()
Abstract
Locks a previously created mutex.
Syntax
op_prg_mt_mutex_lock (mutex_ptr, option)
| Argument | Type | Description |
|---|---|---|
mutex_ptr |
PrgT_Mutex * |
Mutex to be locked. |
option |
int |
Locking mode for mutex. Must be one of the symbolic constants listed in the Details section (see also Table 63 “Mutex Lock Options Symbolic Constants“ on page 17). |
Return Type
Compcode
OPC_COMPCODE_SUCCESS if the mutex could be locked; OPC_COMPCODE_FAILURE otherwise.
Example
/* Evaluate reliability of beacons that are transmitted on the channel */
/* currently used by the receiver (i.e. if the initial status is VALID). */
if (rx_state_ptr->roaming_info_ptr->enable_roaming &&
chanmatch_status == OPC_TDA_RA_MATCH_VALID)
{
op_pk_nfd_access (pkptr, "Type", &rcvd_frame_type);
if (rcvd_frame_type == WlanC_Beac)
{
/* Serialize the execution of AP reliability evaluation, because the */
/* MAC of the receiver might be reading or writing the same information. */
op_prg_mt_mutex_lock (rx_state_ptr->roaming_info_ptr->roam_info_mutex, 0);
wlan_ap_reliability_eval (pkptr, OPC_FALSE, rx_state_ptr->roaming_info_ptr);
op_prg_mt_mutex_unlock (rx_state_ptr->roaming_info_ptr->roam_info_mutex);
}
}
Details
option must be one of the following symbolic constants:
OPC_MT_MUTEX_LOCK_READER—Lock reader/writer mutex in reader mode (shared)OPC_MT_MUTEX_LOCK_WRITER—Lock reader/writer mutex in writer mode (exclusive)
This operation fails if:
- The mutex was created with the
rankargument and a a higher-numbered mutex has already been locked by the same thread. - The mutex was created without the
OPC_MT_MUTEX_RECURSIVEoption and the thread has already locked the mutex.
See the Details section of op_prg_mt_mutex_create() for more information.
Purpose
Provides a way to lock a specific mutex, thus preventing other threads of code from acquiring the mutex.
Errors
- Recoverable Error: Null mutex pointer
- Recoverable Error: Mutex (
<description>): locking flagsOPC_MT_MUTEX_LOCK_READERandOPC_MT_MUTEX_LOCK_WRITERare mutually exclusive - Recoverable Error: Mutex (
<description>) is already locked by that thread for Objid (<lock_objid>) - Recoverable Error: Mutex (
<description>) of rank<rank>can't be locked after mutex (<locked_mutex_description>) of rank<locked_mutex_rank>
Reference
- Use the KP op_prg_mt_global_lock() to lock the global mutex
- Use the KP op_prg_mt_mutex_unlock() to unlock a specific mutex