1<html><head><meta http-equiv="Content-Type" content="text/html; charset=ANSI_X3.4-1968"><title>Chapter 7. Wait Queues include/linux/wait.h</title><meta name="generator" content="DocBook XSL Stylesheets V1.78.1"><link rel="home" href="index.html" title="Unreliable Guide To Hacking The Linux Kernel"><link rel="up" href="index.html" title="Unreliable Guide To Hacking The Linux Kernel"><link rel="prev" href="routines-module-use-counters.html" title="try_module_get()/module_put() include/linux/module.h"><link rel="next" href="queue-waitqueue.html" title="Queuing"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">Chapter 7. Wait Queues 2 <code class="filename">include/linux/wait.h</code> 3 </th></tr><tr><td width="20%" align="left"><a accesskey="p" href="routines-module-use-counters.html">Prev</a> </td><th width="60%" align="center"> </th><td width="20%" align="right"> <a accesskey="n" href="queue-waitqueue.html">Next</a></td></tr></table><hr></div><div class="chapter"><div class="titlepage"><div><div><h1 class="title"><a name="queues"></a>Chapter 7. Wait Queues 4 <code class="filename">include/linux/wait.h</code> 5 </h1></div></div></div><div class="toc"><p><b>Table of Contents</b></p><dl class="toc"><dt><span class="sect1"><a href="queues.html#queue-declaring">Declaring</a></span></dt><dt><span class="sect1"><a href="queue-waitqueue.html">Queuing</a></span></dt><dt><span class="sect1"><a href="queue-waking.html">Waking Up Queued Tasks</a></span></dt></dl></div><p> 6 <span class="emphasis"><em>[SLEEPS]</em></span> 7 </p><p> 8 A wait queue is used to wait for someone to wake you up when a 9 certain condition is true. They must be used carefully to ensure 10 there is no race condition. You declare a 11 <span class="type">wait_queue_head_t</span>, and then processes which want to 12 wait for that condition declare a <span class="type">wait_queue_t</span> 13 referring to themselves, and place that in the queue. 14 </p><div class="sect1"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="queue-declaring"></a>Declaring</h2></div></div></div><p> 15 You declare a <span class="type">wait_queue_head_t</span> using the 16 <code class="function">DECLARE_WAIT_QUEUE_HEAD()</code> macro, or using the 17 <code class="function">init_waitqueue_head()</code> routine in your 18 initialization code. 19 </p></div></div><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="routines-module-use-counters.html">Prev</a> </td><td width="20%" align="center"> </td><td width="40%" align="right"> <a accesskey="n" href="queue-waitqueue.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top"> <code class="function">try_module_get()</code>/<code class="function">module_put()</code> 20 <code class="filename">include/linux/module.h</code> </td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top"> Queuing</td></tr></table></div></body></html> 21