prg_mt_spinlock_acquire()

摘要

获取一个自旋锁。

语法

prg_mt_spinlock_acquire (lock_ptr)
参数 类型 说明
lock_ptr PrgT_Mt_Spinlock * 要获取的自旋锁。

返回类型

void

无返回值。

头文件

prg_mt.h

示例

#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);

详情

在获取自旋锁之前,必须像示例中那样先对其进行初始化。

当仿真为并行环境编译时会定义 OPD_PARALLEL。在示例中,这个宏用于仅在需要时初始化自旋锁。

prg_mt_spinlock_acquire() 在顺序代码中编译为空操作(no-op)。

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