op_prg_mt_mutex_destroy()
摘要
销毁一个互斥锁。
语法
op_prg_mt_mutex_destroy (mutex_ptr)
| 参数 | 类型 | 说明 |
|---|---|---|
mutex_ptr |
PrgT_Mutex * |
待销毁的互斥锁。 |
返回类型
Compcode
若互斥锁被销毁,返回 OPC_COMPCODE_SUCCESS;若互斥锁指针为空或互斥锁处于锁定状态,返回 OPC_COMPCODE_FAILURE。
示例
/* 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);
详情
当互斥锁不再需要用于串行化数据访问时,应当将其销毁。互斥锁必须先解锁才能销毁。若试图销毁一个已锁定的互斥锁,该操作将失败并产生可恢复错误。
用途
提供了一种销毁不再需要的互斥锁并释放相关内存的方法。
错误
- 可恢复错误:互斥锁指针为空
- 可恢复错误:互斥锁(
<description>)当前正被 Objid(<lock_objid>)锁定
参考
- 使用内核过程 op_prg_mt_mutex_create() 创建互斥锁