epicsSpin.h

OS independent interface for creating spin locks.

OS independent interface for creating spin locks. Implemented using the OS-specific spinlock interface if available. Otherwise uses epicsMutexLock.

Typedefs

typedef struct epicsSpin *epicsSpinId

Handle to spin lock

Functions

epicsSpinId epicsSpinCreate(void)

Creates a spin lock.

Creates a spin lock

Returns:

Handle to spinlock or NULL if failed to create the lock

epicsSpinId epicsSpinMustCreate(void)

Creates a spin lock.

Creates a spin lock. Calls cantProceed() if unable to create lock

void epicsSpinDestroy(epicsSpinId lockId)

Destroys spin lock.

Destroys the spin lock

Parameters:

lockId – identifies the spinlock

void epicsSpinLock(epicsSpinId lockId)

Acquires the spin lock.

Acquires the lock. Blocks if lock is unavailable

Parameters:

lockId – identifies the spinlock

int epicsSpinTryLock(epicsSpinId lockId)

Tries to acquire the spin lock

Tries to acquire the lock. If failed, return immediately with non-zero error code.

Parameters:

lockId – identifies the spinlock

Returns:

0 if lock was acquired. 1 if failed because acquired by another thread. Otherwise returns non-zero OS specific return code if failed for any other reason

void epicsSpinUnlock(epicsSpinId lockId)

Releases spin lock.

Releases spin lock

Parameters:

lockId – identifies the spinlock