> ## Documentation Index
> Fetch the complete documentation index at: https://dragonwingdocs-staging.qualcomm.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Mutex

## Functions

### `ar_osal_mutex_init`

Initializes a mutex.

Memory for mutex object is created by client and this API is used to initialize the mutex. Recursive mutexes are always used.

@datatypes ar\_osal\_mutex\_t

```cpp theme={null}
int32_t ar_osal_mutex_init(ar_osal_mutex_t mutex)
```

**Parameters**

<ParamField path="mutex" type="ar_osal_mutex_t">
  Pointer to the mutex object handle.
</ParamField>

**Returns**

0  Success Nonzero  Failure

### `ar_osal_mutex_deinit`

De-initializes a mutex.

Mutex memory was provided by client and this API is used to de-initialize the mutex before freeing the object.

@datatypes ar\_osal\_mutex\_t

```cpp theme={null}
int32_t ar_osal_mutex_deinit(ar_osal_mutex_t mutex)
```

**Parameters**

<ParamField path="mutex" type="ar_osal_mutex_t">
  Pointer to the mutex object handle.
</ParamField>

**Returns**

0  Success Nonzero  Failure

### `ar_osal_mutex_get_size`

Get size of mutex object.

This API is used to get the mutex object size for client to allocate memory for the mutex object.

@datatypes ar\_osal\_mutex\_t

```cpp theme={null}
size_t ar_osal_mutex_get_size(void)
```

**Returns**

Size of mutex object

### `ar_osal_mutex_create`

Creates and initialize a mutex.

Recursive mutex are always used. Mutex memory allocation and initialization done by this API osal\_mutex\_create() or osal\_mutex\_init() would be used, but not both.

@datatypes ar\_osal\_mutex\_t

```cpp theme={null}
int32_t ar_osal_mutex_create(ar_osal_mutex_t *mutex)
```

**Parameters**

<ParamField path="[Out]" type="">
  mutex: Pointer to the mutex object handle.
</ParamField>

**Returns**

0  Success Nonzero  Failure

### `ar_osal_mutex_destroy`

Delete/free a mutex object.

This function must be called for each corresponding osal\_mutex\_create function to clean up all resources.

@datatypes ar\_osal\_mutex\_t

```cpp theme={null}
int32_t ar_osal_mutex_destroy(ar_osal_mutex_t mutex)
```

**Parameters**

<ParamField path="mutex" type="ar_osal_mutex_t">
  Pointer to the mutex.
</ParamField>

**Returns**

0  Success Nonzero  Failure

### `ar_osal_mutex_lock`

Locks a mutex.

Recursive mutex are always used.

@datatypes ar\_osal\_mutex\_t

```cpp theme={null}
int32_t ar_osal_mutex_lock(ar_osal_mutex_t mutex)
```

**Parameters**

<ParamField path="mutex" type="ar_osal_mutex_t">
  Pointer to the mutex.
</ParamField>

**Returns**

0  Success Nonzero  Failure

### `ar_osal_mutex_try_lock`

Attempts to lock a mutex.

If the mutex is already locked and unavailable, a failure is returned.

@datatypes ar\_osal\_mutex\_t

```cpp theme={null}
int32_t ar_osal_mutex_try_lock(ar_osal_mutex_t mutex)
```

**Parameters**

<ParamField path="mutex" type="ar_osal_mutex_t">
  Pointer to the mutex.
</ParamField>

**Returns**

0  Success Nonzero  Failure

### `ar_osal_mutex_unlock`

Unlocks a mutex.

Recursive mutex are always used.

@datatypes ar\_osal\_mutex\_t

```cpp theme={null}
int32_t ar_osal_mutex_unlock(ar_osal_mutex_t mutex)
```

**Parameters**

<ParamField path="mutex" type="ar_osal_mutex_t">
  Pointer to the mutex.
</ParamField>

**Returns**

0  Success Nonzero  Failure

## Type Definitions

### `ar_osal_mutex_t`

ar osal mutex type object.

```cpp theme={null}
typedef void * ar_osal_mutex_t
```
