> ## 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.

# Osal_thread

## Structures

### `ar_osal_thread_attr_t`

Thread attributes.

**Members**

<ParamField path="thread_name" type="char_t *">
  Pointer to the thread name.
</ParamField>

<ParamField path="stack_size" type="uint32_t">
  Size of the thread stack.
</ParamField>

<ParamField path="priority" type="int32_t">
  Thread priority.
</ParamField>

## 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**

<ParamField path="thread_attr" type="ar_osal_thread_attr_t *">
  Initialize thread object.
</ParamField>

**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**

<ParamField path="thread" type="ar_osal_thread_t *">
  Pointer to the thread.
</ParamField>

<ParamField path="thread_attr" type="">
  Pointer to the thread attributes.
</ParamField>

<ParamField path="thread_start" type="ar_osal_thread_start_routine">
  Pointer to the entry function of the thread.
</ParamField>

<ParamField path="thread_param" type="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.
</ParamField>

**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**

<ParamField path="[Out]" type="">
  thread id: Current thread id.
</ParamField>

**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**

<ParamField path="thread" type="ar_osal_thread_t">
  Thread to wait on.
</ParamField>

**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**

<ParamField path="thread" type="ar_osal_thread_t">
  Thread handle.
</ParamField>

<ParamField path="get_priority" type="int32_t *">
  current thread priority
</ParamField>

### `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**

<ParamField path="thread" type="ar_osal_thread_t">
  Thread handle.
</ParamField>

<ParamField path="set_priority" type="int32_t">
  New thread priority to set
</ParamField>

**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**

<ParamField path="get_priority" type="int32_t *">
  get thread priority
</ParamField>

**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**

<ParamField path="set_priority" type="int32_t">
  New priority to set
</ParamField>

**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
```
