DosCreateSpinLock
Appearance
Create a spinlock for multiprocessor serialisation.
Syntax
APIRET APIENTRY DosCreateSpinLock (PHSPINLOCK pHandle)
Parameters
- phandle (PHSPINLOCK)
- A pointer to the spinlock handle that can be passed to DosAcquireSpinLock to acquire a spinlock and to DosReleaseSpinLock to release the spinlock.
Returns
- ulrc (APIRET)
- 0 NO_ERROR
- 32804 ERROR_NO_MORE_HANDLES
Remarks
DosCreateSpinLock returns a handle to a spin lock that is allocated in kernel data space. The handle is to be used on subsequent spin lock function calls and DevHlps. Note that DosAcquireSpinLock will globally disable interrupts and DosReleaseSpinLock will reenable them. Spinlock calls cannot be nested. Do not call any API Function while you are holding a spinlock.
Example Code
// OS/2 adv srv 4 SMP spinlock extern "C" { typedef ULONG HSPINLOCK; typedef HSPINLOCK FAR *PHSPINLOCK; APIRET APIENTRY DosCreateSpinLock(PHSPINLOCK pHandle); VOID APIENTRY DosAcquireSpinLock(HSPINLOCK Handle); VOID APIENTRY DosReleaseSpinLock(HSPINLOCK Handle); APIRET APIENTRY DosFreeSpinLock(HSPINLOCK Handle); }; class SpinLock { HSPINLOCK sl; public: SpinLock() { DosCreateSpinLock(&sl); } ~SpinLock() { DosFreeSpinLock(sl); } void Request() { DosAcquireSpinLock(sl); } void Release() { DosReleaseSpinLock(sl); } };