112 lines
4.1 KiB
Groff
112 lines
4.1 KiB
Groff
.\" $NetBSD: kthread.9,v 1.7 2002/03/08 23:03:23 kleink Exp $
|
|
.\"
|
|
.\" Copyright (c) 2000 The NetBSD Foundation, Inc.
|
|
.\" All rights reserved.
|
|
.\"
|
|
.\" This code is derived from software contributed to The NetBSD Foundation
|
|
.\" by Gregory McGarry.
|
|
.\"
|
|
.\" Redistribution and use in source and binary forms, with or without
|
|
.\" modification, are permitted provided that the following conditions
|
|
.\" are met:
|
|
.\" 1. Redistributions of source code must retain the above copyright
|
|
.\" notice, this list of conditions and the following disclaimer.
|
|
.\" 2. Redistributions in binary form must reproduce the above copyright
|
|
.\" notice, this list of conditions and the following disclaimer in the
|
|
.\" documentation and/or other materials provided with the distribution.
|
|
.\" 3. All advertising materials mentioning features or use of this software
|
|
.\" must display the following acknowledgement:
|
|
.\" This product includes software developed by the NetBSD
|
|
.\" Foundation, Inc. and its contributors.
|
|
.\" 4. Neither the name of The NetBSD Foundation nor the names of its
|
|
.\" contributors may be used to endorse or promote products derived
|
|
.\" from this software without specific prior written permission.
|
|
.\"
|
|
.\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
|
|
.\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
|
.\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
|
.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
|
|
.\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
|
.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
|
.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
|
.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
|
.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
|
.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
|
.\" POSSIBILITY OF SUCH DAMAGE.
|
|
.\"
|
|
.Dd July 9, 2000
|
|
.Dt KTHREAD 9
|
|
.Os
|
|
.Sh NAME
|
|
.Nm kthread_create1 ,
|
|
.Nm kthread_exit ,
|
|
.Nm kthread_create
|
|
.Nd kernel threads
|
|
.Sh SYNOPSIS
|
|
.Fd #include \*[Lt]sys/kthread.h\*[Gt]
|
|
.Ft void
|
|
.Fn kthread_create "void (*func)(void *)" "void *arg"
|
|
.Ft void
|
|
.Fn kthread_exit "int ecode"
|
|
.Ft int
|
|
.Fn kthread_create1 "void (*func)(void *)" "void *arg" "struct proc **newpp" \
|
|
"const char *fmt" "..."
|
|
.Sh DESCRIPTION
|
|
Kernel threads are light-weight processes which execute entirely
|
|
within the kernel. Any process can request the creation of a new
|
|
kernel thread. Kernel threads are not swapped out during memory
|
|
congestion. The VM space and limits are shared with proc0 (usually swapper).
|
|
.Sh FUNCTIONS
|
|
.Bl -tag -width compact
|
|
.It Fn kthread_create1 "func" "arg" "newpp" "fmt" "..."
|
|
Fork a kernel thread.
|
|
.Fa newpp
|
|
is a pointer the the new proc structure for the kernel thread.
|
|
The function
|
|
.Fa func
|
|
is called with arguments
|
|
.Fa arg
|
|
to commence execution.
|
|
.Fa fmt
|
|
is a string containing format information used to display the kernel
|
|
thread name.
|
|
.It Fn kthread_create "void (*func)(void)" "void *arg"
|
|
Register function
|
|
.Fa func
|
|
to defer creation of the kernel thread. Deferral of kernel thread
|
|
creation is required during system startup when kernel thread resources
|
|
are not available.
|
|
.It Fn kthread_exit "int ecode"
|
|
Exit from a kernel thread.
|
|
.El
|
|
.Sh RETURN VALUES
|
|
Upon successful completion,
|
|
.Fn kthread_create1
|
|
returns 0. Otherwise, the following error values are returned:
|
|
.Bl -tag -width [EAGAIN]
|
|
.It Bq Er EAGAIN
|
|
The limit on the total number of system processes would be exceeded.
|
|
.It Bq Er EAGAIN
|
|
The limit
|
|
.Dv RLIMIT_NPROC
|
|
on the total number of processes under execution by this
|
|
user id would be exceeded.
|
|
.El
|
|
.Sh CODE REFERENCES
|
|
This section describes places within the
|
|
.Nx
|
|
source tree where actual code implementing or utilising the kthread
|
|
framework can be found. All pathnames are relative to
|
|
.Pa /usr/src .
|
|
.Pp
|
|
The kthread framework itself is implemented within the file
|
|
.Pa sys/kern/kern_kthread.c .
|
|
Data structures and function prototypes for the framework are located in
|
|
.Pa sys/sys/kthread.h .
|
|
.Sh SEE ALSO
|
|
.Xr driver 9 ,
|
|
.Xr fork1 9
|
|
.Sh HISTORY
|
|
The kthread framework appeared in
|
|
.Nx 1.4 .
|