DosCreateSpinLock
Description
Create a spinlock for multiprocessor
serialization
Calling Sequence
APIRET DosCreateSpinLock
(PHSPINLOCK pHandle)
Parameters
pHandle (PHSPINLOCK)
- output A pointer to the spinlock handle. This handle can be passed to
DosAcquireSpinLock to acquire a spinlock and to DosReleaseSpinLock to release
the spinlock.
Returns
ulrc (APIRET)
DosCreateSpinLock returns the following values:
0
32804
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.
Related Functions
o
o
Example Code
The following code example
shows the use of DosCreateSpinLock:
#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: New OS/2 for SMP V2.11 APIs]
[Next: DosAcquireSpinLock]