---
name: "iv_thread"
section: "3"
platform: "linux"
package: "libivykis-dev"
version: "0.43.2-1+b1"
release: "Debian 13 (Trixie)"
platforms: ["linux"]
url: "https://new.carta.tech/iv_thread"
---

# iv\_thread(3)

ivykis thread convenience functions

## NAME

iv\_thread\_create, iv\_thread\_set\_debug\_state - ivykis thread convenience functions

## SYNOPSIS

**#include \<iv\_thread.h\>**

**int iv\_thread\_create(const char \****name***, void (\****start\_routine***)(void \*), void \****arg***);**\
 **void iv\_thread\_set\_debug\_state(int** *state***);**\

## DESCRIPTION

**iv\_thread\_create** is a wrapper around [**pthread\_create**(3)](/pthread_create/3.md) which will maintain an ivykis main loop reference in the calling thread (which must be an [**ivykis**(3)](/ivykis/3.md) thread, i.e. have had [**iv\_init**(3)](/iv_init/3.md) called in it) for as long as the created thread is alive.

Maintaining a reference on the calling thread's ivykis event loop makes sure that the calling thread will not return from its ivykis main loop before the created thread exits, as that could cause cleanup still happening in the created thread to be interrupted when the calling thread subsequently calls [**exit**(3)](/exit/3.md).

The created thread need not be an ivykis thread.

Enabling debugging by calling **iv\_thread\_set\_debug** with a nonzero argument will print a debug message to standard error whenever a thread is created via **iv\_thread\_create,** whenever a thread so created terminates, and whenever destruction of such a thread is signaled back to the calling thread.

For inter-thread signaling, **iv\_thread** uses [**iv\_event**(3)](/iv_event/3.md).

## SEE ALSO

[**ivykis**(3)](/ivykis/3.md), [**iv\_event**(3)](/iv_event/3.md), [**exit**(3)](/exit/3.md), [**pthread\_create**(3)](/pthread_create/3.md)
