103 lines
2.2 KiB
Plaintext
103 lines
2.2 KiB
Plaintext
'\"macro stdmacro
|
|
.\"
|
|
.\" ----------------
|
|
.TH pthread_create 3P
|
|
.\"
|
|
.\" ----------------
|
|
.SH NAME
|
|
pthread_create \- create and start a thread
|
|
.\"
|
|
.\" ----------------
|
|
.Op c p a
|
|
.SH C SYNOPSIS
|
|
.nf
|
|
.ft 3
|
|
#include <pthread.h>
|
|
.HP
|
|
.ft 3
|
|
int pthread_create(pthread_t \(**thread, pthread_attr_t \(**attr,
|
|
.br
|
|
void \(**(\(**start)(void \(**), void \(**arg);
|
|
.ft 1
|
|
.fi
|
|
.Op
|
|
.\"
|
|
.\" ----------------
|
|
.SH DESCRIPTION
|
|
The
|
|
.IR pthread_create ()
|
|
function creates a thread with the attributes specified by
|
|
.IR attr ,
|
|
starting execution at the function named
|
|
.I start
|
|
with the argument value
|
|
.IR arg .
|
|
A null value of
|
|
.IR attr
|
|
causes the thread to be created with default attributes.
|
|
The thread identity is saved in the location pointed to by the
|
|
.I thread
|
|
argument.
|
|
.\"
|
|
.PP
|
|
A new thread inherits its per-thread signal mask from its creator.
|
|
No signals are pending on the thread when it starts.
|
|
The thread runs until it returns from its
|
|
.IR start
|
|
function, calls
|
|
.IR pthread_exit (),
|
|
or acts on a cancellation request.
|
|
The exception is the initial thread which will cause the process
|
|
to exit if it returns from
|
|
.IR main ().
|
|
When the process terminates so do all its threads.
|
|
.\"
|
|
.PP
|
|
For an overview of POSIX threads see
|
|
.IR pthreads (5).
|
|
.\"
|
|
.\" ----------------
|
|
.SH DIAGNOSTICS
|
|
On success,
|
|
.IR pthread_create ()
|
|
returns zero; otherwise an error number is returned:
|
|
.\"
|
|
.TP 15
|
|
.B [EAGAIN]
|
|
The maximum number of threads has been created [see
|
|
.BR NOTES ,
|
|
and
|
|
.IR setrlimit ()]
|
|
or there is insufficient memory to create the thread.
|
|
.TP
|
|
.B [EPERM]
|
|
The calling process lacks sufficient privilege to create a thread
|
|
with these attributes [see
|
|
.IR pthread_attr_setscope ()].
|
|
.\"
|
|
.\" ----------------
|
|
.SH NOTES
|
|
A thread application can find the thread limit using the
|
|
.IR sysconf ()
|
|
function with the
|
|
.B _SC_THREAD_THREADS_MAX
|
|
option.
|
|
.\"
|
|
.\" ----------------
|
|
.SH CAVEATS
|
|
The POSIX thread model is incompatible with the
|
|
\f4sproc\f1(2) model of threading.
|
|
Attempts to create an sproc process from a pthreaded program
|
|
will be rejected.
|
|
For other limitations with the POSIX thread model see
|
|
\f4pthreads\f1(5).
|
|
.\"
|
|
.\" ----------------
|
|
.SH "SEE ALSO"
|
|
pthread_attr_init(3P),
|
|
pthread_attr_setscope(3P),
|
|
pthread_exit(3P),
|
|
pthreads(5),
|
|
setrlimit(2),
|
|
sysconf(3C).
|