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.
Header
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.