<br><br><div class="gmail_quote">On Tue, Feb 22, 2011 at 3:20 PM, Dave Hylands <span dir="ltr">&lt;<a href="mailto:dhylands@gmail.com">dhylands@gmail.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
Hi Subin,<br>
<div><div></div><div class="h5"><br>
On Tue, Feb 22, 2011 at 4:00 PM, subin gangadharan<br>
&lt;<a href="mailto:subingangadharan@gmail.com">subingangadharan@gmail.com</a>&gt; wrote:<br>
&gt; Hi All,<br>
&gt; I am trying to understand how to use mutex API&#39;s properly,so while going<br>
&gt; through the documentation,<br>
&gt; there is section mentioning fast path and slow path for mutexes.<br>
&gt; For your reference I am pasting this here.(kernel/mutex.c)<br>
&gt; /*<br>
&gt;  * We split the mutex lock/unlock logic into separate fastpath and<br>
&gt;  * slowpath functions, to reduce the register pressure on the fastpath.<br>
&gt;  * We also put the fastpath first in the kernel image, to make sure the<br>
&gt;  * branch is predicted by the CPU as default-untaken.<br>
&gt;  */<br>
&gt; static __used noinline void __sched<br>
&gt; __mutex_lock_slowpath(atomic_t *lock_count);<br>
&gt;<br>
&gt; Can someone help me to understand what is the difference between fastpath<br>
&gt; lock and slowpath lock?<br>
<br>
</div></div>The fastpath is taken when nobody else is holding the lock (so the<br>
caller acquires the mutex without blocking).<br>
<br>
The slowpath is taken when somebody else is holding the lock and the<br>
caller needs to block (i.e. sleep) until the mutex is released.<br>
<font color="#888888"><br></font></blockquote><div>Thanks David.<br>Could you give a bit more idea on the &quot;How this reduce the register pressure on fast path&quot;<br></div><div> </div><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
<font color="#888888">
Dave Hyland<br></font></blockquote><div> </div></div><br><br clear="all"><br>-- <br>With Regards<br>Subin Gangadharan<br><br><div>Everything should be made as simple as possible,but not simpler.</div><br>