op_prg_mt_mutex_lock()

Abstract

Locks a previously created mutex.

Syntax

op_prg_mt_mutex_lock (mutex_ptr, option)
Argument Type Description
mutex_ptr PrgT_Mutex * Mutex to be locked.
option int Locking mode for mutex. Must be one of the symbolic constants listed in the Details section (see also Table 63 “Mutex Lock Options Symbolic Constants“ on page 17).

Return Type

Compcode

OPC_COMPCODE_SUCCESS if the mutex could be locked; 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

option must be one of the following symbolic constants:

  • OPC_MT_MUTEX_LOCK_READER—Lock reader/writer mutex in reader mode (shared)
  • OPC_MT_MUTEX_LOCK_WRITER—Lock reader/writer mutex in writer mode (exclusive)

This operation fails if:

  • The mutex was created with the rank argument and a a higher-numbered mutex has already been locked by the same thread.
  • The mutex was created without the OPC_MT_MUTEX_RECURSIVE option and the thread has already locked the mutex.

See the Details section of op_prg_mt_mutex_create() for more information.

Purpose

Provides a way to lock a specific mutex, thus preventing other threads of code from acquiring the mutex.

Errors

  • Recoverable Error: Null mutex pointer
  • Recoverable Error: Mutex (<description>): locking flags OPC_MT_MUTEX_LOCK_READER and OPC_MT_MUTEX_LOCK_WRITER are mutually exclusive
  • Recoverable Error: Mutex (<description>) is already locked by that thread for Objid (<lock_objid>)
  • Recoverable Error: Mutex (<description>) of rank <rank> can't be locked after mutex (<locked_mutex_description>) of rank <locked_mutex_rank>

Reference

本站文档由 北京智网畅联科技有限公司 整理、翻译并提供 · 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