Kernel code interrupted by Timer

Peter Teoh htmldeveloper at gmail.com
Sat Feb 9 03:20:08 EST 2013


On Sat, Feb 9, 2013 at 3:51 PM, anish kumar <anish198519851985 at gmail.com>wrote:

> On Sat, 2013-02-09 at 14:57 +0800, Peter Teoh wrote:
> >
> >
> > On Sat, Feb 9, 2013 at 1:47 PM, anish kumar
> > .
> >         Timer interrupts is supposed to cause scheduling and scheduler
> >         may or
> >         may not pick up your last process(we always use the term
> >         "task" in
> >         kernel space) after handling timer interrupt.
> >         >
> >
> >
> >
> > Sorry if I may disagree, correct me if wrong.   Timer interrupt and
> > scheduler is two different thing.   I just counted in the "drivers"
> > subdirectory, there are at least more than 200 places where
> > "setup_timer()" is called, and these have nothing to do with
> > scheduling.   For eg, heartbeat operation etc.  Not sure I
> > misunderstood something?
> Have a look at kernel/timer.c and kernel/hrtimer.c.
> There are many sched() calls in these files.This will invoke scheduler.
> >
>

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.

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.

hope i am not wrong.....


> >
> > --
> > Regards,
> > Peter Teoh
>
>
>


-- 
Regards,
Peter Teoh
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.kernelnewbies.org/pipermail/kernelnewbies/attachments/20130209/339379fd/attachment.html 


More information about the Kernelnewbies mailing list