op_prg_mt_mutex_unlock()

摘要

解锁指定的互斥锁。

语法

op_prg_mt_mutex_unlock (mutex_ptr)
参数 类型 说明
mutex_ptr PrgT_Mutex 待解锁的互斥锁。

返回类型

Compcode

若互斥锁解锁成功,返回 OPC_COMPCODE_SUCCESS;否则返回 OPC_COMPCODE_FAILURE。

示例

/* 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);
		}
	}

详情

当某段代码的线程成功锁定互斥锁后,在其他线程解锁该互斥锁之前,所有其他线程都无法锁定它。

试图解锁自己此前并未锁定的互斥锁的线程,不会影响该互斥锁的状态。

如果互斥锁创建时使用了 OPC_MT_MUTEX_RECURSIVE 选项,则只有当该线程调用 op_prg_mt_mutex_unlock() 成功次数与它调用 op_prg_mt_mutex_lock() 的成功次数相等时,互斥锁才会真正解锁。

用途

提供了一种解锁特定互斥锁的方法,该互斥锁此前已被同一段代码的线程锁定。

错误

  • 可恢复错误:互斥锁指针为空
  • 可恢复错误:互斥锁(<description>)未被该线程锁定

参考

本站文档由 北京智网畅联科技有限公司 整理、翻译并提供 · Documentation compiled and provided by Beijing ZNetLink Technology Co., Ltd.

交流群 · QQ Group:OPNET/智网妙算网络仿真交流群(群号 486383494)

原文档 © 2017 Riverbed Technology · 本站为公益翻译,由 AI 辅助完成,请仔细甄别

Original documentation © 2017 Riverbed Technology. Community translation, AI-assisted. Contact: jiazequn@znetlink.com