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

# Osal_thread

## Structures

### `ar_osal_thread_attr_t`

Thread attributes.

**Members**

**thread\_name** `char_t *`

Pointer to the thread name.

**stack\_size** `uint32_t`

Size of the thread stack.

**priority** `int32_t`

Thread priority.

## Functions

### `ar_osal_thread_attr_init`

Thread attribute initialization API, client allocates the memory for ar\_osal\_thread.

@datatypes osal\_thread\_attribute\_t

```cpp theme={null}
int32_t ar_osal_thread_attr_init(ar_osal_thread_attr_t *thread_attr)
```

**Parameters**

**thread\_attr** `ar_osal_thread_attr_t *`

Initialize thread object.

**Returns**

0  Success Nonzero  Failure

### `ar_osal_thread_create`

Creates and launches a thread.

@datatypes ar\_osal\_thread\_t

```cpp theme={null}
int32_t ar_osal_thread_create(ar_osal_thread_t *thread, ar_osal_thread_attr_t *attr_ptr, ar_osal_thread_start_routine thread_start, void *thread_param)
```

**Parameters**

**thread** `ar_osal_thread_t *`

Pointer to the thread.

**thread\_attr**

Pointer to the thread attributes.

**thread\_start** `ar_osal_thread_start_routine`

Pointer to the entry function of the thread.

**thread\_param** `void *`

Pointer to the arguments passed to the entry function. An argument can be to any pointer type. @detdesc The thread stack can be passed in as the osal\_thread\_stack argument, or osal\_thread\_stack=NULL indicates that osal allocates the stack internally. If the caller provides the stack, the caller is responsible for freeing the stack memory after joining the thread.

**Returns**

0  Success Nonzero  Failure.

### `ar_osal_thread_get_id`

Get current thread id.

```cpp theme={null}
int64_t ar_osal_thread_get_id(void)
```

**Parameters**

**\[Out]**

thread id: Current thread id.

**Returns**

Thread id.

### `ar_osal_thread_join_destroy`

Waits for a specified thread to exit, and collects the exit status and clear the thread object.

@datatypes ar\_osal\_thread\_t

```cpp theme={null}
int32_t ar_osal_thread_join_destroy(ar_osal_thread_t thread)
```

**Parameters**

**thread** `ar_osal_thread_t`

Thread to wait on.

**Returns**

0  Success. Nonzero  Failure.

### `ar_osal_thread_get_priority`

Queries the thread priority using a thread handle.

@dependencies Before calling this function, the object must be created and initialized. @newpage

```cpp theme={null}
int32_t ar_osal_thread_get_priority(ar_osal_thread_t thread, int32_t *get_priority)
```

**Parameters**

**thread** `ar_osal_thread_t`

Thread handle.

**get\_priority** `int32_t *`

current thread priority

### `ar_osal_thread_set_priority`

Changes the thread priority using a thread handle.

```cpp theme={null}
int32_t ar_osal_thread_set_priority(ar_osal_thread_t thread, int32_t set_priority)
```

**Parameters**

**thread** `ar_osal_thread_t`

Thread handle.

**set\_priority** `int32_t`

New thread priority to set

**Returns**

0  Success. Nonzero  Failure.

### `ar_osal_thread_self_get_priority`

Queries the thread priority within the thread work function.

```cpp theme={null}
int32_t ar_osal_thread_self_get_priority(int32_t *get_priority)
```

**Parameters**

**get\_priority** `int32_t *`

get thread priority

**Returns**

0  Success. Nonzero  Failure.

### `ar_osal_thread_self_set_priority`

Changes the thread priority within the thread work function.

```cpp theme={null}
int32_t ar_osal_thread_self_set_priority(int32_t set_priority)
```

**Parameters**

**set\_priority** `int32_t`

New priority to set

**Returns**

0  Success. Nonzero  Failure.

## Type Definitions

### `ar_osal_thread_t`

Handle to a thread.

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

### `ar_osal_thread_attr_t`

Thread attributes.

```cpp theme={null}
typedef struct ar_osal_thread_attr_t ar_osal_thread_attr_t
```

### `ar_osal_thread_start_routine`

osal thread start function definition.

```cpp theme={null}
typedef void(* ar_osal_thread_start_routine
```
