<p>Hi, <span style="background-color: rgb(242, 242, 242);">Raghavendra, </span><span style="line-height: 20px; background-color: rgb(245, 245, 245);"><font face="Arial">pranjas:</font></span></p><p><span style="line-height: 20px; background-color: rgb(245, 245, 245);"><font face="Arial"><br></font></span></p><p>Thanks for your reply, <span style="background-color: rgb(214, 212, 213);">add_wait_queue_exclusive()</span> is perfect.</p><p><br></p><div id="origbody"><div style="background: #f2f2f2;">----- 原始邮件 -----<br>发件人:Raghavendra <arrao@cdac.in><br>收件人:kernelnewbies@kernelnewbies.org<br>主题:Re: How can I wake up one process from the wait queue?<br>日期:2014年10月30日 16点52分<br></div><br>
<div class="">On Thursday 30 October 2014 02:02 PM,
Rock Lee wrote:<br>
</div>
<blockquote cite="mid:20141030083210.11B81838001@webmail.sinamail.sina.com.cn" type="cite">
<p>Hi, everyone</p>
<p>I am implementing a simple driver to experiment with wait
queue.Two or more read processes block until a write process
changes a flag and call <span style="background-color: rgb(214,
212, 213);">wake_up_interruptible()</span>.I expect that a
write process will only wake up one read process.However, once a
write process calls <span style="background-color: rgb(214,
212, 213);">wake_up_interruptible()</span><span style="background-color: rgb(255, 255, 255);"> , all the read
processes are awaken. </span>How can I wake up one process
from the wait queue?<br>
</p>
</blockquote>
You can use exclusive wait queues, which wakes up only one process
from the queue.<br>
<br>
Although the general idea that is followed is: all the process are
woken up once the resource is made available. And then the access to
that resource is guarded by a lock, which in turn allows only one
process to access the resource. Rest of the processes are pushed
backed to sleep(or busy wait).<br>
<br>-------------------------------------------------------------------------------------------------------------------------------
<br><br></div>