NAME
thread_fork
—
create a new thread inside a
process
SYNOPSIS
#include
<sys/types.h>
#include <sys/proc.h>
int
thread_fork
(struct proc *p1,
void *stack, void *tcb,
pid_t *tidptr, register_t
*retval);
DESCRIPTION
thread_fork
()
creates a new thread out of p1, which should be the
current thread. This function is used to implement the
__tfork(3) system
call.
stack, which must not be
NULL
, will be used as the initial value of the new
thread's stack pointer.
If tcb is not NULL
,
it will be used as the initial address of the new thread's TCB (thread
control block).
If tidptr is not
NULL
, the TID of the new thread will be copied out
there on success. This is guaranteed to be done before the new thread is
started.
On successful completion the TID of the new thread will be stored in *retval.
RETURN VALUES
Upon successful completion of the operation,
thread_fork
() returns 0. Otherwise, the following
error values are returned:
- [
EAGAIN
] - The system limit on the total number of threads would be exceeded.
- [
ENOMEM
] - There is insufficient swap space for the new thread.
- [
EINVAL
] - The stack argument was
NULL
.
SEE ALSO
HISTORY
The thread_fork
() function appeared in
OpenBSD 6.1.