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)。