thrd_create()

Updated: May 06, 2022

Create a thread

Synopsis:

#include <threads.h>

typedef int (*thrd_start_t)(void*);

int thrd_create( thrd_t *thr,
                 thrd_start_t func,
                 void *arg );

Arguments:

thr
NULL, or a pointer to a thrd_t object where the function can store the thread ID of the new thread.
func
The routine where the thread begins, with arg as its only argument. If func() returns, there's an implicit call to thrd_exit(), using the return value of func() as the exit status.

The thread in which main() was invoked behaves differently. When it returns from main(), there's an implicit call to exit(), using the return value of main() as the exit status.

arg
The argument to pass to func.

Library:

libc

Use the -l c option to qcc to link against this library. This library is usually included automatically.

Description:

The thrd_create() function creates a new thread. The created thread inherits the signal mask of the parent thread, and its set of pending signals is empty.

Returns:

thrd_success
Success.
thrd_error
An error occurred.

Classification:

C11

Safety:  
Cancellation point No
Interrupt handler No
Signal handler Yes
Thread Yes