op_prg_mt_mutex_unlock()
Abstract
Unlocks a specified mutex.
Syntax
op_prg_mt_mutex_unlock (mutex_ptr)
| Argument | Type | Description |
|---|---|---|
mutex_ptr |
PrgT_Mutex |
Mutex to be unlocked. |
Return Type
Compcode
OPC_COMPCODE_SUCCESS if the mutex could be unlocked; 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
When a thread of code has successfully locked a mutex, it prevents all other threads from locking that mutex until it unlocks the mutex.
A thread of code trying to unlock a mutex it hasn’t previously locked will not affect the state of the mutex.
If the mutex was created with the option OPC_MT_MUTEX_RECURSIVE, the mutex will not be unlocked until as many successful calls to op_prg_mt_mutex_unlock() have been made by the thread as the number of successful op_prg_mt_mutex_lock() calls made by that same thread.
Purpose
Provides a way to unlock a specific mutex that had been previously locked by the same thread of code.
Errors
- Recoverable Error: Null mutex pointer
- Recoverable Error: Mutex (
<description>) is not locked by this thread
Reference
- Use the KP op_prg_mt_global_unlock() to unlock the global mutex
- Use the KP op_prg_mt_mutex_lock() to lock a specific mutex