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 only be released by the nth call to the OS_LockMutex function.

Example

OSMutex mutex;

OS_LockMutex( &mutex );
:
OS_LockMutex( &mutex );
:
:
:
OS_UnlockMutex( &mutex ); // mutex not released yet
:
OS_UnlockMutex( &mutex ); // mutex is released

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

2008/12/17 Added example.
2004/04/05 Added mention that mutex is unlocked by the OS_ExitThread function.
2003/12/01 Initial version.


CONFIDENTIAL