<p></p>
<p>Sent from my Sony Xperia™ smartphone<br>
On Dec 25, 2013 4:16 PM, &quot;Pranay Srivastava&quot; &lt;<a href="mailto:pranjas@gmail.com">pranjas@gmail.com</a>&gt; wrote:<br>
&gt;<br>
&gt; Hi santosh<br>
&gt;<br>
&gt; I hope you understand difference between semaphores and spin locks.<br>
&gt;</p>
<p>Ya I am completely aware of sleeping locks n spin locks <br>
&gt; If however you are stuck a situation where you can afford being preempted then you can use sem/mutex. But i think your serialization requires that you use spin locks then best is to have a guarded variable with spin lock and release the lock before you schedule.<br>

&gt;</p>
<p>I just wanted to verify if it was possible n if yes considering preemption is disabled..<br>
&gt; Even if you set the state preempt count would be increased when you acquire spin lock. so you Cant schedule or go to sleep after spin lock.<br>
&gt;</p>
<p>Since schedule_timout would make sure the task remains on the run queue and intended to be scheduled back after the specificed jeffies period. It was just out of curiosity anyway .Thanks !!!</p>
<p>&gt; Regards<br>
&gt;<br>
&gt; On Dec 25, 2013 3:36 PM, &quot;SaNtosh kuLkarni&quot; &lt;<a href="mailto:santosh.yesoptus@gmail.com">santosh.yesoptus@gmail.com</a>&gt; wrote:<br>
&gt;&gt;<br>
&gt;&gt; Hi,<br>
&gt;&gt;<br>
&gt;&gt; I wanted to verify/clarify if using schedule_timeout after acquiring a spinlock is safe?. So basically you have a situation where you are working on a critical code and you acquire a spin lock and you end up using a schedule_timeout after say setting the current task to Interruptible state &#39;cause you are waiting for some user space code to fill in some buffer from which you want to read.<br>

&gt;&gt; So my doubt is simple, is it safe to acquire a spinlock and use schedule_timeout.<br>
&gt;&gt; I assume the task is put in the run queue and will &quot;ALWAYS&quot; be scheduled back after the specified delay in schedule_timeout.<br>
&gt;&gt;<br>
&gt;&gt; -- <br>
&gt;&gt; Regards,<br>
&gt;&gt; Santosh<br>
&gt;&gt;<br>
&gt;&gt; _______________________________________________<br>
&gt;&gt; Kernelnewbies mailing list<br>
&gt;&gt; <a href="mailto:Kernelnewbies@kernelnewbies.org">Kernelnewbies@kernelnewbies.org</a><br>
&gt;&gt; <a href="http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies">http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies</a><br>
&gt;&gt;<br>
</p>