op_prg_mt_mutex_destroy()
Abstract
Destroys a mutex.
Syntax
op_prg_mt_mutex_destroy (mutex_ptr)
| Argument | Type | Description |
|---|---|---|
mutex_ptr |
PrgT_Mutex * |
Mutex to be destroyed. |
Return Type
Compcode
OPC_COMPCODE_SUCCESS if the mutex is destroyed; OPC_COMPCODE_FAILURE if the mutex pointer is null or the mutex is locked.
Example
/* Create the mutex that will be used to serialize calling of prg_mapping */
/* functions, which read/write global model related mapping information, */
/* under multithreaded execution with multiple CPUs. */
mapping_info_mutex = op_prg_mt_mutex_create (OPC_MT_MUTEX_READER_WRITER, 0,
"WLAN Mapping Info Mutex");
. . .
/* Mutex for prg_mapping functions no longer needed. */
op_prg_mt_mutex_destroy (mapping_info_mutex);
Details
A mutex should be destroyed when it is no longer needed to serialize access to data. A mutex must be unlocked before it can be destroyed. If you try to destroy an locked mutex, the operation will fail and a recoverable error will be generated.
Purpose
Provides a way to destroy an unneeded mutex and free the associated memory.
Errors
- Recoverable Error: Null mutex pointer
- Recoverable Error: Mutex (
<description>) is currently locked by Objid (<lock_objid>)
Reference
- Use the KP op_prg_mt_mutex_create() to create a mutex