THRD_CREATE(3C) Standard C Library Functions THRD_CREATE(3C)

NAME


thrd_create - create a thread

SYNOPSIS


#include <threads.h>

typedef int (*thrd_start_t)(void *);

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

DESCRIPTION


The thrd_create() function creates a new thread of execution inside of
the current process and stores its identifier in thrdp. Each thread
operates concurrently within the process.

When a thread is created, it begins its execution at the function func
with the argument arg. A created thread has access to all global data
within a process; however, it has its own private stack. Currently
32-bit processes have a default stack of 1 megabyte, while 64-bit
systems have a default stack size of 2 megabytes. In addition, newly
created threads inherit the signal mask of the thread which created
them; however, they do not inherit any pending signals.

Once created, a thread will continue to execute until either, it
returns from its initial function, the thread explicitly calls
thrd_exit(3C), or the process itself terminates, such as with a call to
exit(2). When the initial function returns, it behaves as though a
call to thrd_exit(3C) was made, and, if the thread has not been
detached with a call to thrd_detach(3C), the exit status remains
available and the corresponding thread ID will not be reused until a
process calls thrd_join(3C). This is similar to how a parent must call
wait(3C), to clean up a child process that has terminated.

For a richer interface interface with more control over aspects of the
newly created thread, such as stack size, stack placement, and the
like, see thr_create(3C) and pthread_create(3C).

RETURN VALUES


Upon successful completion, the thrd_create() function returns
thrd_success. If insufficient memory was available, then thrd_nomem is
returned. Otherwise, thrd_error is returned, indicating that a non-
memory related error.

INTERFACE STABILITY


Standard

MT-LEVEL
MT-Safe

SEE ALSO


pthread_create(3C), thr_create(3C), thrd_detach(3C), thrd_join(3C),
attributes(7), threads(7)

illumos January 13, 2015 illumos

tribblix@gmail.com :: GitHub :: Privacy