#include <cafe/os.h> void OSFastMutex_Init (OSFastMutex* fastMutex, char* name);
|fastMutex||Pointer to the mutex to initialize.|
|name||Pointer to the fast mutex name, for debugging.|
Initializes the fast mutex that fastMutex specifies. Note that if the fast mutex specified is in use, attempting to initialize it results in a program error.
There are several major differences between a mutex and a fast mutex.
OSSchedulerLock. All mutex acquire and release the
OSSchedulerLockeach time a mutex is used. Fast mutex uses atomic operations first and then, only if there is contention, the
OSSchedulerLockis taken. Because of this, a fast mutex may lock and unlock approximately 3X faster than a mutex.
OSFastMutex_Lockfunction return immediately. Each call to the
OSFastMutex_Unlockfunction must correspond to a call to the
OSFastMutex_Lockfunction. Otherwise, the fast mutex remains locked. This allows one thread to safely nest multiple calls to the
OSFastMutex_Unlockfunctions for the same fast mutex.
OSFastMutex_Initis not thread-safe because it is not safe to call
OSFastMutex_Initon a mutex, if that mutex is in use in another thread. However, it is safe to call
OSFastMutex_Initon a mutex, if that mutex is not currently in use on another thread.
|Multiple threads||This function is not thread-safe.|
2010/04/24 Initial version.