# OS_LockMutex

## Syntax

  `#include <nitro/os.h>`
  `void OS_LockMutex( OSMutex* mutex );`

## Arguments

mutex | Pointer to the `OSMutex` structure

## Return Values

None.

## Description

The calling thread tries to lock the mutex specified by `mutex`.

When `mutex` is being maintained by another thread, the calling thread is temporarily stopped until `mutex` is released. If `mutex` is being maintained in the current thread, it returns immediately. However, the number of times the `OS_LockMutex` function is called is recorded, and `mutex` must be unlocked the same number of times to actually release it.

When the thread that is locking `mutex` is ended by the `OS_ExitThread` function, that mutex is automatically unlocked.

## See Also

`OS_InitMutex`
`OS_UnlockMutex`
`OS_TryLockMutex`
`OS_ExitThread`

## Revision History

2004/04/05 Added that the `OS_ExitThread` function will unlock mutexes.
2003/12/01 Initial version.

CONFIDENTIAL