Sync with reality.
This commit is contained in:
parent
53d643b5f7
commit
58af9c20d0
|
@ -1,10 +1,10 @@
|
|||
.\" $NetBSD: kthread.9,v 1.14 2005/09/10 22:21:41 wiz Exp $
|
||||
.\" $NetBSD: kthread.9,v 1.15 2007/07/14 11:22:33 ad Exp $
|
||||
.\"
|
||||
.\" Copyright (c) 2000 The NetBSD Foundation, Inc.
|
||||
.\" Copyright (c) 2000, 2007 The NetBSD Foundation, Inc.
|
||||
.\" All rights reserved.
|
||||
.\"
|
||||
.\" This code is derived from software contributed to The NetBSD Foundation
|
||||
.\" by Gregory McGarry.
|
||||
.\" by Gregory McGarry, and by Andrew Doran.
|
||||
.\"
|
||||
.\" Redistribution and use in source and binary forms, with or without
|
||||
.\" modification, are permitted provided that the following conditions
|
||||
|
@ -34,60 +34,95 @@
|
|||
.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
.\" POSSIBILITY OF SUCH DAMAGE.
|
||||
.\"
|
||||
.Dd August 27, 2005
|
||||
.Dd July 14, 2007
|
||||
.Dt KTHREAD 9
|
||||
.Os
|
||||
.Sh NAME
|
||||
.Nm kthread_create1 ,
|
||||
.Nm kthread_exit ,
|
||||
.Nm kthread_create
|
||||
.Nm kthread_create ,
|
||||
.Nm kthread_destroy ,
|
||||
.Nm kthread_exit
|
||||
.Nd kernel threads
|
||||
.Sh SYNOPSIS
|
||||
.In sys/kthread.h
|
||||
.Ft int
|
||||
.Fn kthread_create "pri_t pri" "int flags" "struct cpu_info *ci" \
|
||||
"void (*func)(void *)" "void *arg" "lwp_t **newlp" "const char *fmt" "..."
|
||||
.Ft void
|
||||
.Fn kthread_create "void (*func)(void *)" "void *arg"
|
||||
.Fn kthread_destroy "lwp_t *l"
|
||||
.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.
|
||||
.Pp
|
||||
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).
|
||||
A kernel thread must call
|
||||
.Fn kthread_exit
|
||||
to end execution.
|
||||
.Sh FUNCTIONS
|
||||
.Bl -tag -width compact
|
||||
.It Fn kthread_create1 "void (*func)(void *)" "void *arg" "struct proc **newpp" "const char *fmt" "..."
|
||||
Fork a kernel thread.
|
||||
.Fa newpp
|
||||
is a pointer 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.
|
||||
The function
|
||||
.Fa func
|
||||
must not return.
|
||||
If the kernel thread runs to completion, it must call
|
||||
.It Fn kthread_create "pri" "flags" "ci" "func" "arg" "newlp" "fmt" "..."
|
||||
Create a kernel thread.
|
||||
The arguments are as follows.
|
||||
.Bl -tag -width compact
|
||||
.It Fa pri
|
||||
Priority level for the thread.
|
||||
If no priority level is desired specify
|
||||
.Dv PRI_NONE ,
|
||||
causing
|
||||
.Fn kthread_create
|
||||
to select the default priority level.
|
||||
.It Fa flags
|
||||
Flags that can be logically ORed together to alter the thread's behaviour.
|
||||
.Pp
|
||||
.Dv KTHREAD_IDLE :
|
||||
causes the thread to be created in the
|
||||
.Dv LSIDL
|
||||
(idle) state.
|
||||
By default, the threads are created in the
|
||||
.Dv LSRUN
|
||||
(runnable) state, meaning they will begin execution shortly after creation.
|
||||
.Pp
|
||||
.Dv KTHREAD_MPSAFE :
|
||||
Specifies that the thread does its own locking and so is multiprocessor safe.
|
||||
If not specified, the global kernel lock will be held whenever the thread is
|
||||
running (unless explicitly dropped by the thread).
|
||||
.Pp
|
||||
.Dv KTHREAD_INTR :
|
||||
Specifies that the thread services device interrupts.
|
||||
This flag is intended for kernel internal use and should not normally be
|
||||
specified.
|
||||
.It Fa ci
|
||||
If non-NULL, the thread will be created bound to the CPU specified
|
||||
by
|
||||
.Fa ci ,
|
||||
meaning that it will only ever execute on that CPU.
|
||||
By default, the threads are free to execute on any CPU in the system.
|
||||
.It Fa func
|
||||
A function to be called when the thread begins executing.
|
||||
This function must not return.
|
||||
If the thread runs to completion, it must call
|
||||
.Fn kthread_exit
|
||||
to properly terminate itself.
|
||||
.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"
|
||||
.It Fa arg
|
||||
An argument to be passed to
|
||||
.Fn func .
|
||||
May be NULL if not required.
|
||||
.It Fa newpl
|
||||
A pointer to receive the new lwp structure for the kernel thread.
|
||||
May be NULL if not required.
|
||||
.It Fa fmt
|
||||
A string containing format information used to display the kernel
|
||||
thread name.
|
||||
Must not be NULL.
|
||||
.El
|
||||
.It Fn kthread_destroy "l"
|
||||
From another thread executing in the kernel, cause a kthread to exit.
|
||||
The kthread must be in the
|
||||
.Dv LSIDL
|
||||
(idle) state.
|
||||
.It Fn kthread_exit "ecode"
|
||||
Exit from a kernel thread.
|
||||
Must only be called by a kernel thread.
|
||||
.El
|
||||
.Sh RETURN VALUES
|
||||
Upon successful completion,
|
||||
|
@ -116,8 +151,7 @@ The kthread framework itself is implemented within the file
|
|||
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
|
||||
.Xr driver 9
|
||||
.Sh HISTORY
|
||||
The kthread framework appeared in
|
||||
.Nx 1.4 .
|
||||
|
|
Loading…
Reference in New Issue