OS_UnlockMutex

Syntax

#include <nitro/os.h>

void OS_UnlockMutex( OSMutex* mutex );

Arguments

mutex Pointer to the OSMutex structure

Return Values

None.

Description

The thread calling this function releases mutex.
The thread that calls this function must be the owner of mutex.

However, when the calling thread has locked mutex n times, the mutex will be released only by the nth call to the OS_UnlockMutex function.

Example

OSMutex mutex;

OS_LockMutex( &mutex );
:
OS_LockMutex( &mutex );
:
:
:
OS_UnlockMutex( &mutex ); // The mutex has not yet been unlocked.
:
OS_UnlockMutex( &mutex ); // The mutex is unlocked here.

When the thread that is locking mutex is terminated with the OS_ExitThread function, mutex is automatically unlocked.

See Also

OS_InitMutex
OS_LockMutex
OS_TryLockMutex
OS_ExitThread

Revision History

2009/03/11 Fixed a location that incorrectly used OS_LockMutex instead of OS_UnlockMutex.
2008/12/17 Added an example.
2004/04/05 Noted that the OS_ExitThread function unlocks mutexes.
2003/12/01 Initial version.


CONFIDENTIAL