Document the kproc_kthread_add() call
and fix a small detail of its implementation. MFC after: 1 week
This commit is contained in:
parent
a8f7b90ca0
commit
c59b9a7659
@ -57,6 +57,12 @@
|
|||||||
.Fn kproc_suspend "struct proc *p" "int timo"
|
.Fn kproc_suspend "struct proc *p" "int timo"
|
||||||
.Ft void
|
.Ft void
|
||||||
.Fn kproc_suspend_check "struct proc *p"
|
.Fn kproc_suspend_check "struct proc *p"
|
||||||
|
.Ft int
|
||||||
|
.Fo kproc_kthread_add
|
||||||
|
.Fa "void (*func)(void *)" "void *arg"
|
||||||
|
.Fa "struct proc **procptr" "struct thread **tdptr"
|
||||||
|
.Fa "int flags" "int pages" "char * procname" "const char *fmt" "..."
|
||||||
|
.Fc
|
||||||
.Sh DESCRIPTION
|
.Sh DESCRIPTION
|
||||||
The function
|
The function
|
||||||
.Fn kproc_start
|
.Fn kproc_start
|
||||||
@ -196,6 +202,58 @@ need to be suspended voluntarily during system shutdown so as not to interfere
|
|||||||
with system shutdown activities.
|
with system shutdown activities.
|
||||||
The actual suspension of the kernel process is done with
|
The actual suspension of the kernel process is done with
|
||||||
.Fn kproc_suspend .
|
.Fn kproc_suspend .
|
||||||
|
.Pp
|
||||||
|
The
|
||||||
|
.Fn kproc_kthread_add
|
||||||
|
function is much like the
|
||||||
|
.Fn kproc_create
|
||||||
|
function above except that if the kproc already exists,
|
||||||
|
then only a new thread (see
|
||||||
|
.Xr kthread 9 )
|
||||||
|
is created on the existing process.
|
||||||
|
The
|
||||||
|
.Fa func
|
||||||
|
argument specifies the function that the process should execute.
|
||||||
|
The
|
||||||
|
.Fa arg
|
||||||
|
argument is an arbitrary pointer that is passed in as the only argument to
|
||||||
|
.Fa func
|
||||||
|
when it is called by the new process.
|
||||||
|
The
|
||||||
|
.Fa procptr
|
||||||
|
pointer points to a
|
||||||
|
.Vt "struct proc "
|
||||||
|
pointer that is the location to be updated with the new proc pointer
|
||||||
|
if a new process is created, or if not
|
||||||
|
.Dv NULL ,
|
||||||
|
must contain the process pointer for the already exisiting process.
|
||||||
|
If this argument points to
|
||||||
|
.Dv NULL ,
|
||||||
|
then a new process is created and the field updated.
|
||||||
|
If not NULL, the
|
||||||
|
.Fa tdptr
|
||||||
|
pointer points to a
|
||||||
|
.Vt "struct thread "
|
||||||
|
pointer that is the location to be updated with the new thread pointer.
|
||||||
|
The
|
||||||
|
.Fa flags
|
||||||
|
argument specifies a set of flags as described in
|
||||||
|
.Xr rfork 2 .
|
||||||
|
The
|
||||||
|
.Fa pages
|
||||||
|
argument specifies the size of the new kernel thread's stack in pages.
|
||||||
|
If 0 is used, the default kernel stack size is allocated.
|
||||||
|
The procname argument is the name the new process should be given if it needs to be created.
|
||||||
|
It is
|
||||||
|
.Em NOT
|
||||||
|
a printf style format specifier but a simple string.
|
||||||
|
The rest of the arguments form a
|
||||||
|
.Xr printf 9
|
||||||
|
argument list that is used to build the name of the new thread and is stored
|
||||||
|
in the
|
||||||
|
.Va td_name
|
||||||
|
member of the new thread's
|
||||||
|
.Vt "struct thread" .
|
||||||
.Sh RETURN VALUES
|
.Sh RETURN VALUES
|
||||||
The
|
The
|
||||||
.Fn kproc_create ,
|
.Fn kproc_create ,
|
||||||
|
@ -57,6 +57,12 @@
|
|||||||
.Fn kthread_suspend "struct thread *td" "int timo"
|
.Fn kthread_suspend "struct thread *td" "int timo"
|
||||||
.Ft void
|
.Ft void
|
||||||
.Fn kthread_suspend_check "struct thread *td"
|
.Fn kthread_suspend_check "struct thread *td"
|
||||||
|
.Ft int
|
||||||
|
.Fo kproc_kthread_add
|
||||||
|
.Fa "void (*func)(void *)" "void *arg"
|
||||||
|
.Fa "struct proc **procptr" "struct thread **tdptr"
|
||||||
|
.Fa "int flags" "int pages" "char * procname" "const char *fmt" "..."
|
||||||
|
.Fc
|
||||||
.Sh DESCRIPTION
|
.Sh DESCRIPTION
|
||||||
The function
|
The function
|
||||||
.Fn kthread_start
|
.Fn kthread_start
|
||||||
@ -151,6 +157,16 @@ member of the new thread's
|
|||||||
.Vt "struct thread" .
|
.Vt "struct thread" .
|
||||||
.Pp
|
.Pp
|
||||||
The
|
The
|
||||||
|
.Fn kproc_kthread_add
|
||||||
|
function is much like the
|
||||||
|
.Fn kthread_add
|
||||||
|
function above except that if the kproc does not already
|
||||||
|
exist, it is created.
|
||||||
|
This function is better documented in the
|
||||||
|
.Xr kproc 9
|
||||||
|
manual page.
|
||||||
|
.Pp
|
||||||
|
The
|
||||||
.Fn kthread_exit
|
.Fn kthread_exit
|
||||||
function is used to terminate kernel threads.
|
function is used to terminate kernel threads.
|
||||||
It should be called by the main function of the kernel thread rather than
|
It should be called by the main function of the kernel thread rather than
|
||||||
|
@ -403,7 +403,8 @@ kproc_kthread_add(void (*func)(void *), void *arg,
|
|||||||
if (error)
|
if (error)
|
||||||
return (error);
|
return (error);
|
||||||
td = FIRST_THREAD_IN_PROC(*procptr);
|
td = FIRST_THREAD_IN_PROC(*procptr);
|
||||||
*tdptr = td;
|
if (tdptr)
|
||||||
|
*tdptr = td;
|
||||||
va_start(ap, fmt);
|
va_start(ap, fmt);
|
||||||
vsnprintf(td->td_name, sizeof(td->td_name), fmt, ap);
|
vsnprintf(td->td_name, sizeof(td->td_name), fmt, ap);
|
||||||
va_end(ap);
|
va_end(ap);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user