op_prg_mt_global_lock()
Abstract
Locks the global mutex.
Syntax
op_prg_mt_global_lock ()
| Argument | Type | Description |
|---|---|---|
| no arguments |
Return Type
Compcode
OPC_COMPCODE_SUCCESS if the global mutex could be locked; OPC_COMPCODE_FAILURE otherwise.
Example
/* Unless it is already done, initialize the receiver */
/* channel's state information. */
if (op_ima_obj_state_get (rx_obid) == OPC_NIL)
{
/* Channel state information doesn't exist. Lock */
/* the global mutex before continuing. */
op_prg_mt_global_lock ();
/* Check again, because another thread may have */
/* already set up the state information. */
if (op_ima_obj_state_get (rx_obid) == OPC_NIL)
{
/* Create and set the initial state information */
/* for the receiver channel. */
rxch_state_ptr = (DraT_Rxch_State_Info *)
op_prg_mem_alloc (sizeof (DraT_Rxch_State_Info));
rxch_state_ptr->signal_lock = OPC_FALSE;
op_ima_obj_state_set (rx_obid, rxch_state_ptr);
}
/* Unlock the global mutex. */
op_prg_mt_global_unlock ();
}
Details
None.
Purpose
Provides a way to lock the global mutex. The global mutex is a built-in mutex with the highest possible rank that can be used by model code when it is undesirable or impossible to create a unique mutex.
Errors
- Recoverable Error: Null mutex pointer
- Recoverable Error: Mutex (
prg_global_mutex): locking flagsOPC_MT_MUTEX_LOCK_READERandOPC_MT_MUTEX_LOCK_WRITERare mutually exclusive - Recoverable Error: Mutex (
prg_global_mutex) is already locked by that thread for Objid (<lock_objid>) - Recoverable Error: Mutex (
prg_global_mutex) 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_unlock() to unlock the global mutex
- Use the KP op_prg_mt_mutex_lock() to lock a specific mutex