# OS_LockMutexFrom[RToW|WToR]

## Syntax

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

## Arguments

`mutex` | Pointer to the `OSMutex` structure

## Return Values

None.

## Description

Changes the type of the `mutex` that is locked.

`mutex` is the pointer to the `OSMutex` structure to be changed.

The `OS_LockMutexFromWToR` function takes a `mutex` that is set to `write lock` and changes the setting to `read lock`. The `mutex` type is then `read lock`. To unlock it you need to execute either the `OS_UnlockMutexR` or `OS_UnlockMutexRW` function.

The `OS_LockMutexFromRToW` takes a `mutex` that is set to `read lock` and changes the setting to `write lock`. The `mutex` type is then `write lock`. To unlock it you need to execute either the `OS_UnlockMutexW` or `OS_UnlockMutexRW` function.

Control will not return from either of these functions until the change has succeeded. Internally, the `OS_TryLockMutexFromWToR` and `OS_TryLockMutexFromRToW` functions will be called repeatedly until the process succeeds. The process will stop, however, if the function has been specified in a way that cannot succeed. For example, if the `OS_LockMutexFromToWToR` function is called to change the mutex from `write lock` to `read lock` but the mutex is already set to `read lock`. (The thread goes to sleep.)

## See Also

`OS_InitMutex
OS_LockMutex
OS_UnlockMutex`
`OS_LockMutexR
OS_LockMutexW
OS_UnlocMutexR
OS_UnlocMutexW
OS_TryLockMutexR
OS_TryLockMutexW
OS_TryLockMutexFromRToW
OS_TryLockMutexFromWToR`

## Revision History

2008/12/17 Initial version.

CONFIDENTIAL