prg_mt_spinlock_acquire()

Abstract

Acquires a spinlock.

Syntax

prg_mt_spinlock_acquire (lock_ptr)
Argument Type Description
lock_ptr PrgT_Mt_Spinlock * Spinlock to acquire.

Return Type

void

No return value.

prg_mt.h

Example

#if defined (OPD_PARALLEL)
   static PrgT_Mt_Spinlock    module_lock;
   module_lock = PRGC_MT_SPINLOCK_INIT;
#endif

. . .

prg_mt_spinlock_acquire (&module_lock);

/* Protected code */

prg_mt_spinlock_release (&module_lock);

Details

Before acquiring a spinlock, you must initialize it as in the example.

OPD_PARALLEL is defined when a simulation is being compiled for a parallel environment. In the example, this macro is used to initialize the spinlock only when needed.

prg_mt_spinlock_acquire() compiles as a no-op in sequential code.

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