DosAcquireSpinLock
Description
Acquire a spinlock for multiprocessor
serialization
Calling Sequence
APIRET DosAcquireSpinLock
(HSPINLOCK Handle)
Parameters
Handle (HSPINLOCK)
- input A handle to a spinlock. This handle was returned on the DosCreateSpinLock
api call.
Returns
ulrc (APIRET)
DosAcquireSpinLock returns one of the following values:
0
6
Remarks
DosAcquireSpinLock is passed
a handle which was returned by DosCreateSpinLock When control is returned
to the requester, the spin lock has been acquired and interrupts are disabled.
A call to DosReleaseSpinLock must follow very shortly. Spin locks can be
nested.
Related Functions
o
o
Example Code
The following code example
shows the use of DosAcquireSpinLock
#define INCL_BASE
#define OS2_API16
#define INCL_DOSSPINLOCK
#include <os2.h>
#include <stdio.h>
#include <string.h>
main()
{
APIRET rc; /* Return code */
HSPINLOCK Handle; /* Handle to spin lock */
PHSPINLOCK pHandle = &Handle; /* pointer to spin lock handle */
/* Create a spin lock */
rc = DosCreateSpinLock(pHandle);
if (rc !=0)
{
printf("DosCreateSpinLock failed -- rc = %1d",rc);
DosExit(0,1);
}
/* Acquire spin lock */
rc = DosAcquireSpinLock(Handle);
if (rc !=0)
{
printf("DosAcquireSpinLock failed -- rc = %1d",rc);
DosExit(0,1);
}
/* Code that needs serialization */
/* Release spin lock */
rc = DosReleaseSpinLock(Handle);
if (rc !=0)
{
printf("DosReleaseSpinLock failed -- rc = %1d",rc);
DosExit(0,1);
}
}
[Back: DosCreateSpinLock]
[Next: DosReleaseSpinLock]