#include <cafe/mp.h>

inline void MPInitSpinLock(MPSpinLock* spinlock);


spinlock MPSpinLock to initialize.

Return Values



MPInitSpinLock initializes a MPSpinLock for usage. After returning, the MPSpinLock is capable of being used by MP Synchronization APIs.

MPSpinLock is an inline SMP spinlock implementation, which has low overhead. This basic spinlock must be used carefully. The intended use is to guard access to shared memory between equal priority threads each running on a different core.

  1. A deadlock condition may occur if a thread that is holding a spinlock is preempted by a higher priority thread on the same core that wants the same spinlock.
  2. Slower performance than expected may occur if a thread that is holding a spinlock is preempted. Other cores must wait until the holding thread resumes and releases the lock.

Important usage notes while holding a spinlock:

OSSpinLock is designed to handle thread priority inversion issues. However, OSSpinLock still busy-waits, if a thread wants to sleep one needs to use an OSMutex.

Do Not Call From

Multiple threads This function is not thread-safe.

See Also


Revision History

2013/05/08 Automated cleanup pass.
2010/08/23 Initial version.