Share via


NKReleaseOalSpinLock (Compact 2013)

3/28/2014

This function releases an OEM adaptation layer (OAL) spin lock that protects shared resources.

Syntax

void
  NKReleaseOalSpinLock
(void)

Parameters

None.

Return Value

None.

Remarks

In a single-processor environment, resources accessed in an ISR are typically protected by turning interrupts off. This does not work when there is more than one processor, as other processors can be running conflicting function calls at the same time.

Since it is not possible to use a critical section in an ISR context, the only way to protect shared resources is by spin lock. Use this function to protect shared resource in an ISR context, rather than turning interrupts off.

The OAL spin lock has the following limitations:

  • Maximum stack usage is less than 2048 bytes.
  • You cannot use other synchronization objects while you own the spin lock because you cannot block while interrupts are turned off.
  • You cannot issue any debug messages going through the kernel independent transport layer (KITL) or kernel while spin lock is applied.

You can safely replace turning interrupts on or off with OAL spin lock on single-processor systems. However, holding a spinlock prevents threads from being rescheduled. Do not write code that holds a spin lock while running routines that can take indeterminate amounts of time. This could potentially cause all processors to spin and do nothing while waiting for the spin lock to be released.

It is strongly recommended that codes accessing share resources be broken into small non-preemptible chunks and use the OAL spin lock only to guard those small chunks of code.

Requirements

Header

nkglobal.h

Library

Nkstub.lib

See Also

Reference

SMP Functions
NKAcquireOalSpinLock
NKSendInterProcessorInterrupt