summaryrefslogtreecommitdiff
path: root/static/freebsd/man9/kthread.9 3.html
diff options
context:
space:
mode:
Diffstat (limited to 'static/freebsd/man9/kthread.9 3.html')
-rw-r--r--static/freebsd/man9/kthread.9 3.html271
1 files changed, 0 insertions, 271 deletions
diff --git a/static/freebsd/man9/kthread.9 3.html b/static/freebsd/man9/kthread.9 3.html
deleted file mode 100644
index 01aa3362..00000000
--- a/static/freebsd/man9/kthread.9 3.html
+++ /dev/null
@@ -1,271 +0,0 @@
-<table class="head">
- <tr>
- <td class="head-ltitle">KTHREAD(9)</td>
- <td class="head-vol">Kernel Developer's Manual</td>
- <td class="head-rtitle">KTHREAD(9)</td>
- </tr>
-</table>
-<div class="manual-text">
-<section class="Sh">
-<h1 class="Sh" id="NAME"><a class="permalink" href="#NAME">NAME</a></h1>
-<p class="Pp"><code class="Nm">kthread_start</code>,
- <code class="Nm">kthread_shutdown</code>,
- <code class="Nm">kthread_add</code>, <code class="Nm">kthread_exit</code>,
- <code class="Nm">kthread_resume</code>,
- <code class="Nm">kthread_suspend</code>,
- <code class="Nm">kthread_suspend_check</code> &#x2014;
- <span class="Nd">kernel threads</span></p>
-</section>
-<section class="Sh">
-<h1 class="Sh" id="SYNOPSIS"><a class="permalink" href="#SYNOPSIS">SYNOPSIS</a></h1>
-<p class="Pp"><code class="In">#include
- &lt;<a class="In">sys/kthread.h</a>&gt;</code></p>
-<p class="Pp"><var class="Ft">void</var>
- <br/>
- <code class="Fn">kthread_start</code>(<var class="Fa" style="white-space: nowrap;">const
- void *udata</var>);</p>
-<p class="Pp"><var class="Ft">void</var>
- <br/>
- <code class="Fn">kthread_shutdown</code>(<var class="Fa" style="white-space: nowrap;">void
- *arg</var>, <var class="Fa" style="white-space: nowrap;">int
- howto</var>);</p>
-<p class="Pp"><var class="Ft">void</var>
- <br/>
- <code class="Fn">kthread_exit</code>(<var class="Fa" style="white-space: nowrap;">void</var>);</p>
-<p class="Pp"><var class="Ft">int</var>
- <br/>
- <code class="Fn">kthread_resume</code>(<var class="Fa" style="white-space: nowrap;">struct
- thread *td</var>);</p>
-<p class="Pp"><var class="Ft">int</var>
- <br/>
- <code class="Fn">kthread_suspend</code>(<var class="Fa" style="white-space: nowrap;">struct
- thread *td</var>, <var class="Fa" style="white-space: nowrap;">int
- timo</var>);</p>
-<p class="Pp"><var class="Ft">void</var>
- <br/>
- <code class="Fn">kthread_suspend_check</code>(<var class="Fa" style="white-space: nowrap;">void</var>);</p>
-<p class="Pp"><code class="In">#include
- &lt;<a class="In">sys/unistd.h</a>&gt;</code></p>
-<p class="Pp"><var class="Ft">int</var>
- <br/>
- <code class="Fn">kthread_add</code>(<var class="Fa">void (*func)(void
- *)</var>, <var class="Fa">void *arg</var>, <var class="Fa">struct proc
- *procp</var>, <var class="Fa">struct thread **newtdpp</var>,
- <var class="Fa">int flags</var>, <var class="Fa">int pages</var>,
- <var class="Fa">const char *fmt</var>, <var class="Fa">...</var>);</p>
-<p class="Pp"><var class="Ft">int</var>
- <br/>
- <code class="Fn">kproc_kthread_add</code>(<var class="Fa">void (*func)(void
- *)</var>, <var class="Fa">void *arg</var>, <var class="Fa">struct proc
- **procptr</var>, <var class="Fa">struct thread **tdptr</var>,
- <var class="Fa">int flags</var>, <var class="Fa">int pages</var>,
- <var class="Fa">char * procname</var>, <var class="Fa">const char
- *fmt</var>, <var class="Fa">...</var>);</p>
-</section>
-<section class="Sh">
-<h1 class="Sh" id="DESCRIPTION"><a class="permalink" href="#DESCRIPTION">DESCRIPTION</a></h1>
-<p class="Pp">In <span class="Ux">FreeBSD 8.0</span>, the older family of
- <a class="permalink" href="#kthread_*"><code class="Fn" id="kthread_*">kthread_*</code></a>(<var class="Fa">9</var>)
- functions was renamed to be the
- <a class="permalink" href="#kproc_*"><code class="Fn" id="kproc_*">kproc_*</code></a>(<var class="Fa">9</var>)
- family of functions, as they were previously misnamed and actually produced
- kernel processes. This new family of
- <code class="Fn">kthread_*</code>(<var class="Fa">9</var>) functions was
- added to produce
- <a class="permalink" href="#real"><i class="Em" id="real">real</i></a>
- kernel threads. See the <a class="Xr">kproc(9)</a> man page for more
- information on the renamed calls. Also note that the
- <code class="Fn">kproc_kthread_add</code>(<var class="Fa">9</var>) function
- appears in both pages as its functionality is split.</p>
-<p class="Pp" id="kthread_start">The function
- <a class="permalink" href="#kthread_start"><code class="Fn">kthread_start</code></a>()
- is used to start &#x201C;internal&#x201D; daemons such as
- <code class="Nm">bufdaemon</code>, <code class="Nm">pagedaemon</code>,
- <code class="Nm">vmdaemon</code>, and the <code class="Nm">syncer</code> and
- is intended to be called from <a class="Xr">SYSINIT(9)</a>. The
- <var class="Fa">udata</var> argument is actually a pointer to a
- <var class="Vt">struct kthread_desc</var> which describes the kernel thread
- that should be created:</p>
-<div class="Bd Pp Bd-indent Li">
-<pre>struct kthread_desc {
- char *arg0;
- void (*func)(void);
- struct thread **global_threadpp;
-};</pre>
-</div>
-<p class="Pp" id="kthread_start~2">The structure members are used by
- <a class="permalink" href="#kthread_start~2"><code class="Fn">kthread_start</code></a>()
- as follows:</p>
-<div class="Bd-indent">
-<dl class="Bl-tag">
- <dt id="arg0"><var class="Va">arg0</var></dt>
- <dd>String to be used for the name of the thread. This string will be copied
- into the <var class="Va">td_name</var> member of the new threads'
- <var class="Vt">struct thread</var>.</dd>
- <dt id="func"><var class="Va">func</var></dt>
- <dd>The main function for this kernel thread to run.</dd>
- <dt id="global_threadpp"><var class="Va">global_threadpp</var></dt>
- <dd>A pointer to a <var class="Vt">struct thread</var> pointer that should be
- updated to point to the newly created thread's
- <var class="Vt">thread</var> structure. If this variable is
- <code class="Dv">NULL</code>, then it is ignored. The thread will be a
- subthread of <var class="Va">proc0</var> (PID 0).</dd>
-</dl>
-</div>
-<p class="Pp" id="kthread_add">The
- <a class="permalink" href="#kthread_add"><code class="Fn">kthread_add</code></a>()
- function is used to create a kernel thread. The new thread runs in kernel
- mode only. It is added to the process specified by the
- <var class="Fa">procp</var> argument, or if that is
- <code class="Dv">NULL</code>, to <var class="Va">proc0</var>. The
- <var class="Fa">func</var> argument specifies the function that the thread
- should execute. The <var class="Fa">arg</var> argument is an arbitrary
- pointer that is passed in as the only argument to <var class="Fa">func</var>
- when it is called by the new thread. The <var class="Fa">newtdpp</var>
- pointer points to a <var class="Vt">struct thread</var> pointer that is to
- be updated to point to the newly created thread. If this argument is
- <code class="Dv">NULL</code>, then it is ignored. The
- <var class="Fa">flags</var> argument may be set to
- <code class="Dv">RFSTOPPED</code> to leave the thread in a stopped state.
- The caller must call
- <a class="permalink" href="#sched_add"><code class="Fn" id="sched_add">sched_add</code></a>()
- to start the thread. The <var class="Fa">pages</var> 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 rest of the arguments form a
- <a class="Xr">printf(9)</a> argument list that is used to build the name of
- the new thread and is stored in the <var class="Va">td_name</var> member of
- the new thread's <var class="Vt">struct thread</var>.</p>
-<p class="Pp" id="kproc_kthread_add">The
- <a class="permalink" href="#kproc_kthread_add"><code class="Fn">kproc_kthread_add</code></a>()
- function is much like the <code class="Fn">kthread_add</code>() function
- above except that if the kproc does not already exist, it is created. This
- function is better documented in the <a class="Xr">kproc(9)</a> manual
- page.</p>
-<p class="Pp" id="kthread_exit">The
- <a class="permalink" href="#kthread_exit"><code class="Fn">kthread_exit</code></a>()
- function is used to terminate kernel threads. It should be called by the
- main function of the kernel thread rather than letting the main function
- return to its caller.</p>
-<p class="Pp" id="kthread_resume">The
- <a class="permalink" href="#kthread_resume"><code class="Fn">kthread_resume</code></a>(),
- <a class="permalink" href="#kthread_suspend"><code class="Fn" id="kthread_suspend">kthread_suspend</code></a>(),
- and
- <a class="permalink" href="#kthread_suspend_check"><code class="Fn" id="kthread_suspend_check">kthread_suspend_check</code></a>()
- functions are used to suspend and resume a kernel thread. During the main
- loop of its execution, a kernel thread that wishes to allow itself to be
- suspended should call <code class="Fn">kthread_suspend_check</code>() in
- order to check if the it has been asked to suspend. If it has, it will
- <a class="Xr">msleep(9)</a> until it is told to resume. Once it has been
- told to resume it will return allowing execution of the kernel thread to
- continue. The other two functions are used to notify a kernel thread of a
- suspend or resume request. The <var class="Fa">td</var> argument points to
- the <var class="Vt">struct thread</var> of the kernel thread to suspend or
- resume. For <code class="Fn">kthread_suspend</code>(), the
- <var class="Fa">timo</var> argument specifies a timeout to wait for the
- kernel thread to acknowledge the suspend request and suspend itself.</p>
-<p class="Pp" id="kthread_shutdown">The
- <a class="permalink" href="#kthread_shutdown"><code class="Fn">kthread_shutdown</code></a>()
- function is meant to be registered as a shutdown event for kernel threads
- that need to be suspended voluntarily during system shutdown so as not to
- interfere with system shutdown activities. The actual suspension of the
- kernel thread is done with
- <a class="permalink" href="#kthread_suspend~2"><code class="Fn" id="kthread_suspend~2">kthread_suspend</code></a>().</p>
-</section>
-<section class="Sh">
-<h1 class="Sh" id="RETURN_VALUES"><a class="permalink" href="#RETURN_VALUES">RETURN
- VALUES</a></h1>
-<p class="Pp">The <code class="Fn">kthread_add</code>(),
- <code class="Fn">kthread_resume</code>(), and
- <code class="Fn">kthread_suspend</code>() functions return zero on success
- and non-zero on failure.</p>
-</section>
-<section class="Sh">
-<h1 class="Sh" id="EXAMPLES"><a class="permalink" href="#EXAMPLES">EXAMPLES</a></h1>
-<p class="Pp">This example demonstrates the use of a <var class="Vt">struct
- kthread_desc</var> and the functions
- <code class="Fn">kthread_start</code>(),
- <code class="Fn">kthread_shutdown</code>(), and
- <code class="Fn">kthread_suspend_check</code>() to run the
- <code class="Nm">bufdaemon</code> process.</p>
-<div class="Bd Pp Bd-indent Li">
-<pre>static struct thread *bufdaemonthread;
-
-static struct kthread_desc buf_kp = {
- &quot;bufdaemon&quot;,
- buf_daemon,
- &amp;bufdaemonthread
-};
-SYSINIT(bufdaemon, SI_SUB_KTHREAD_BUF, SI_ORDER_FIRST, kthread_start,
- &amp;buf_kp)
-
-static void
-buf_daemon()
-{
- ...
- /*
- * This process needs to be suspended prior to shutdown sync.
- */
- EVENTHANDLER_REGISTER(shutdown_pre_sync, kthread_shutdown,
- bufdaemonthread, SHUTDOWN_PRI_LAST);
- ...
- for (;;) {
- kthread_suspend_check();
- ...
- }
-}</pre>
-</div>
-</section>
-<section class="Sh">
-<h1 class="Sh" id="ERRORS"><a class="permalink" href="#ERRORS">ERRORS</a></h1>
-<p class="Pp">The <code class="Fn">kthread_resume</code>() and
- <code class="Fn">kthread_suspend</code>() functions will fail if:</p>
-<dl class="Bl-tag">
- <dt id="EINVAL">[<a class="permalink" href="#EINVAL"><code class="Er">EINVAL</code></a>]</dt>
- <dd>The <var class="Fa">td</var> argument does not reference a kernel
- thread.</dd>
-</dl>
-<p class="Pp">The <code class="Fn">kthread_add</code>() function will fail
- if:</p>
-<dl class="Bl-tag">
- <dt id="ENOMEM">[<a class="permalink" href="#ENOMEM"><code class="Er">ENOMEM</code></a>]</dt>
- <dd>Memory for a thread's stack could not be allocated.</dd>
-</dl>
-</section>
-<section class="Sh">
-<h1 class="Sh" id="SEE_ALSO"><a class="permalink" href="#SEE_ALSO">SEE
- ALSO</a></h1>
-<p class="Pp"><a class="Xr">kproc(9)</a>, <a class="Xr">SYSINIT(9)</a>,
- <a class="Xr">wakeup(9)</a></p>
-</section>
-<section class="Sh">
-<h1 class="Sh" id="HISTORY"><a class="permalink" href="#HISTORY">HISTORY</a></h1>
-<p class="Pp">The <code class="Fn">kthread_start</code>() function first
- appeared in <span class="Ux">FreeBSD 2.2</span> where it created a whole
- process. It was converted to create threads in <span class="Ux">FreeBSD
- 8.0</span>. The <code class="Fn">kthread_shutdown</code>(),
- <code class="Fn">kthread_exit</code>(),
- <code class="Fn">kthread_resume</code>(),
- <code class="Fn">kthread_suspend</code>(), and
- <code class="Fn">kthread_suspend_check</code>() functions were introduced in
- <span class="Ux">FreeBSD 4.0</span> and were converted to threads in
- <span class="Ux">FreeBSD 8.0</span>. The
- <code class="Fn">kthread_create</code>() call was renamed to
- <code class="Fn">kthread_add</code>() in <span class="Ux">FreeBSD
- 8.0</span>. The old functionality of creating a kernel process was renamed
- to <a class="Xr">kproc_create(9)</a>. Prior to <span class="Ux">FreeBSD
- 5.0</span>, the <code class="Fn">kthread_shutdown</code>(),
- <code class="Fn">kthread_resume</code>(),
- <code class="Fn">kthread_suspend</code>(), and
- <code class="Fn">kthread_suspend_check</code>() functions were named
- <code class="Fn">shutdown_kproc</code>(),
- <code class="Fn">resume_kproc</code>(),
- <code class="Fn">shutdown_kproc</code>(), and
- <code class="Fn">kproc_suspend_loop</code>(), respectively.</p>
-</section>
-</div>
-<table class="foot">
- <tr>
- <td class="foot-date">July 15, 2014</td>
- <td class="foot-os">FreeBSD 15.0</td>
- </tr>
-</table>