<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.1.2//EN"
	"http://www.oasis-open.org/docbook/xml/4.1.2/docbookx.dtd" []>

<book id="LinuxKernelAPI">
 <bookinfo>
  <title>The Linux Kernel API</title>
  
  <legalnotice>
   <para>
     This documentation is free software; you can redistribute
     it and/or modify it under the terms of the GNU General Public
     License as published by the Free Software Foundation; either
     version 2 of the License, or (at your option) any later
     version.
   </para>
      
   <para>
     This program is distributed in the hope that it will be
     useful, but WITHOUT ANY WARRANTY; without even the implied
     warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
     See the GNU General Public License for more details.
   </para>
      
   <para>
     You should have received a copy of the GNU General Public
     License along with this program; if not, write to the Free
     Software Foundation, Inc., 59 Temple Place, Suite 330, Boston,
     MA 02111-1307 USA
   </para>
      
   <para>
     For more details see the file COPYING in the source
     distribution of Linux.
   </para>
  </legalnotice>
 </bookinfo>

<toc></toc>

  <chapter id="Basics">
     <title>Driver Basics</title>
     <sect1><title>Driver Entry and Exit points</title>
<!-- include/linux/init.h -->
<refentry>
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>November 2007</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase id="API-module-init">module_init</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
</refmeta>
<refnamediv>
 <refname>module_init</refname>
 <refpurpose>
   driver initialization entry point
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef> <function>module_init </function></funcdef>
   <paramdef> <parameter>x</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>x</parameter></term>
   <listitem>
    <para>
     function to be run at kernel boot time or module insertion
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   <function>module_init</function> will either be called during do_initcalls (if
   builtin) or at module insertion time (if a module).  There can only
   be one per module.
</para>
</refsect1>
</refentry>

<refentry>
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>November 2007</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase id="API-module-exit">module_exit</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
</refmeta>
<refnamediv>
 <refname>module_exit</refname>
 <refpurpose>
      driver exit entry point
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef> <function>module_exit </function></funcdef>
   <paramdef> <parameter>x</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>x</parameter></term>
   <listitem>
    <para>
     function to be run when driver is removed
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   <function>module_exit</function> will wrap the driver clean-up code
   with <function>cleanup_module</function> when used with rmmod when
   the driver is a module.  If the driver is statically
   compiled into the kernel, <function>module_exit</function> has no effect.
   There can only be one per module.
</para>
</refsect1>
</refentry>

     </sect1>

     <sect1><title>Atomic and pointer manipulation</title>
<!-- include/asm-i386/atomic.h -->
<refentry>
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>November 2007</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase id="API-atomic-read">atomic_read</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
</refmeta>
<refnamediv>
 <refname>atomic_read</refname>
 <refpurpose>
   read atomic variable
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef> <function>atomic_read </function></funcdef>
   <paramdef> <parameter>v</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>v</parameter></term>
   <listitem>
    <para>
     pointer of type atomic_t
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   Atomically reads the value of <parameter>v</parameter>.
</para>
</refsect1>
</refentry>

<refentry>
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>November 2007</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase id="API-atomic-set">atomic_set</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
</refmeta>
<refnamediv>
 <refname>atomic_set</refname>
 <refpurpose>
      set atomic variable
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef> <function>atomic_set </function></funcdef>
   <paramdef> <parameter>v</parameter></paramdef>
   <paramdef> <parameter>i</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>v</parameter></term>
   <listitem>
    <para>
     pointer of type atomic_t
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>i</parameter></term>
   <listitem>
    <para>
     required value
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   Atomically sets the value of <parameter>v</parameter> to <parameter>i</parameter>.
</para>
</refsect1>
</refentry>

<refentry>
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>November 2007</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase id="API-atomic-add">atomic_add</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
</refmeta>
<refnamediv>
 <refname>atomic_add</refname>
 <refpurpose>
      add integer to atomic variable
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>void <function>atomic_add </function></funcdef>
   <paramdef>int <parameter>i</parameter></paramdef>
   <paramdef>atomic_t * <parameter>v</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>i</parameter></term>
   <listitem>
    <para>
     integer value to add
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>v</parameter></term>
   <listitem>
    <para>
     pointer of type atomic_t
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   Atomically adds <parameter>i</parameter> to <parameter>v</parameter>.
</para>
</refsect1>
</refentry>

<refentry>
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>November 2007</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase id="API-atomic-sub">atomic_sub</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
</refmeta>
<refnamediv>
 <refname>atomic_sub</refname>
 <refpurpose>
      subtract the atomic variable
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>void <function>atomic_sub </function></funcdef>
   <paramdef>int <parameter>i</parameter></paramdef>
   <paramdef>atomic_t * <parameter>v</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>i</parameter></term>
   <listitem>
    <para>
     integer value to subtract
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>v</parameter></term>
   <listitem>
    <para>
     pointer of type atomic_t
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   Atomically subtracts <parameter>i</parameter> from <parameter>v</parameter>.
</para>
</refsect1>
</refentry>

<refentry>
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>November 2007</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase id="API-atomic-sub-and-test">atomic_sub_and_test</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
</refmeta>
<refnamediv>
 <refname>atomic_sub_and_test</refname>
 <refpurpose>
      subtract value from variable and test result
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>int <function>atomic_sub_and_test </function></funcdef>
   <paramdef>int <parameter>i</parameter></paramdef>
   <paramdef>atomic_t * <parameter>v</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>i</parameter></term>
   <listitem>
    <para>
     integer value to subtract
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>v</parameter></term>
   <listitem>
    <para>
     pointer of type atomic_t
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   Atomically subtracts <parameter>i</parameter> from <parameter>v</parameter> and returns
   true if the result is zero, or false for all
   other cases.
</para>
</refsect1>
</refentry>

<refentry>
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>November 2007</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase id="API-atomic-inc">atomic_inc</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
</refmeta>
<refnamediv>
 <refname>atomic_inc</refname>
 <refpurpose>
      increment atomic variable
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>void <function>atomic_inc </function></funcdef>
   <paramdef>atomic_t * <parameter>v</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>v</parameter></term>
   <listitem>
    <para>
     pointer of type atomic_t
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   Atomically increments <parameter>v</parameter> by 1.
</para>
</refsect1>
</refentry>

<refentry>
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>November 2007</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase id="API-atomic-dec">atomic_dec</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
</refmeta>
<refnamediv>
 <refname>atomic_dec</refname>
 <refpurpose>
      decrement atomic variable
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>void <function>atomic_dec </function></funcdef>
   <paramdef>atomic_t * <parameter>v</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>v</parameter></term>
   <listitem>
    <para>
     pointer of type atomic_t
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   Atomically decrements <parameter>v</parameter> by 1.
</para>
</refsect1>
</refentry>

<refentry>
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>November 2007</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase id="API-atomic-dec-and-test">atomic_dec_and_test</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
</refmeta>
<refnamediv>
 <refname>atomic_dec_and_test</refname>
 <refpurpose>
      decrement and test
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>int <function>atomic_dec_and_test </function></funcdef>
   <paramdef>atomic_t * <parameter>v</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>v</parameter></term>
   <listitem>
    <para>
     pointer of type atomic_t
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   Atomically decrements <parameter>v</parameter> by 1 and
   returns true if the result is 0, or false for all other
   cases.
</para>
</refsect1>
</refentry>

<refentry>
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>November 2007</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase id="API-atomic-inc-and-test">atomic_inc_and_test</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
</refmeta>
<refnamediv>
 <refname>atomic_inc_and_test</refname>
 <refpurpose>
      increment and test 
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>int <function>atomic_inc_and_test </function></funcdef>
   <paramdef>atomic_t * <parameter>v</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>v</parameter></term>
   <listitem>
    <para>
     pointer of type atomic_t
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   Atomically increments <parameter>v</parameter> by 1
   and returns true if the result is zero, or false for all
   other cases.
</para>
</refsect1>
</refentry>

<refentry>
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>November 2007</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase id="API-atomic-add-negative">atomic_add_negative</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
</refmeta>
<refnamediv>
 <refname>atomic_add_negative</refname>
 <refpurpose>
      add and test if negative
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>int <function>atomic_add_negative </function></funcdef>
   <paramdef>int <parameter>i</parameter></paramdef>
   <paramdef>atomic_t * <parameter>v</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>i</parameter></term>
   <listitem>
    <para>
     integer value to add
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>v</parameter></term>
   <listitem>
    <para>
     pointer of type atomic_t
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   Atomically adds <parameter>i</parameter> to <parameter>v</parameter> and returns true
   if the result is negative, or false when
   result is greater than or equal to zero.
</para>
</refsect1>
</refentry>

<refentry>
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>November 2007</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase id="API-atomic-add-return">atomic_add_return</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
</refmeta>
<refnamediv>
 <refname>atomic_add_return</refname>
 <refpurpose>
      add and return
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>int <function>atomic_add_return </function></funcdef>
   <paramdef>int <parameter>i</parameter></paramdef>
   <paramdef>atomic_t * <parameter>v</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>i</parameter></term>
   <listitem>
    <para>
     integer value to add
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>v</parameter></term>
   <listitem>
    <para>
     pointer of type atomic_t
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   Atomically adds <parameter>i</parameter> to <parameter>v</parameter> and returns <parameter>i</parameter> + <parameter>v</parameter>
</para>
</refsect1>
</refentry>

<refentry>
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>November 2007</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase id="API-atomic-add-unless">atomic_add_unless</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
</refmeta>
<refnamediv>
 <refname>atomic_add_unless</refname>
 <refpurpose>
      add unless the number is a given value
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef> <function>atomic_add_unless </function></funcdef>
   <paramdef> <parameter>v</parameter></paramdef>
   <paramdef> <parameter>a</parameter></paramdef>
   <paramdef> <parameter>u</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>v</parameter></term>
   <listitem>
    <para>
     pointer of type atomic_t
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>a</parameter></term>
   <listitem>
    <para>
     the amount to add to v...
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>u</parameter></term>
   <listitem>
    <para>
     ...unless v is equal to u.
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   Atomically adds <parameter>a</parameter> to <parameter>v</parameter>, so long as it was not <parameter>u</parameter>.
   Returns non-zero if <parameter>v</parameter> was not <parameter>u</parameter>, and zero otherwise.
</para>
</refsect1>
</refentry>

<!-- include/asm-i386/unaligned.h -->
<refentry>
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>November 2007</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase id="API-get-unaligned">get_unaligned</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
</refmeta>
<refnamediv>
 <refname>get_unaligned</refname>
 <refpurpose>
   get value from possibly mis-aligned location
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef> <function>get_unaligned </function></funcdef>
   <paramdef> <parameter>ptr</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>ptr</parameter></term>
   <listitem>
    <para>
     pointer to value
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   This macro should be used for accessing values larger in size than 
   single bytes at locations that are expected to be improperly aligned, 
   e.g. retrieving a u16 value from a location not u16-aligned.
   </para><para>

   Note that unaligned accesses can be very expensive on some architectures.
</para>
</refsect1>
</refentry>

<refentry>
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>November 2007</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase id="API-put-unaligned">put_unaligned</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
</refmeta>
<refnamediv>
 <refname>put_unaligned</refname>
 <refpurpose>
      put value to a possibly mis-aligned location
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef> <function>put_unaligned </function></funcdef>
   <paramdef> <parameter>val</parameter></paramdef>
   <paramdef> <parameter>ptr</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>val</parameter></term>
   <listitem>
    <para>
     value to place
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>ptr</parameter></term>
   <listitem>
    <para>
     pointer to location
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   This macro should be used for placing values larger in size than 
   single bytes at locations that are expected to be improperly aligned, 
   e.g. writing a u16 value to a location not u16-aligned.
   </para><para>

   Note that unaligned accesses can be very expensive on some architectures.
</para>
</refsect1>
</refentry>

     </sect1>

     <sect1><title>Delaying, scheduling, and timer routines</title>
<!-- include/linux/sched.h -->
<refentry>
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>November 2007</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase id="API-pid-alive">pid_alive</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
</refmeta>
<refnamediv>
 <refname>pid_alive</refname>
 <refpurpose>
   check that a task structure is not stale
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>int <function>pid_alive </function></funcdef>
   <paramdef>struct task_struct * <parameter>p</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>p</parameter></term>
   <listitem>
    <para>
     Task structure to be checked.
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   Test if a process is not yet dead (at most zombie state)
   If pid_alive fails, then pointers within the task structure
   can be stale and must not be dereferenced.
</para>
</refsect1>
</refentry>

<!-- kernel/sched.c -->
<refentry>
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>November 2007</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase id="API---wake-up">__wake_up</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
</refmeta>
<refnamediv>
 <refname>__wake_up</refname>
 <refpurpose>
   wake up threads blocked on a waitqueue.
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>void fastcall <function>__wake_up </function></funcdef>
   <paramdef>wait_queue_head_t * <parameter>q</parameter></paramdef>
   <paramdef>unsigned int <parameter>mode</parameter></paramdef>
   <paramdef>int <parameter>nr_exclusive</parameter></paramdef>
   <paramdef>void * <parameter>key</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>q</parameter></term>
   <listitem>
    <para>
     the waitqueue
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>mode</parameter></term>
   <listitem>
    <para>
     which threads
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>nr_exclusive</parameter></term>
   <listitem>
    <para>
     how many wake-one or wake-many threads to wake up
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>key</parameter></term>
   <listitem>
    <para>
     is directly passed to the wakeup function
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
</refentry>

<refentry>
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>November 2007</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase id="API---wake-up-sync">__wake_up_sync</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
</refmeta>
<refnamediv>
 <refname>__wake_up_sync</refname>
 <refpurpose>
      wake up threads blocked on a waitqueue.
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>void fastcall <function>__wake_up_sync </function></funcdef>
   <paramdef>wait_queue_head_t * <parameter>q</parameter></paramdef>
   <paramdef>unsigned int <parameter>mode</parameter></paramdef>
   <paramdef>int <parameter>nr_exclusive</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>q</parameter></term>
   <listitem>
    <para>
     the waitqueue
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>mode</parameter></term>
   <listitem>
    <para>
     which threads
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>nr_exclusive</parameter></term>
   <listitem>
    <para>
     how many wake-one or wake-many threads to wake up
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   The sync wakeup differs that the waker knows that it will schedule
   away soon, so while the target thread will be woken up, it will not
   be migrated to another CPU - ie. the two threads are 'synchronized'
   with each other. This can prevent needless bouncing between CPUs.
   </para><para>

   On UP it can prevent extra preemption.
</para>
</refsect1>
</refentry>

<refentry>
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>November 2007</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase id="API-task-nice">task_nice</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
</refmeta>
<refnamediv>
 <refname>task_nice</refname>
 <refpurpose>
      return the nice value of a given task.
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>int <function>task_nice </function></funcdef>
   <paramdef>const task_t * <parameter>p</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>p</parameter></term>
   <listitem>
    <para>
     the task in question.
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
</refentry>

<refentry>
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>November 2007</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase id="API-sched-setscheduler">sched_setscheduler</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
</refmeta>
<refnamediv>
 <refname>sched_setscheduler</refname>
 <refpurpose>
      change the scheduling policy and/or RT priority of
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>int <function>sched_setscheduler </function></funcdef>
   <paramdef>struct task_struct * <parameter>p</parameter></paramdef>
   <paramdef>int <parameter>policy</parameter></paramdef>
   <paramdef>struct sched_param * <parameter>param</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>p</parameter></term>
   <listitem>
    <para>
     the task in question.
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>policy</parameter></term>
   <listitem>
    <para>
     new policy.
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>param</parameter></term>
   <listitem>
    <para>
     structure containing the new RT priority.
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   a thread.
</para>
</refsect1>
</refentry>

<refentry>
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>November 2007</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase id="API-yield">yield</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
</refmeta>
<refnamediv>
 <refname>yield</refname>
 <refpurpose>
      yield the current processor to other threads.
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>void __sched <function>yield </function></funcdef>
   <paramdef> <parameter>void</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>void</parameter></term>
   <listitem>
    <para>
     no arguments
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   </para><para>

   this is a shortcut for kernel-space yielding - it marks the
   thread runnable and calls <function>sys_sched_yield</function>.
</para>
</refsect1>
</refentry>

<!-- kernel/timer.c -->
<refentry>
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>November 2007</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase id="API-schedule-timeout">schedule_timeout</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
</refmeta>
<refnamediv>
 <refname>schedule_timeout</refname>
 <refpurpose>
   sleep until timeout
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>signed long __sched <function>schedule_timeout </function></funcdef>
   <paramdef>signed long <parameter>timeout</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>timeout</parameter></term>
   <listitem>
    <para>
     timeout value in jiffies
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   Make the current task sleep until <parameter>timeout</parameter> jiffies have
   elapsed. The routine will return immediately unless
   the current task state has been set (see <function>set_current_state</function>).
   </para><para>

   You can set the task state as follows -
   </para><para>

   <constant>TASK_UNINTERRUPTIBLE</constant> - at least <parameter>timeout</parameter> jiffies are guaranteed to
   pass before the routine returns. The routine will return 0
   </para><para>

   <constant>TASK_INTERRUPTIBLE</constant> - the routine may return early if a signal is
   delivered to the current task. In this case the remaining time
   in jiffies will be returned, or 0 if the timer expired in time
   </para><para>

   The current task state is guaranteed to be TASK_RUNNING when this
   routine returns.
   </para><para>

   Specifying a <parameter>timeout</parameter> value of <constant>MAX_SCHEDULE_TIMEOUT</constant> will schedule
   the CPU away without a bound on the timeout. In this case the return
   value will be <constant>MAX_SCHEDULE_TIMEOUT</constant>.
   </para><para>

   In all cases the return value is guaranteed to be non-negative.
</para>
</refsect1>
</refentry>

<refentry>
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>November 2007</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase id="API-msleep">msleep</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
</refmeta>
<refnamediv>
 <refname>msleep</refname>
 <refpurpose>
      sleep safely even with waitqueue interruptions
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>void <function>msleep </function></funcdef>
   <paramdef>unsigned int <parameter>msecs</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>msecs</parameter></term>
   <listitem>
    <para>
     Time in milliseconds to sleep for
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
</refentry>

<refentry>
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>November 2007</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase id="API-msleep-interruptible">msleep_interruptible</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
</refmeta>
<refnamediv>
 <refname>msleep_interruptible</refname>
 <refpurpose>
      sleep waiting for signals
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>unsigned long <function>msleep_interruptible </function></funcdef>
   <paramdef>unsigned int <parameter>msecs</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>msecs</parameter></term>
   <listitem>
    <para>
     Time in milliseconds to sleep for
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
</refentry>

     </sect1>
     <sect1><title>High-resolution timers</title>
<!-- include/linux/ktime.h -->
<refentry>
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>November 2007</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase id="API-ktime-set">ktime_set</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
</refmeta>
<refnamediv>
 <refname>ktime_set</refname>
 <refpurpose>
   Set a ktime_t variable from a seconds/nanoseconds value
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>ktime_t <function>ktime_set </function></funcdef>
   <paramdef>const long <parameter>secs</parameter></paramdef>
   <paramdef>const unsigned long <parameter>nsecs</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>secs</parameter></term>
   <listitem>
    <para>
     	seconds to set
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>nsecs</parameter></term>
   <listitem>
    <para>
     	nanoseconds to set
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   Return the ktime_t representation of the value
</para>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   Return the ktime_t representation of the value
</para>
</refsect1>
</refentry>

<refentry>
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>November 2007</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase id="API-ktime-sub">ktime_sub</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
</refmeta>
<refnamediv>
 <refname>ktime_sub</refname>
 <refpurpose>
      subtract two ktime_t variables
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>ktime_t <function>ktime_sub </function></funcdef>
   <paramdef>const ktime_t <parameter>lhs</parameter></paramdef>
   <paramdef>const ktime_t <parameter>rhs</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>lhs</parameter></term>
   <listitem>
    <para>
     	minuend
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>rhs</parameter></term>
   <listitem>
    <para>
     	subtrahend
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   Returns the remainder of the substraction
</para>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   Returns the remainder of the substraction
</para>
</refsect1>
</refentry>

<refentry>
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>November 2007</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase id="API-ktime-add">ktime_add</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
</refmeta>
<refnamediv>
 <refname>ktime_add</refname>
 <refpurpose>
      add two ktime_t variables
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>ktime_t <function>ktime_add </function></funcdef>
   <paramdef>const ktime_t <parameter>add1</parameter></paramdef>
   <paramdef>const ktime_t <parameter>add2</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>add1</parameter></term>
   <listitem>
    <para>
     	addend1
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>add2</parameter></term>
   <listitem>
    <para>
     	addend2
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   Returns the sum of addend1 and addend2
</para>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   Returns the sum of addend1 and addend2
</para>
</refsect1>
</refentry>

<refentry>
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>November 2007</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase id="API-ktime-add-ns">ktime_add_ns</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
</refmeta>
<refnamediv>
 <refname>ktime_add_ns</refname>
 <refpurpose>
      Add a scalar nanoseconds value to a ktime_t variable
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>ktime_t <function>ktime_add_ns </function></funcdef>
   <paramdef>const ktime_t <parameter>kt</parameter></paramdef>
   <paramdef>u64 <parameter>nsec</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>kt</parameter></term>
   <listitem>
    <para>
     		addend
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>nsec</parameter></term>
   <listitem>
    <para>
     	the scalar nsec value to add
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   Returns the sum of kt and nsec in ktime_t format
</para>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   Returns the sum of kt and nsec in ktime_t format
</para>
</refsect1>
</refentry>

<refentry>
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>November 2007</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase id="API-timespec-to-ktime">timespec_to_ktime</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
</refmeta>
<refnamediv>
 <refname>timespec_to_ktime</refname>
 <refpurpose>
      convert a timespec to ktime_t format
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>ktime_t <function>timespec_to_ktime </function></funcdef>
   <paramdef>const struct timespec <parameter>ts</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>ts</parameter></term>
   <listitem>
    <para>
     		the timespec variable to convert
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   Returns a ktime_t variable with the converted timespec value
</para>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   Returns a ktime_t variable with the converted timespec value
</para>
</refsect1>
</refentry>

<refentry>
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>November 2007</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase id="API-timeval-to-ktime">timeval_to_ktime</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
</refmeta>
<refnamediv>
 <refname>timeval_to_ktime</refname>
 <refpurpose>
      convert a timeval to ktime_t format
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>ktime_t <function>timeval_to_ktime </function></funcdef>
   <paramdef>const struct timeval <parameter>tv</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>tv</parameter></term>
   <listitem>
    <para>
     		the timeval variable to convert
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   Returns a ktime_t variable with the converted timeval value
</para>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   Returns a ktime_t variable with the converted timeval value
</para>
</refsect1>
</refentry>

<refentry>
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>November 2007</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase id="API-ktime-to-timespec">ktime_to_timespec</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
</refmeta>
<refnamediv>
 <refname>ktime_to_timespec</refname>
 <refpurpose>
      convert a ktime_t variable to timespec format
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>struct timespec <function>ktime_to_timespec </function></funcdef>
   <paramdef>const ktime_t <parameter>kt</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>kt</parameter></term>
   <listitem>
    <para>
     		the ktime_t variable to convert
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   Returns the timespec representation of the ktime value
</para>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   Returns the timespec representation of the ktime value
</para>
</refsect1>
</refentry>

<refentry>
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>November 2007</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase id="API-ktime-to-timeval">ktime_to_timeval</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
</refmeta>
<refnamediv>
 <refname>ktime_to_timeval</refname>
 <refpurpose>
      convert a ktime_t variable to timeval format
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>struct timeval <function>ktime_to_timeval </function></funcdef>
   <paramdef>const ktime_t <parameter>kt</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>kt</parameter></term>
   <listitem>
    <para>
     		the ktime_t variable to convert
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   Returns the timeval representation of the ktime value
</para>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   Returns the timeval representation of the ktime value
</para>
</refsect1>
</refentry>

<refentry>
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>November 2007</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase id="API-ktime-to-ns">ktime_to_ns</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
</refmeta>
<refnamediv>
 <refname>ktime_to_ns</refname>
 <refpurpose>
      convert a ktime_t variable to scalar nanoseconds
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>u64 <function>ktime_to_ns </function></funcdef>
   <paramdef>const ktime_t <parameter>kt</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>kt</parameter></term>
   <listitem>
    <para>
     		the ktime_t variable to convert
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   Returns the scalar nanoseconds representation of kt
</para>
</refsect1>
</refentry>

<!-- include/linux/hrtimer.h -->
<refentry>
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>November 2007</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase id="API-struct-hrtimer">struct hrtimer</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
</refmeta>
<refnamediv>
 <refname>struct hrtimer</refname>
 <refpurpose>
   the basic hrtimer structure
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <programlisting>
struct hrtimer {
  struct rb_node node;
  ktime_t expires;
  int (* function) (struct hrtimer *);
  struct hrtimer_base * base;
};  </programlisting>
</refsynopsisdiv>
 <refsect1>
  <title>Members</title>
  <variablelist>
    <varlistentry>      <term>node</term>
      <listitem><para>
	red black tree node for time ordered insertion
      </para></listitem>
    </varlistentry>
    <varlistentry>      <term>expires</term>
      <listitem><para>
	the absolute expiry time in the hrtimers internal
representation. The time is related to the clock on
which the timer is based.
      </para></listitem>
    </varlistentry>
    <varlistentry>      <term>function</term>
      <listitem><para>
	timer expiry callback function
      </para></listitem>
    </varlistentry>
    <varlistentry>      <term>base</term>
      <listitem><para>
	pointer to the timer base (per cpu and per clock)
      </para></listitem>
    </varlistentry>
  </variablelist>
 </refsect1>
<refsect1>
<title>Description</title>
<para>
   The hrtimer structure must be initialized by init_hrtimer_#<function>CLOCKTYPE</function>
</para>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   The hrtimer structure must be initialized by init_hrtimer_#<function>CLOCKTYPE</function>
</para>
</refsect1>
</refentry>

<refentry>
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>November 2007</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase id="API-struct-hrtimer-sleeper">struct hrtimer_sleeper</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
</refmeta>
<refnamediv>
 <refname>struct hrtimer_sleeper</refname>
 <refpurpose>
      simple sleeper structure
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <programlisting>
struct hrtimer_sleeper {
  struct hrtimer timer;
  struct task_struct * task;
};  </programlisting>
</refsynopsisdiv>
 <refsect1>
  <title>Members</title>
  <variablelist>
    <varlistentry>      <term>timer</term>
      <listitem><para>
   	embedded timer structure
      </para></listitem>
    </varlistentry>
    <varlistentry>      <term>task</term>
      <listitem><para>
   	task to wake up
      </para></listitem>
    </varlistentry>
  </variablelist>
 </refsect1>
<refsect1>
<title>Description</title>
<para>
   task is set to NULL, when the timer expires.
</para>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   task is set to NULL, when the timer expires.
</para>
</refsect1>
</refentry>

<refentry>
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>November 2007</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase id="API-struct-hrtimer-base">struct hrtimer_base</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
</refmeta>
<refnamediv>
 <refname>struct hrtimer_base</refname>
 <refpurpose>
      the timer base for a specific clock
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <programlisting>
struct hrtimer_base {
  clockid_t index;
  spinlock_t lock;
  struct rb_root active;
  struct rb_node * first;
  ktime_t resolution;
  ktime_t (* get_time) (void);
  ktime_t (* get_softirq_time) (void);
  struct hrtimer * curr_timer;
  ktime_t softirq_time;
};  </programlisting>
</refsynopsisdiv>
 <refsect1>
  <title>Members</title>
  <variablelist>
    <varlistentry>      <term>index</term>
      <listitem><para>
   		clock type index for per_cpu support when moving a timer
   to a base on another cpu.
      </para></listitem>
    </varlistentry>
    <varlistentry>      <term>lock</term>
      <listitem><para>
   		lock protecting the base and associated timers
      </para></listitem>
    </varlistentry>
    <varlistentry>      <term>active</term>
      <listitem><para>
   		red black tree root node for the active timers
      </para></listitem>
    </varlistentry>
    <varlistentry>      <term>first</term>
      <listitem><para>
   		pointer to the timer node which expires first
      </para></listitem>
    </varlistentry>
    <varlistentry>      <term>resolution</term>
      <listitem><para>
   		the resolution of the clock, in nanoseconds
      </para></listitem>
    </varlistentry>
    <varlistentry>      <term>get_time</term>
      <listitem><para>
   		function to retrieve the current time of the clock
      </para></listitem>
    </varlistentry>
    <varlistentry>      <term>get_softirq_time</term>
      <listitem><para>
   	function to retrieve the current time from the softirq
      </para></listitem>
    </varlistentry>
    <varlistentry>      <term>curr_timer</term>
      <listitem><para>
   		the timer which is executing a callback right now
      </para></listitem>
    </varlistentry>
    <varlistentry>      <term>softirq_time</term>
      <listitem><para>
   	the time when running the hrtimer queue in the softirq
      </para></listitem>
    </varlistentry>
  </variablelist>
 </refsect1>
<refsect1>
<title>Description</title>
<para>
</para>
</refsect1>
</refentry>

<!-- kernel/hrtimer.c -->
<refentry>
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>November 2007</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase id="API-ktime-get-real">ktime_get_real</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
</refmeta>
<refnamediv>
 <refname>ktime_get_real</refname>
 <refpurpose>
   get the real (wall-) time in ktime_t format
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>ktime_t <function>ktime_get_real </function></funcdef>
   <paramdef> <parameter>void</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>void</parameter></term>
   <listitem>
    <para>
     no arguments
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   </para><para>

   returns the time in ktime_t format
</para>
</refsect1>
</refentry>

<refentry>
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>November 2007</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase id="API-ktime-get-ts">ktime_get_ts</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
</refmeta>
<refnamediv>
 <refname>ktime_get_ts</refname>
 <refpurpose>
      get the monotonic clock in timespec format
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>void <function>ktime_get_ts </function></funcdef>
   <paramdef>struct timespec * <parameter>ts</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>ts</parameter></term>
   <listitem>
    <para>
     		pointer to timespec variable
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   The function calculates the monotonic clock from the realtime
   clock and the wall_to_monotonic offset and stores the result
   in normalized timespec format in the variable pointed to by ts.
</para>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   The function calculates the monotonic clock from the realtime
   clock and the wall_to_monotonic offset and stores the result
   in normalized timespec format in the variable pointed to by ts.
</para>
</refsect1>
</refentry>

     </sect1>
     <sect1><title>Internal Functions</title>
<!-- kernel/exit.c -->
<refentry>
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>November 2007</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase id="API-reparent-to-init">reparent_to_init</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
</refmeta>
<refnamediv>
 <refname>reparent_to_init</refname>
 <refpurpose>
   Reparent the calling kernel thread to the init task.
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>void <function>reparent_to_init </function></funcdef>
   <paramdef> <parameter>void</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>void</parameter></term>
   <listitem>
    <para>
     no arguments
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   </para><para>

   If a kernel thread is launched as a result of a system call, or if
   it ever exits, it should generally reparent itself to init so that
   it is correctly cleaned up on exit.
   </para><para>

   The various task state such as scheduling policy and priority may have
   been inherited from a user process, so we reset them to sane values here.
   </para><para>

   NOTE that <function>reparent_to_init</function> gives the caller full capabilities.
</para>
</refsect1>
</refentry>

<!-- kernel/signal.c -->
<refentry>
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>November 2007</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase id="API-sys-tgkill">sys_tgkill</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
</refmeta>
<refnamediv>
 <refname>sys_tgkill</refname>
 <refpurpose>
   send signal to one specific thread
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>long <function>sys_tgkill </function></funcdef>
   <paramdef>int <parameter>tgid</parameter></paramdef>
   <paramdef>int <parameter>pid</parameter></paramdef>
   <paramdef>int <parameter>sig</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>tgid</parameter></term>
   <listitem>
    <para>
     the thread group ID of the thread
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>pid</parameter></term>
   <listitem>
    <para>
     the PID of the thread
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>sig</parameter></term>
   <listitem>
    <para>
     signal to be sent
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   This syscall also checks the tgid and returns -ESRCH even if the PID
   exists but it's not belonging to the target process anymore. This
   method solves the problem of threads exiting and PIDs getting reused.
</para>
</refsect1>
</refentry>

     </sect1>

     <sect1><title>Kernel objects manipulation</title>
<!--
X!Iinclude/linux/kobject.h
-->
<!-- lib/kobject.c -->
<refentry>
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>November 2007</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase id="API-kobject-init">kobject_init</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
</refmeta>
<refnamediv>
 <refname>kobject_init</refname>
 <refpurpose>
   initialize object.
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>void <function>kobject_init </function></funcdef>
   <paramdef>struct kobject * <parameter>kobj</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>kobj</parameter></term>
   <listitem>
    <para>
     	object in question.
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
</refentry>

<refentry>
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>November 2007</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase id="API-kobject-add">kobject_add</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
</refmeta>
<refnamediv>
 <refname>kobject_add</refname>
 <refpurpose>
      add an object to the hierarchy.
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>int <function>kobject_add </function></funcdef>
   <paramdef>struct kobject * <parameter>kobj</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>kobj</parameter></term>
   <listitem>
    <para>
     	object.
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
</refentry>

<refentry>
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>November 2007</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase id="API-kobject-register">kobject_register</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
</refmeta>
<refnamediv>
 <refname>kobject_register</refname>
 <refpurpose>
      initialize and add an object.
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>int <function>kobject_register </function></funcdef>
   <paramdef>struct kobject * <parameter>kobj</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>kobj</parameter></term>
   <listitem>
    <para>
     	object in question.
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
</refentry>

<refentry>
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>November 2007</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase id="API-kobject-set-name">kobject_set_name</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
</refmeta>
<refnamediv>
 <refname>kobject_set_name</refname>
 <refpurpose>
      Set the name of an object
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>int <function>kobject_set_name </function></funcdef>
   <paramdef>struct kobject * <parameter>kobj</parameter></paramdef>
   <paramdef>const char * <parameter>fmt</parameter></paramdef>
   <paramdef> <parameter>...</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>kobj</parameter></term>
   <listitem>
    <para>
     	object.
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>fmt</parameter></term>
   <listitem>
    <para>
     	format string used to build the name
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>...</parameter></term>
   <listitem>
    <para>
     variable arguments
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   If strlen(name) &gt;= KOBJ_NAME_LEN, then use a dynamically allocated
   string that <parameter>kobj</parameter>-&gt;k_name points to. Otherwise, use the static 
   <parameter>kobj</parameter>-&gt;name array.
</para>
</refsect1>
</refentry>

<refentry>
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>November 2007</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase id="API-kobject-del">kobject_del</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
</refmeta>
<refnamediv>
 <refname>kobject_del</refname>
 <refpurpose>
      unlink kobject from hierarchy.
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>void <function>kobject_del </function></funcdef>
   <paramdef>struct kobject * <parameter>kobj</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>kobj</parameter></term>
   <listitem>
    <para>
     	object.
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
</refentry>

<refentry>
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>November 2007</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase id="API-kobject-unregister">kobject_unregister</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
</refmeta>
<refnamediv>
 <refname>kobject_unregister</refname>
 <refpurpose>
      remove object from hierarchy and decrement refcount.
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>void <function>kobject_unregister </function></funcdef>
   <paramdef>struct kobject * <parameter>kobj</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>kobj</parameter></term>
   <listitem>
    <para>
     	object going away.
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
</refentry>

<refentry>
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>November 2007</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase id="API-kobject-get">kobject_get</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
</refmeta>
<refnamediv>
 <refname>kobject_get</refname>
 <refpurpose>
      increment refcount for object.
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>struct kobject * <function>kobject_get </function></funcdef>
   <paramdef>struct kobject * <parameter>kobj</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>kobj</parameter></term>
   <listitem>
    <para>
     	object.
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
</refentry>

<refentry>
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>November 2007</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase id="API-kobject-put">kobject_put</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
</refmeta>
<refnamediv>
 <refname>kobject_put</refname>
 <refpurpose>
      decrement refcount for object.
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>void <function>kobject_put </function></funcdef>
   <paramdef>struct kobject * <parameter>kobj</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>kobj</parameter></term>
   <listitem>
    <para>
     	object.
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   Decrement the refcount, and if 0, call <function>kobject_cleanup</function>.
</para>
</refsect1>
</refentry>

<refentry>
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>November 2007</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase id="API-kset-register">kset_register</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
</refmeta>
<refnamediv>
 <refname>kset_register</refname>
 <refpurpose>
      initialize and add a kset.
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>int <function>kset_register </function></funcdef>
   <paramdef>struct kset * <parameter>k</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>k</parameter></term>
   <listitem>
    <para>
     	kset.
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
</refentry>

<refentry>
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>November 2007</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase id="API-kset-unregister">kset_unregister</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
</refmeta>
<refnamediv>
 <refname>kset_unregister</refname>
 <refpurpose>
      remove a kset.
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>void <function>kset_unregister </function></funcdef>
   <paramdef>struct kset * <parameter>k</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>k</parameter></term>
   <listitem>
    <para>
     	kset.
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
</refentry>

<refentry>
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>November 2007</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase id="API-subsystem-register">subsystem_register</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
</refmeta>
<refnamediv>
 <refname>subsystem_register</refname>
 <refpurpose>
      register a subsystem.
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>int <function>subsystem_register </function></funcdef>
   <paramdef>struct subsystem * <parameter>s</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>s</parameter></term>
   <listitem>
    <para>
     	the subsystem we're registering.
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   Once we register the subsystem, we want to make sure that 
   the kset points back to this subsystem for correct usage of 
   the rwsem. 
</para>
</refsect1>
</refentry>

<refentry>
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>November 2007</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase id="API-subsys-create-file">subsys_create_file</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
</refmeta>
<refnamediv>
 <refname>subsys_create_file</refname>
 <refpurpose>
      export sysfs attribute file.
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>int <function>subsys_create_file </function></funcdef>
   <paramdef>struct subsystem * <parameter>s</parameter></paramdef>
   <paramdef>struct subsys_attribute * <parameter>a</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>s</parameter></term>
   <listitem>
    <para>
     	subsystem.
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>a</parameter></term>
   <listitem>
    <para>
     	subsystem attribute descriptor.
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
</refentry>

     </sect1>

     <sect1><title>Kernel utility functions</title>
<!-- include/linux/kernel.h -->
<refentry>
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>November 2007</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase id="API-container-of">container_of</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
</refmeta>
<refnamediv>
 <refname>container_of</refname>
 <refpurpose>
   cast a member of a structure out to the containing structure
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef> <function>container_of </function></funcdef>
   <paramdef> <parameter>ptr</parameter></paramdef>
   <paramdef> <parameter>type</parameter></paramdef>
   <paramdef> <parameter>member</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>ptr</parameter></term>
   <listitem>
    <para>
     	the pointer to the member.
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>type</parameter></term>
   <listitem>
    <para>
     	the type of the container struct this is embedded in.
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>member</parameter></term>
   <listitem>
    <para>
     	the name of the member within the struct.
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
</refentry>

<!-- kernel/printk.c -->
<refentry>
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>November 2007</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase id="API-printk">printk</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
</refmeta>
<refnamediv>
 <refname>printk</refname>
 <refpurpose>
   print a kernel message
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>int <function>printk </function></funcdef>
   <paramdef>const char * <parameter>fmt</parameter></paramdef>
   <paramdef> <parameter>...</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>fmt</parameter></term>
   <listitem>
    <para>
     format string
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>...</parameter></term>
   <listitem>
    <para>
     variable arguments
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   This is printk.  It can be called from any context.  We want it to work.
   </para><para>

   We try to grab the console_sem.  If we succeed, it's easy - we log the output and
   call the console drivers.  If we fail to get the semaphore we place the output
   into the log buffer and return.  The current holder of the console_sem will
   notice the new output in <function>release_console_sem</function> and will send it to the
   consoles before releasing the semaphore.
   </para><para>

   One effect of this deferred printing is that code which calls <function>printk</function> and
   then changes console_loglevel may break. This is because console_loglevel
   is inspected when the actual printing occurs.
</para>
</refsect1>
<refsect1>
<title>See also</title>
<para>
   printf(3)
</para>
</refsect1>
</refentry>

<refentry>
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>November 2007</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase id="API-acquire-console-sem">acquire_console_sem</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
</refmeta>
<refnamediv>
 <refname>acquire_console_sem</refname>
 <refpurpose>
      lock the console system for exclusive use.
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>void <function>acquire_console_sem </function></funcdef>
   <paramdef> <parameter>void</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>void</parameter></term>
   <listitem>
    <para>
     no arguments
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   </para><para>

   Acquires a semaphore which guarantees that the caller has
   exclusive access to the console system and the console_drivers list.
   </para><para>

   Can sleep, returns nothing.
</para>
</refsect1>
</refentry>

<refentry>
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>November 2007</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase id="API-release-console-sem">release_console_sem</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
</refmeta>
<refnamediv>
 <refname>release_console_sem</refname>
 <refpurpose>
      unlock the console system
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>void <function>release_console_sem </function></funcdef>
   <paramdef> <parameter>void</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>void</parameter></term>
   <listitem>
    <para>
     no arguments
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   </para><para>

   Releases the semaphore which the caller holds on the console system
   and the console driver list.
   </para><para>

   While the semaphore was held, console output may have been buffered
   by <function>printk</function>.  If this is the case, <function>release_console_sem</function> emits
   the output prior to releasing the semaphore.
   </para><para>

   If there is output waiting for klogd, we wake it up.
   </para><para>

   <function>release_console_sem</function> may be called from any context.
</para>
</refsect1>
</refentry>

<refentry>
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>November 2007</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase id="API-console-conditional-schedule">console_conditional_schedule</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
</refmeta>
<refnamediv>
 <refname>console_conditional_schedule</refname>
 <refpurpose>
      yield the CPU if required
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>void __sched <function>console_conditional_schedule </function></funcdef>
   <paramdef> <parameter>void</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>void</parameter></term>
   <listitem>
    <para>
     no arguments
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   </para><para>

   If the console code is currently allowed to sleep, and
   if this CPU should yield the CPU to another task, do
   so here.
   </para><para>

   Must be called within <function>acquire_console_sem</function>.
</para>
</refsect1>
</refentry>

<!-- kernel/panic.c -->
<refentry>
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>November 2007</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase id="API-panic">panic</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
</refmeta>
<refnamediv>
 <refname>panic</refname>
 <refpurpose>
   halt the system
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>NORET_TYPE void <function>panic </function></funcdef>
   <paramdef>const char * <parameter>fmt</parameter></paramdef>
   <paramdef> <parameter>...</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>fmt</parameter></term>
   <listitem>
    <para>
     The text string to print
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>...</parameter></term>
   <listitem>
    <para>
     variable arguments
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   Display a message, then perform cleanups.
   </para><para>

   This function never returns.
</para>
</refsect1>
</refentry>

<!-- kernel/sys.c -->
<refentry>
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>November 2007</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase id="API-atomic-notifier-chain-register">atomic_notifier_chain_register</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
</refmeta>
<refnamediv>
 <refname>atomic_notifier_chain_register</refname>
 <refpurpose>
   Add notifier to an atomic notifier chain
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>int <function>atomic_notifier_chain_register </function></funcdef>
   <paramdef>struct atomic_notifier_head * <parameter>nh</parameter></paramdef>
   <paramdef>struct notifier_block * <parameter>n</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>nh</parameter></term>
   <listitem>
    <para>
     Pointer to head of the atomic notifier chain
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>n</parameter></term>
   <listitem>
    <para>
     New entry in notifier chain
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   Adds a notifier to an atomic notifier chain.
   </para><para>

   Currently always returns zero.
</para>
</refsect1>
</refentry>

<refentry>
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>November 2007</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase id="API-atomic-notifier-chain-unregister">atomic_notifier_chain_unregister</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
</refmeta>
<refnamediv>
 <refname>atomic_notifier_chain_unregister</refname>
 <refpurpose>
      Remove notifier from an atomic notifier chain
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>int <function>atomic_notifier_chain_unregister </function></funcdef>
   <paramdef>struct atomic_notifier_head * <parameter>nh</parameter></paramdef>
   <paramdef>struct notifier_block * <parameter>n</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>nh</parameter></term>
   <listitem>
    <para>
     Pointer to head of the atomic notifier chain
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>n</parameter></term>
   <listitem>
    <para>
     Entry to remove from notifier chain
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   Removes a notifier from an atomic notifier chain.
   </para><para>

   Returns zero on success or <constant>-ENOENT</constant> on failure.
</para>
</refsect1>
</refentry>

<refentry>
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>November 2007</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase id="API-atomic-notifier-call-chain">atomic_notifier_call_chain</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
</refmeta>
<refnamediv>
 <refname>atomic_notifier_call_chain</refname>
 <refpurpose>
      Call functions in an atomic notifier chain
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>int <function>atomic_notifier_call_chain </function></funcdef>
   <paramdef>struct atomic_notifier_head * <parameter>nh</parameter></paramdef>
   <paramdef>unsigned long <parameter>val</parameter></paramdef>
   <paramdef>void * <parameter>v</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>nh</parameter></term>
   <listitem>
    <para>
     Pointer to head of the atomic notifier chain
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>val</parameter></term>
   <listitem>
    <para>
     Value passed unmodified to notifier function
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>v</parameter></term>
   <listitem>
    <para>
     Pointer passed unmodified to notifier function
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   Calls each function in a notifier chain in turn.  The functions
   run in an atomic context, so they must not block.
   This routine uses RCU to synchronize with changes to the chain.
   </para><para>

   If the return value of the notifier can be and'ed
   with <constant>NOTIFY_STOP_MASK</constant> then atomic_notifier_call_chain
   will return immediately, with the return value of
   the notifier function which halted execution.
   Otherwise the return value is the return value
   of the last notifier function called.
</para>
</refsect1>
</refentry>

<refentry>
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>November 2007</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase id="API-blocking-notifier-chain-register">blocking_notifier_chain_register</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
</refmeta>
<refnamediv>
 <refname>blocking_notifier_chain_register</refname>
 <refpurpose>
      Add notifier to a blocking notifier chain
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>int <function>blocking_notifier_chain_register </function></funcdef>
   <paramdef>struct blocking_notifier_head * <parameter>nh</parameter></paramdef>
   <paramdef>struct notifier_block * <parameter>n</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>nh</parameter></term>
   <listitem>
    <para>
     Pointer to head of the blocking notifier chain
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>n</parameter></term>
   <listitem>
    <para>
     New entry in notifier chain
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   Adds a notifier to a blocking notifier chain.
   Must be called in process context.
   </para><para>

   Currently always returns zero.
</para>
</refsect1>
</refentry>

<refentry>
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>November 2007</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase id="API-blocking-notifier-chain-unregister">blocking_notifier_chain_unregister</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
</refmeta>
<refnamediv>
 <refname>blocking_notifier_chain_unregister</refname>
 <refpurpose>
      Remove notifier from a blocking notifier chain
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>int <function>blocking_notifier_chain_unregister </function></funcdef>
   <paramdef>struct blocking_notifier_head * <parameter>nh</parameter></paramdef>
   <paramdef>struct notifier_block * <parameter>n</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>nh</parameter></term>
   <listitem>
    <para>
     Pointer to head of the blocking notifier chain
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>n</parameter></term>
   <listitem>
    <para>
     Entry to remove from notifier chain
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   Removes a notifier from a blocking notifier chain.
   Must be called from process context.
   </para><para>

   Returns zero on success or <constant>-ENOENT</constant> on failure.
</para>
</refsect1>
</refentry>

<refentry>
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>November 2007</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase id="API-blocking-notifier-call-chain">blocking_notifier_call_chain</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
</refmeta>
<refnamediv>
 <refname>blocking_notifier_call_chain</refname>
 <refpurpose>
      Call functions in a blocking notifier chain
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>int <function>blocking_notifier_call_chain </function></funcdef>
   <paramdef>struct blocking_notifier_head * <parameter>nh</parameter></paramdef>
   <paramdef>unsigned long <parameter>val</parameter></paramdef>
   <paramdef>void * <parameter>v</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>nh</parameter></term>
   <listitem>
    <para>
     Pointer to head of the blocking notifier chain
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>val</parameter></term>
   <listitem>
    <para>
     Value passed unmodified to notifier function
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>v</parameter></term>
   <listitem>
    <para>
     Pointer passed unmodified to notifier function
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   Calls each function in a notifier chain in turn.  The functions
   run in a process context, so they are allowed to block.
   </para><para>

   If the return value of the notifier can be and'ed
   with <constant>NOTIFY_STOP_MASK</constant> then blocking_notifier_call_chain
   will return immediately, with the return value of
   the notifier function which halted execution.
   Otherwise the return value is the return value
   of the last notifier function called.
</para>
</refsect1>
</refentry>

<refentry>
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>November 2007</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase id="API-raw-notifier-chain-register">raw_notifier_chain_register</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
</refmeta>
<refnamediv>
 <refname>raw_notifier_chain_register</refname>
 <refpurpose>
      Add notifier to a raw notifier chain
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>int <function>raw_notifier_chain_register </function></funcdef>
   <paramdef>struct raw_notifier_head * <parameter>nh</parameter></paramdef>
   <paramdef>struct notifier_block * <parameter>n</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>nh</parameter></term>
   <listitem>
    <para>
     Pointer to head of the raw notifier chain
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>n</parameter></term>
   <listitem>
    <para>
     New entry in notifier chain
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   Adds a notifier to a raw notifier chain.
   All locking must be provided by the caller.
   </para><para>

   Currently always returns zero.
</para>
</refsect1>
</refentry>

<refentry>
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>November 2007</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase id="API-raw-notifier-chain-unregister">raw_notifier_chain_unregister</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
</refmeta>
<refnamediv>
 <refname>raw_notifier_chain_unregister</refname>
 <refpurpose>
      Remove notifier from a raw notifier chain
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>int <function>raw_notifier_chain_unregister </function></funcdef>
   <paramdef>struct raw_notifier_head * <parameter>nh</parameter></paramdef>
   <paramdef>struct notifier_block * <parameter>n</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>nh</parameter></term>
   <listitem>
    <para>
     Pointer to head of the raw notifier chain
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>n</parameter></term>
   <listitem>
    <para>
     Entry to remove from notifier chain
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   Removes a notifier from a raw notifier chain.
   All locking must be provided by the caller.
   </para><para>

   Returns zero on success or <constant>-ENOENT</constant> on failure.
</para>
</refsect1>
</refentry>

<refentry>
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>November 2007</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase id="API-raw-notifier-call-chain">raw_notifier_call_chain</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
</refmeta>
<refnamediv>
 <refname>raw_notifier_call_chain</refname>
 <refpurpose>
      Call functions in a raw notifier chain
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>int <function>raw_notifier_call_chain </function></funcdef>
   <paramdef>struct raw_notifier_head * <parameter>nh</parameter></paramdef>
   <paramdef>unsigned long <parameter>val</parameter></paramdef>
   <paramdef>void * <parameter>v</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>nh</parameter></term>
   <listitem>
    <para>
     Pointer to head of the raw notifier chain
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>val</parameter></term>
   <listitem>
    <para>
     Value passed unmodified to notifier function
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>v</parameter></term>
   <listitem>
    <para>
     Pointer passed unmodified to notifier function
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   Calls each function in a notifier chain in turn.  The functions
   run in an undefined context.
   All locking must be provided by the caller.
   </para><para>

   If the return value of the notifier can be and'ed
   with <constant>NOTIFY_STOP_MASK</constant> then raw_notifier_call_chain
   will return immediately, with the return value of
   the notifier function which halted execution.
   Otherwise the return value is the return value
   of the last notifier function called.
</para>
</refsect1>
</refentry>

<refentry>
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>November 2007</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase id="API-register-reboot-notifier">register_reboot_notifier</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
</refmeta>
<refnamediv>
 <refname>register_reboot_notifier</refname>
 <refpurpose>
      Register function to be called at reboot time
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>int <function>register_reboot_notifier </function></funcdef>
   <paramdef>struct notifier_block * <parameter>nb</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>nb</parameter></term>
   <listitem>
    <para>
     Info about notifier function to be called
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   Registers a function with the list of functions
   to be called at reboot time.
   </para><para>

   Currently always returns zero, as blocking_notifier_chain_register
   always returns zero.
</para>
</refsect1>
</refentry>

<refentry>
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>November 2007</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase id="API-unregister-reboot-notifier">unregister_reboot_notifier</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
</refmeta>
<refnamediv>
 <refname>unregister_reboot_notifier</refname>
 <refpurpose>
      Unregister previously registered reboot notifier
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>int <function>unregister_reboot_notifier </function></funcdef>
   <paramdef>struct notifier_block * <parameter>nb</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>nb</parameter></term>
   <listitem>
    <para>
     Hook to be unregistered
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   Unregisters a previously registered reboot
   notifier function.
   </para><para>

   Returns zero on success, or <constant>-ENOENT</constant> on failure.
</para>
</refsect1>
</refentry>

<refentry>
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>November 2007</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase id="API-emergency-restart">emergency_restart</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
</refmeta>
<refnamediv>
 <refname>emergency_restart</refname>
 <refpurpose>
      reboot the system
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>void <function>emergency_restart </function></funcdef>
   <paramdef> <parameter>void</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>void</parameter></term>
   <listitem>
    <para>
     no arguments
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   </para><para>

   Without shutting down any hardware or taking any locks
   reboot the system.  This is called when we know we are in
   trouble so this is our best effort to reboot.  This is
   safe to call in interrupt context.
</para>
</refsect1>
</refentry>

<refentry>
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>November 2007</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase id="API-kernel-restart">kernel_restart</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
</refmeta>
<refnamediv>
 <refname>kernel_restart</refname>
 <refpurpose>
      reboot the system
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>void <function>kernel_restart </function></funcdef>
   <paramdef>char * <parameter>cmd</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>cmd</parameter></term>
   <listitem>
    <para>
     pointer to buffer containing command to execute for restart
     or <constant>NULL</constant>
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   Shutdown everything and perform a clean reboot.
   This is not safe to call in interrupt context.
</para>
</refsect1>
</refentry>

<refentry>
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>November 2007</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase id="API-kernel-kexec">kernel_kexec</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
</refmeta>
<refnamediv>
 <refname>kernel_kexec</refname>
 <refpurpose>
      reboot the system
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>void <function>kernel_kexec </function></funcdef>
   <paramdef> <parameter>void</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>void</parameter></term>
   <listitem>
    <para>
     no arguments
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   </para><para>

   Move into place and start executing a preloaded standalone
   executable.  If nothing was preloaded return an error.
</para>
</refsect1>
</refentry>

<refentry>
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>November 2007</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase id="API-kernel-halt">kernel_halt</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
</refmeta>
<refnamediv>
 <refname>kernel_halt</refname>
 <refpurpose>
      halt the system
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>void <function>kernel_halt </function></funcdef>
   <paramdef> <parameter>void</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>void</parameter></term>
   <listitem>
    <para>
     no arguments
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   </para><para>

   Shutdown everything and perform a clean system halt.
</para>
</refsect1>
</refentry>

<refentry>
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>November 2007</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase id="API-kernel-power-off">kernel_power_off</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
</refmeta>
<refnamediv>
 <refname>kernel_power_off</refname>
 <refpurpose>
      power_off the system
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>void <function>kernel_power_off </function></funcdef>
   <paramdef> <parameter>void</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>void</parameter></term>
   <listitem>
    <para>
     no arguments
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   </para><para>

   Shutdown everything and perform a clean system power_off.
</para>
</refsect1>
</refentry>

<!-- kernel/rcupdate.c -->
<refentry>
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>November 2007</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase id="API-call-rcu">call_rcu</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
</refmeta>
<refnamediv>
 <refname>call_rcu</refname>
 <refpurpose>
   Queue an RCU callback for invocation after a grace period.
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>void fastcall <function>call_rcu </function></funcdef>
   <paramdef>struct rcu_head * <parameter>head</parameter></paramdef>
   <paramdef>void (*<parameter>func</parameter>)
     <funcparams>struct rcu_head *rcu</funcparams></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>head</parameter></term>
   <listitem>
    <para>
     structure to be used for queueing the RCU updates.
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>func</parameter></term>
   <listitem>
    <para>
     actual update function to be invoked after the grace period
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   The update function will be invoked some time after a full grace
   period elapses, in other words after all currently executing RCU
   read-side critical sections have completed.  RCU read-side critical
   sections are delimited by <function>rcu_read_lock</function> and <function>rcu_read_unlock</function>,
   and may be nested.
</para>
</refsect1>
</refentry>

<refentry>
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>November 2007</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase id="API-call-rcu-bh">call_rcu_bh</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
</refmeta>
<refnamediv>
 <refname>call_rcu_bh</refname>
 <refpurpose>
      Queue an RCU for invocation after a quicker grace period.
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>void fastcall <function>call_rcu_bh </function></funcdef>
   <paramdef>struct rcu_head * <parameter>head</parameter></paramdef>
   <paramdef>void (*<parameter>func</parameter>)
     <funcparams>struct rcu_head *rcu</funcparams></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>head</parameter></term>
   <listitem>
    <para>
     structure to be used for queueing the RCU updates.
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>func</parameter></term>
   <listitem>
    <para>
     actual update function to be invoked after the grace period
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   The update function will be invoked some time after a full grace
   period elapses, in other words after all currently executing RCU
   read-side critical sections have completed. <function>call_rcu_bh</function> assumes
   that the read-side critical sections end on completion of a softirq
   handler. This means that read-side critical sections in process
   context must not be interrupted by softirqs. This interface is to be
   used when most of the read-side critical sections are in softirq context.
   RCU read-side critical sections are delimited by <function>rcu_read_lock</function> and
   <function>rcu_read_unlock</function>, * if in interrupt context or <function>rcu_read_lock_bh</function>
   and <function>rcu_read_unlock_bh</function>, if in process context. These may be nested.
</para>
</refsect1>
</refentry>

<refentry>
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>November 2007</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase id="API-rcu-barrier">rcu_barrier</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
</refmeta>
<refnamediv>
 <refname>rcu_barrier</refname>
 <refpurpose>
      Wait until all the in-flight RCUs are complete.
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>void <function>rcu_barrier </function></funcdef>
   <paramdef> <parameter>void</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>void</parameter></term>
   <listitem>
    <para>
     no arguments
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
</refentry>

<refentry>
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>November 2007</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase id="API-synchronize-rcu">synchronize_rcu</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
</refmeta>
<refnamediv>
 <refname>synchronize_rcu</refname>
 <refpurpose>
      wait until a grace period has elapsed.
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>void <function>synchronize_rcu </function></funcdef>
   <paramdef> <parameter>void</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>void</parameter></term>
   <listitem>
    <para>
     no arguments
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   </para><para>

   Control will return to the caller some time after a full grace
   period has elapsed, in other words after all currently executing RCU
   read-side critical sections have completed.  RCU read-side critical
   sections are delimited by <function>rcu_read_lock</function> and <function>rcu_read_unlock</function>,
   and may be nested.
   </para><para>

   If your read-side code is not protected by <function>rcu_read_lock</function>, do -not-
   use <function>synchronize_rcu</function>.
</para>
</refsect1>
</refentry>

     </sect1>

  </chapter>

  <chapter id="adt">
     <title>Data Types</title>
     <sect1><title>Doubly Linked Lists</title>
<!-- include/linux/list.h -->
<refentry>
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>November 2007</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase id="API-list-add">list_add</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
</refmeta>
<refnamediv>
 <refname>list_add</refname>
 <refpurpose>
   add a new entry
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>void <function>list_add </function></funcdef>
   <paramdef>struct list_head * <parameter>new</parameter></paramdef>
   <paramdef>struct list_head * <parameter>head</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>new</parameter></term>
   <listitem>
    <para>
     new entry to be added
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>head</parameter></term>
   <listitem>
    <para>
     list head to add it after
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   Insert a new entry after the specified head.
   This is good for implementing stacks.
</para>
</refsect1>
</refentry>

<refentry>
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>November 2007</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase id="API-list-add-tail">list_add_tail</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
</refmeta>
<refnamediv>
 <refname>list_add_tail</refname>
 <refpurpose>
      add a new entry
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>void <function>list_add_tail </function></funcdef>
   <paramdef>struct list_head * <parameter>new</parameter></paramdef>
   <paramdef>struct list_head * <parameter>head</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>new</parameter></term>
   <listitem>
    <para>
     new entry to be added
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>head</parameter></term>
   <listitem>
    <para>
     list head to add it before
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   Insert a new entry before the specified head.
   This is useful for implementing queues.
</para>
</refsect1>
</refentry>

<refentry>
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>November 2007</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase id="API-list-add-rcu">list_add_rcu</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
</refmeta>
<refnamediv>
 <refname>list_add_rcu</refname>
 <refpurpose>
      add a new entry to rcu-protected list
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>void <function>list_add_rcu </function></funcdef>
   <paramdef>struct list_head * <parameter>new</parameter></paramdef>
   <paramdef>struct list_head * <parameter>head</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>new</parameter></term>
   <listitem>
    <para>
     new entry to be added
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>head</parameter></term>
   <listitem>
    <para>
     list head to add it after
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   Insert a new entry after the specified head.
   This is good for implementing stacks.
   </para><para>

   The caller must take whatever precautions are necessary
   (such as holding appropriate locks) to avoid racing
   with another list-mutation primitive, such as <function>list_add_rcu</function>
   or <function>list_del_rcu</function>, running on this same list.
   However, it is perfectly legal to run concurrently with
   the _rcu list-traversal primitives, such as
   <function>list_for_each_entry_rcu</function>.
</para>
</refsect1>
</refentry>

<refentry>
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>November 2007</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase id="API-list-add-tail-rcu">list_add_tail_rcu</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
</refmeta>
<refnamediv>
 <refname>list_add_tail_rcu</refname>
 <refpurpose>
      add a new entry to rcu-protected list
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>void <function>list_add_tail_rcu </function></funcdef>
   <paramdef>struct list_head * <parameter>new</parameter></paramdef>
   <paramdef>struct list_head * <parameter>head</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>new</parameter></term>
   <listitem>
    <para>
     new entry to be added
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>head</parameter></term>
   <listitem>
    <para>
     list head to add it before
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   Insert a new entry before the specified head.
   This is useful for implementing queues.
   </para><para>

   The caller must take whatever precautions are necessary
   (such as holding appropriate locks) to avoid racing
   with another list-mutation primitive, such as <function>list_add_tail_rcu</function>
   or <function>list_del_rcu</function>, running on this same list.
   However, it is perfectly legal to run concurrently with
   the _rcu list-traversal primitives, such as
   <function>list_for_each_entry_rcu</function>.
</para>
</refsect1>
</refentry>

<refentry>
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>November 2007</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase id="API-list-del">list_del</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
</refmeta>
<refnamediv>
 <refname>list_del</refname>
 <refpurpose>
      deletes entry from list.
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>void <function>list_del </function></funcdef>
   <paramdef>struct list_head * <parameter>entry</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>entry</parameter></term>
   <listitem>
    <para>
     the element to delete from the list.
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Note</title>
<para>
   list_empty on entry does not return true after this, the entry is
   in an undefined state.
</para>
</refsect1>
</refentry>

<refentry>
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>November 2007</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase id="API-list-del-rcu">list_del_rcu</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
</refmeta>
<refnamediv>
 <refname>list_del_rcu</refname>
 <refpurpose>
      deletes entry from list without re-initialization
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>void <function>list_del_rcu </function></funcdef>
   <paramdef>struct list_head * <parameter>entry</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>entry</parameter></term>
   <listitem>
    <para>
     the element to delete from the list.
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Note</title>
<para>
   list_empty on entry does not return true after this,
   the entry is in an undefined state. It is useful for RCU based
   lockfree traversal.
   </para><para>

   In particular, it means that we can not poison the forward
   pointers that may still be used for walking the list.
   </para><para>

   The caller must take whatever precautions are necessary
   (such as holding appropriate locks) to avoid racing
   with another list-mutation primitive, such as <function>list_del_rcu</function>
   or <function>list_add_rcu</function>, running on this same list.
   However, it is perfectly legal to run concurrently with
   the _rcu list-traversal primitives, such as
   <function>list_for_each_entry_rcu</function>.
   </para><para>

   Note that the caller is not permitted to immediately free
   the newly deleted entry.  Instead, either <function>synchronize_rcu</function>
   or <function>call_rcu</function> must be used to defer freeing until an RCU
   grace period has elapsed.
</para>
</refsect1>
</refentry>

<refentry>
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>November 2007</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase id="API-list-del-init">list_del_init</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
</refmeta>
<refnamediv>
 <refname>list_del_init</refname>
 <refpurpose>
      deletes entry from list and reinitialize it.
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>void <function>list_del_init </function></funcdef>
   <paramdef>struct list_head * <parameter>entry</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>entry</parameter></term>
   <listitem>
    <para>
     the element to delete from the list.
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
</refentry>

<refentry>
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>November 2007</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase id="API-list-move">list_move</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
</refmeta>
<refnamediv>
 <refname>list_move</refname>
 <refpurpose>
      delete from one list and add as another's head
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>void <function>list_move </function></funcdef>
   <paramdef>struct list_head * <parameter>list</parameter></paramdef>
   <paramdef>struct list_head * <parameter>head</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>list</parameter></term>
   <listitem>
    <para>
     the entry to move
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>head</parameter></term>
   <listitem>
    <para>
     the head that will precede our entry
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
</refentry>

<refentry>
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>November 2007</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase id="API-list-move-tail">list_move_tail</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
</refmeta>
<refnamediv>
 <refname>list_move_tail</refname>
 <refpurpose>
      delete from one list and add as another's tail
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>void <function>list_move_tail </function></funcdef>
   <paramdef>struct list_head * <parameter>list</parameter></paramdef>
   <paramdef>struct list_head * <parameter>head</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>list</parameter></term>
   <listitem>
    <para>
     the entry to move
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>head</parameter></term>
   <listitem>
    <para>
     the head that will follow our entry
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
</refentry>

<refentry>
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>November 2007</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase id="API-list-empty">list_empty</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
</refmeta>
<refnamediv>
 <refname>list_empty</refname>
 <refpurpose>
      tests whether a list is empty
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>int <function>list_empty </function></funcdef>
   <paramdef>const struct list_head * <parameter>head</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>head</parameter></term>
   <listitem>
    <para>
     the list to test.
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
</refentry>

<refentry>
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>November 2007</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase id="API-list-empty-careful">list_empty_careful</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
</refmeta>
<refnamediv>
 <refname>list_empty_careful</refname>
 <refpurpose>
      tests whether a list is
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>int <function>list_empty_careful </function></funcdef>
   <paramdef>const struct list_head * <parameter>head</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>head</parameter></term>
   <listitem>
    <para>
     the list to test.
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   empty _and_ checks that no other CPU might be
   in the process of still modifying either member
</para>
</refsect1>
<refsect1>
<title>NOTE</title>
<para>
   using <function>list_empty_careful</function> without synchronization
   can only be safe if the only activity that can happen
   to the list entry is <function>list_del_init</function>. Eg. it cannot be used
   if another CPU could re-<function>list_add</function> it.
</para>
</refsect1>
</refentry>

<refentry>
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>November 2007</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase id="API-list-splice">list_splice</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
</refmeta>
<refnamediv>
 <refname>list_splice</refname>
 <refpurpose>
      join two lists
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>void <function>list_splice </function></funcdef>
   <paramdef>struct list_head * <parameter>list</parameter></paramdef>
   <paramdef>struct list_head * <parameter>head</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>list</parameter></term>
   <listitem>
    <para>
     the new list to add.
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>head</parameter></term>
   <listitem>
    <para>
     the place to add it in the first list.
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
</refentry>

<refentry>
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>November 2007</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase id="API-list-splice-init">list_splice_init</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
</refmeta>
<refnamediv>
 <refname>list_splice_init</refname>
 <refpurpose>
      join two lists and reinitialise the emptied list.
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>void <function>list_splice_init </function></funcdef>
   <paramdef>struct list_head * <parameter>list</parameter></paramdef>
   <paramdef>struct list_head * <parameter>head</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>list</parameter></term>
   <listitem>
    <para>
     the new list to add.
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>head</parameter></term>
   <listitem>
    <para>
     the place to add it in the first list.
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   The list at <parameter>list</parameter> is reinitialised
</para>
</refsect1>
</refentry>

<refentry>
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>November 2007</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase id="API-list-entry">list_entry</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
</refmeta>
<refnamediv>
 <refname>list_entry</refname>
 <refpurpose>
      get the struct for this entry
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef> <function>list_entry </function></funcdef>
   <paramdef> <parameter>ptr</parameter></paramdef>
   <paramdef> <parameter>type</parameter></paramdef>
   <paramdef> <parameter>member</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>ptr</parameter></term>
   <listitem>
    <para>
     	the &amp;struct list_head pointer.
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>type</parameter></term>
   <listitem>
    <para>
     	the type of the struct this is embedded in.
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>member</parameter></term>
   <listitem>
    <para>
     	the name of the list_struct within the struct.
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
</refentry>

<refentry>
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>November 2007</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase id="API-list-for-each">list_for_each</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
</refmeta>
<refnamediv>
 <refname>list_for_each</refname>
 <refpurpose>
     	iterate over a list
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef> <function>list_for_each </function></funcdef>
   <paramdef> <parameter>pos</parameter></paramdef>
   <paramdef> <parameter>head</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>pos</parameter></term>
   <listitem>
    <para>
     	the &amp;struct list_head to use as a loop counter.
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>head</parameter></term>
   <listitem>
    <para>
     	the head for your list.
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
</refentry>

<refentry>
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>November 2007</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase id="API---list-for-each">__list_for_each</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
</refmeta>
<refnamediv>
 <refname>__list_for_each</refname>
 <refpurpose>
     	iterate over a list
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef> <function>__list_for_each </function></funcdef>
   <paramdef> <parameter>pos</parameter></paramdef>
   <paramdef> <parameter>head</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>pos</parameter></term>
   <listitem>
    <para>
     	the &amp;struct list_head to use as a loop counter.
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>head</parameter></term>
   <listitem>
    <para>
     	the head for your list.
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   This variant differs from <function>list_for_each</function> in that it's the
   simplest possible list iteration code, no prefetching is done.
   Use this for code that knows the list to be very short (empty
   or 1 entry) most of the time.
</para>
</refsect1>
</refentry>

<refentry>
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>November 2007</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase id="API-list-for-each-prev">list_for_each_prev</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
</refmeta>
<refnamediv>
 <refname>list_for_each_prev</refname>
 <refpurpose>
     	iterate over a list backwards
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef> <function>list_for_each_prev </function></funcdef>
   <paramdef> <parameter>pos</parameter></paramdef>
   <paramdef> <parameter>head</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>pos</parameter></term>
   <listitem>
    <para>
     	the &amp;struct list_head to use as a loop counter.
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>head</parameter></term>
   <listitem>
    <para>
     	the head for your list.
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
</refentry>

<refentry>
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>November 2007</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase id="API-list-for-each-safe">list_for_each_safe</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
</refmeta>
<refnamediv>
 <refname>list_for_each_safe</refname>
 <refpurpose>
     	iterate over a list safe against removal of list entry
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef> <function>list_for_each_safe </function></funcdef>
   <paramdef> <parameter>pos</parameter></paramdef>
   <paramdef> <parameter>n</parameter></paramdef>
   <paramdef> <parameter>head</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>pos</parameter></term>
   <listitem>
    <para>
     	the &amp;struct list_head to use as a loop counter.
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>n</parameter></term>
   <listitem>
    <para>
     		another &amp;struct list_head to use as temporary storage
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>head</parameter></term>
   <listitem>
    <para>
     	the head for your list.
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
</refentry>

<refentry>
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>November 2007</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase id="API-list-for-each-entry">list_for_each_entry</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
</refmeta>
<refnamediv>
 <refname>list_for_each_entry</refname>
 <refpurpose>
     	iterate over list of given type
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef> <function>list_for_each_entry </function></funcdef>
   <paramdef> <parameter>pos</parameter></paramdef>
   <paramdef> <parameter>head</parameter></paramdef>
   <paramdef> <parameter>member</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>pos</par