Sophie

Sophie

distrib > Mandriva > 9.0 > i586 > by-pkgid > 98e91bc877e03cf3582cd163550eb7e3 > files > 590

kernel-doc-html-2.4.19-16mdk.i586.rpm

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN">
<HTML
><HEAD
><TITLE
>Queuing</TITLE
><META
NAME="GENERATOR"
CONTENT="Modular DocBook HTML Stylesheet Version 1.7"><LINK
REL="HOME"
TITLE="Unreliable Guide To Hacking The Linux Kernel"
HREF="book1.html"><LINK
REL="UP"
TITLE="Wait Queues
   include/linux/wait.h
  "
HREF="c325.html"><LINK
REL="PREVIOUS"
TITLE="Wait Queues
   include/linux/wait.h
  "
HREF="c325.html"><LINK
REL="NEXT"
TITLE="Waking Up Queued Tasks"
HREF="x353.html"></HEAD
><BODY
CLASS="SECT1"
BGCOLOR="#FFFFFF"
TEXT="#000000"
LINK="#0000FF"
VLINK="#840084"
ALINK="#0000FF"
><DIV
CLASS="NAVHEADER"
><TABLE
SUMMARY="Header navigation table"
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
><TR
><TH
COLSPAN="3"
ALIGN="center"
>Unreliable Guide To Hacking The Linux Kernel</TH
></TR
><TR
><TD
WIDTH="10%"
ALIGN="left"
VALIGN="bottom"
><A
HREF="c325.html"
ACCESSKEY="P"
>&#60;&#60;&#60; Previous</A
></TD
><TD
WIDTH="80%"
ALIGN="center"
VALIGN="bottom"
>Wait Queues
   <TT
CLASS="FILENAME"
>include/linux/wait.h</TT
></TD
><TD
WIDTH="10%"
ALIGN="right"
VALIGN="bottom"
><A
HREF="x353.html"
ACCESSKEY="N"
>Next &#62;&#62;&#62;</A
></TD
></TR
></TABLE
><HR
ALIGN="LEFT"
WIDTH="100%"></DIV
><DIV
CLASS="SECT1"
><H1
CLASS="SECT1"
><A
NAME="QUEUE-WAITQUEUE"
></A
>Queuing</H1
><P
>    Placing yourself in the waitqueue is fairly complex, because you
    must put yourself in the queue before checking the condition.
    There is a macro to do this:
    <TT
CLASS="FUNCTION"
>wait_event_interruptible()</TT
>

    <TT
CLASS="FILENAME"
>include/linux/sched.h</TT
> The
    first argument is the wait queue head, and the second is an
    expression which is evaluated; the macro returns
    <SPAN
CLASS="RETURNVALUE"
>0</SPAN
> when this expression is true, or
    <SPAN
CLASS="RETURNVALUE"
>-ERESTARTSYS</SPAN
> if a signal is received.
    The <TT
CLASS="FUNCTION"
>wait_event()</TT
> version ignores signals.
   </P
><P
>   Do not use the <TT
CLASS="FUNCTION"
>sleep_on()</TT
> function family -
   it is very easy to accidentally introduce races; almost certainly
   one of the <TT
CLASS="FUNCTION"
>wait_event()</TT
> family will do, or a
   loop around <TT
CLASS="FUNCTION"
>schedule_timeout()</TT
>. If you choose
   to loop around <TT
CLASS="FUNCTION"
>schedule_timeout()</TT
> remember
   you must set the task state (with 
   <TT
CLASS="FUNCTION"
>set_current_state()</TT
>) on each iteration to avoid
   busy-looping.
   </P
></DIV
><DIV
CLASS="NAVFOOTER"
><HR
ALIGN="LEFT"
WIDTH="100%"><TABLE
SUMMARY="Footer navigation table"
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
><A
HREF="c325.html"
ACCESSKEY="P"
>&#60;&#60;&#60; Previous</A
></TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
><A
HREF="book1.html"
ACCESSKEY="H"
>Home</A
></TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
><A
HREF="x353.html"
ACCESSKEY="N"
>Next &#62;&#62;&#62;</A
></TD
></TR
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
>Wait Queues
   <TT
CLASS="FILENAME"
>include/linux/wait.h</TT
></TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
><A
HREF="c325.html"
ACCESSKEY="U"
>Up</A
></TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
>Waking Up Queued Tasks</TD
></TR
></TABLE
></DIV
></BODY
></HTML
>