On Wed, Apr 16, 2008 at 12:22 PM, shyam Burkule <shyam.burkule@xxxxxxxxx> wrote: > > I was reading about schedular.. i have following question.. > > Who schedule the schedular? I mean , let linux uses round-robin scheduling > policy, with some time slice say 'x'. So process can run upto x time slice > and if not finished it is preemted and schedular schedule another process to > run. So my question is that, how kernel comes to know that time slice > expire and now preempt the current process? (I think kernel might be > decrementing time slice,but when this happen,because in uniprocessor system > , CPU is currently assigned to running process.) > > Thanks > Shyam http://kerneltrap.org/node/6750 http://lwn.net/Articles/223185/ (i answered this recently in kerneltrap, so just cut and paste here, no copyright issue :-)) What triggers scheduling - timer, yes, but in the recent "tickless" kernel option, the timer-based interrupt was removed - specifically during idle time, and with the ongoing effort for removal during non-idle time as well (has it been done?). the logic is that by inserting "schedule()" nicely everywhere, the CPU can be made to voluntarily surrender itself for another task on the taskqueue. indeed, if u just search for the keyword "schedule()" u can find it occurring everywhere. Or just in the mm sub-branch, "cond_resched()" (many variation on this scheduling function exists) occurred many times....just grep yourself. but note that these voluntary scheduling of CPU occurred whether u have tickless kernel or not. so who schedule the scheduler? i think answer is EVERYBODY.....the symbol can be found almost every where. Am I understanding it correctly? Userspace API like pthread (part of POSIX specification) will allow u to do thread scheduling as well. That area is unknown to me. but the implementation is not easy (Solaris, in 2004 Usenix, when they presented their redesign/implementation of the pthread from many-to-one to one-to-one user-kernel threads mapping, managed to cut down 50% of the code - about 200K lines long). -- Regards, Peter Teoh -- To unsubscribe from this list: send an email with "unsubscribe kernelnewbies" to ecartis@xxxxxxxxxxxx Please read the FAQ at http://kernelnewbies.org/FAQ