DosCreateSpinLock: Difference between revisions
Appearance
No edit summary |
|||
Line 13: | Line 13: | ||
==Remarks== | ==Remarks== | ||
DosCreateSpinLock, DosAcquireSpinLock, DosReleaseSpinLock and DosFreeSpinLock are the user mode equivalents of the Kernel (DevHlp) Spinlocks. Note that DosAcquireSpinLock will globally disable interrrupts and DosReleaseSpinLock will reenable them. Spinlock calls cannot be nested. Do not call any API Function while you are holding a spinlock. | |||
==Example Code== | ==Example Code== |
Revision as of 09:01, 19 July 2023
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, DosAcquireSpinLock, DosReleaseSpinLock and DosFreeSpinLock are the user mode equivalents of the Kernel (DevHlp) Spinlocks. Note that DosAcquireSpinLock will globally disable interrrupts 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); } };