<br><br><div class="gmail_quote">On Sat, Feb 9, 2013 at 4:20 PM, Peter Teoh <span dir="ltr">&lt;<a href="mailto:htmldeveloper@gmail.com" target="_blank">htmldeveloper@gmail.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br><br><div class="gmail_quote"><div><div class="h5">On Sat, Feb 9, 2013 at 3:51 PM, anish kumar <span dir="ltr">&lt;<a href="mailto:anish198519851985@gmail.com" target="_blank">anish198519851985@gmail.com</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div><div>On Sat, 2013-02-09 at 14:57 +0800, Peter Teoh wrote:<br>
&gt;<br>
&gt;<br>
&gt; On Sat, Feb 9, 2013 at 1:47 PM, anish kumar<br>
&gt; .<br>
&gt;         Timer interrupts is supposed to cause scheduling and scheduler<br>
&gt;         may or<br>
&gt;         may not pick up your last process(we always use the term<br>
&gt;         &quot;task&quot; in<br>
&gt;         kernel space) after handling timer interrupt.<br>
&gt;         &gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt; Sorry if I may disagree, correct me if wrong.   Timer interrupt and<br>
&gt; scheduler is two different thing.   I just counted in the &quot;drivers&quot;<br>
&gt; subdirectory, there are at least more than 200 places where<br>
&gt; &quot;setup_timer()&quot; is called, and these have nothing to do with<br>
&gt; scheduling.   For eg, heartbeat operation etc.  Not sure I<br>
&gt; misunderstood something?<br>
</div></div>Have a look at kernel/timer.c and kernel/hrtimer.c.<br>
There are many sched() calls in these files.This will invoke scheduler.<br>
&gt;<br></blockquote><div><br></div></div></div><div>kernel/timer.c and kernel/hrtimer.c are implementing the logic outside of timer interrupt context, ie, it is NOT executed in timer interrupt context, but in bottom half context.   the real timer interrupt context is done in arch-specific branch:  arch/x86/kernel/tsc.c, for example, and the entire tsc.c has no scheduling concept in it.   the entire file tsc.c in fact is handling all the hardware-specific stuff - in the top-half context.   </div>
</div></blockquote><div><br></div><div>one mistake here:  kernel/timer.c is running in bottom half interrupt context, which is still in interrupt context/mode.    but as I glanced through the entire kernel/timer.c, there is no task scheduling called anywhere in this file.   it is doing timer scheduling in fact.   whereas the context switching we were discussing, that necessitate consistent state maintenance, is done in task scheduling (inside kernel/sched.c).   of course sometimes timer interrupt will trigger task scheduling logic sometime, but it is not always......not sure if my statement is correct?   (no time to search the source, please pardon me).</div>
<div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="gmail_quote">
<div><br></div><div>in linux kernel scheduling is done in two ways:  voluntary and involuntary scheduling.   involuntary scheduling means it is triggered by timer interrupt.   but voluntary scheduling (which is only recently introduced into kernel for performance reasons) drastically improve the latency numbers.    voluntary scheduling is NOT triggered by timer, but ANYONE who want to give up the CPU can call sched_cpu() to do a rescheduling.</div>

<div><br></div><div>hope i am not wrong.....</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<span><font color="#888888">&gt;<br>
&gt; --<br>
&gt; Regards,<br>
&gt; Peter Teoh<br>
<br>
<br><span class="HOEnZb"><font color="#888888">
</font></span></font></span></blockquote></div><span class="HOEnZb"><font color="#888888"><br><br clear="all"><div><br></div>-- <br>Regards,<br>Peter Teoh
</font></span></blockquote></div><br><br clear="all"><div><br></div>-- <br>Regards,<br>Peter Teoh