On Sat, 27 Aug 2005, Sat. wrote:Actually, this is not completly true. The kernel sets a flag while handling interrupts that says it is within an interrupt. This flag is cleared on the way out of the interrupt but prior to the return from interrupt (rfi) instruction. Between this flag clearing and the rfi, there is a check made to see if the kernel is preemptable and, if so, if it is desired (i.e. something more important should run NOW). If both of these are true, schedule is called to do the context switch. So, schedule IS called from within the interrupt, but NOT within the area the kernel flags as being in an interrupt which is a subset of the actual interrupt.
2005/8/27, Christopher Friesen <cfriesen@xxxxxxxxxx>:
Sat. wrote:
the case about kernel preemption as follow :
the book said "when a process that has a higher priority than the
currenty running process is awakened ".
but I can think about when such case can occur , could you give me an example ?
There may be others, but one common case is when a hardware interrupt
causes the higher priority process to become runnable. Some examples of
this would be a network packet arriving, or the expiry of a hardware timer.
Chris
unfortunately, I cannot agree with you , normally ,when the kernel
runs in interrupt context , the schedule() should not be invoked
------my views .
then,could anyone give me a definite example about network like above
or anything else to eluminate this , ok?
thanks !
--
Sat.
Schedule is never executed from an interrupt, BUT, there may be
kernel threads or even user tasks that are sleeping, waiting
to be awakened when some preliminary interrupt processing has
occurred. The interrupt code may execute one of the wake-up calls
which will cause the target to be put into the run queue as soon
as possible.