thrd_create Subroutine
Purpose
This subroutine creates a thread.
Library
Standard C Library (libc.a)
Syntax
#include <threads.h>
int thrd_create(thrd_t *thr, thrd_start_t func, void *arg);
Description
The thrd_create subroutine
creates a new thread by running the func(arg) subroutine.
If the thrd_create subroutine succeeds, it sets
the object specified by the
thr
parameter to the
identifier of the newly created thread. Notes:
- A thread’s identifier can be reused for a different thread after the original thread is exited and the thread is detached or joined to another thread.
- The completion of the thrd_create subroutine synchronizes with the starting of the new thread.
Parameters
status
Item | Description |
---|---|
thr |
Holds the identifier of the newly created thread. |
func |
Specifies the subroutine that is used to create a new thread. |
arg |
Specifies the argument to the func() subroutine. |
Return Values
The thrd_create subroutine returns thrd_success on success, thrd_nomem if no memory is allocated for the thread that is requested, or thrd_error if the request is not completed.
Files
Item | Description |
---|---|
threads.h | Standard macros, data types, and subroutines are defined by the threads.h file. |