I want to understand the interrupt mechanism when a processor yields a chance to kernel code and to perform maintenance and regulation work. What I know is that timer interrupt provides this facility to OS.
1) What I want to know what exactly is the related interrupt number and what is the first OS routine that gets called in case of Linux. Will be good if I get to know the file and function name for this.
In case of Linux, scheduler_tick is the kernel function that is called to schedule new tasks, however what is unknown is who calls scheduler_tick and its parent(s)?
2) Are there any other interrupts as well which call scheduler_tick in Linux ? Which ones are they, if any at all?
/*
This function gets called by the timer code, with HZ frequency.
We call it with interrupts disabled.
*/
void scheduler_tick(void)
{
int cpu = smp_processor_id();
struct rq *rq = cpu_rq(cpu);
struct task_struct *curr = rq->curr;
.......
This is easy to answer when you have access to cross-reference (x-ref) source browser.
Click here: http://lxr.linux.no/#linux+v3.6.3/kernel/sched/core.c#L3214 to get one online x-ref project of Linux Kernel. (This one will not x-ref assembler code.)
This link goes to
scheduler_tickfunction definition. Click on the function name, then in new panel at right select after the line “Function prototype or declaration” link “usage…”. After some time all code which mentions this function will be listed:So, timer.c: 1373 http://lxr.linux.no/#linux+v3.6.3/kernel/timer.c#L1373 is part of
update_process_timesfunction:This function is only callable from timer interrupt handler; it should be called at every tick.
Repeat cross-reference search process for
update_process_timesto get list:Interrupt numbers are platform-dependent (and sometimes they are even assigned at boot time). You didn’t say what platform you are interested in.
There are several timer implementations, including hrtimers (high-resolution timer, this can be different from usual system timer). Each implementation may use different interrupt.