LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Kernel (https://www.linuxquestions.org/questions/linux-kernel-70/)
-   -   Linux Scheduler (https://www.linuxquestions.org/questions/linux-kernel-70/linux-scheduler-524751/)

tbui57 02-01-2007 02:17 PM

Linux Scheduler
 
I found out that the linux schedule() is called on every system call. I also thought that the tick timer interrupt should invoke the schedule() ?

I trace the linux kernel code but could not find any where the schedule is called from the tick timer interrupt.

I am sure there are some one with linux kernel knowledge, please help.

Thanks in advance,
Tung

nx5000 02-02-2007 03:18 AM

Its called from sched.c, rtc.c, rtc-dev.c, signal.c, processor.c, mutex.c, semaphore.c, idle.c, genrtc.c, hpet.c and probably in 50 other files.

sundialsvcs 02-03-2007 10:27 PM

When a timer interrupt happens, it cannot immediately call schedule() because, at that moment, it is still in an interrupt-handler context.

What it does, instead, is to set the NEEDS_RESCHEDULE flag. This flag is checked when we are otherwise ready to return to user mode.

Generally speaking, any interrupt-handler is divided into what is casually called the top half and the bottom half. (While these terms were literally used as the names of now-deprecated mechanisms in the kernel itself, the essential notion denoted by terms such as these, remains useful: interrupt processing occurs in two stages.) Conceptually, "the top half" is the immediate and very-brief response to the actual hardware signal, but almost all that we actually do at that time is to arrange for the "real" interrupt response to occur "soon." That work is done in "the bottom half."

For example, a timer-interrupt will cause the current process to be pre-empted "soon." It may cause task-queues, tasklets, or other deferred-execution units-of-work to become "runnable," so that they will occur "soon." An I/O interrupt's top-half handler will scoop status-information from the controller's registers, then schedule the bottom-half, which is where the consequences of the data-transfer that has just happened will be dealt with.

studioj 02-04-2007 12:37 PM

yea a scheduling slice is/can be larger than timer ticks so there is also p->counter
leading to p->need_resched
timeslice is dynamically calculated based on priorities i think and different people run ticks of different frequencies for various reasons.


All times are GMT -5. The time now is 04:05 AM.