Skip to contentSkip to conversation

when or where can the case occur in "linux kernel development " about "kernel preemption"?

DISCUSSION Sat. 5 participants 6 messages Aug 26, 2005 – Aug 29, 2005

lore
Share & tools
lore

Sat.

author
#0 lore raw

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 ?

thanks and any help will be appreciated!

Signature · 1 line
Sat.
#1 lore raw
Quoted 6 lines · Sat.

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

author
#2 lore raw

2005/8/27, Christopher Friesen <[email protected]>:

Quoted 6 lines
Quoted 5 lines · Sat.

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 ".

Quoted 8 lines
Quoted 1 line

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 !

Signature · 1 line
Sat.
#3 lore raw
Quoted 13 lines · Sat.

2005/8/27, Christopher Friesen <[email protected]>:

Quoted 12 lines
Quoted 6 lines · Sat.

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.

Quoted 7 lines
Quoted 2 lines

Chris

unfortunately, I cannot agree with you , normally ,when the kernel runs in interrupt context , the schedule() should not be invoked ------my views .

Its not actually the interrupt handler which calls the schedule() function, rather interrupt handler just perform the minimal task, like copying the data from network card buffer to kernel buffer in case of packet arriving on system. Its the other function which actually interrut handler schedules for later invocation and this later invocation is done in process context and so the function scheduled for later invocation can wake the waiting processes and can call schedule() function if needed.

I hope I am not wrong ;-)
-Gaurav

Quoted 13 lines

then,could anyone give me a definite example about network like above or anything else to eluminate this , ok?

thanks !

--
Sat.
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

#4 lore raw
In reply to Sat.
Quoted 20 lines · Sat.

2005/8/27, Christopher Friesen <[email protected]>:

Quoted 6 lines
Quoted 5 lines · Sat.

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 ".

Quoted 8 lines
Quoted 1 line

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 .

Quoted 7 lines

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.

Cheers,
Dick Johnson
Penguin : Linux version 2.6.12.5 on an i686 machine (5537.79 BogoMips). Warning : 98.36% of all statistics are fiction.
.
I apologize for the following. I tried to kill it with the above dot :

****************************************************************
The information transmitted in this message is confidential and may be privileged. Any review, retransmission, dissemination, or other use of this information by persons or entities other than the intended recipient is prohibited. If you are not the intended recipient, please notify Analogic Corporation immediately - by replying to this message or by sending an email to [email protected] - and destroy all copies of this information, including any attachments, without reading or disclosing them.

Thank you.

#5 lore raw
Quoted 36 lines · linux-os (Dick Johnson)
Quoted 25 lines · Sat.

2005/8/27, Christopher Friesen <[email protected]>:

Quoted 7 lines
Quoted 5 lines · Sat.

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 ".

Quoted 8 lines
Quoted 1 line

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?

Quoted 6 lines

thanks !

--

Sat.

Quoted 7 lines

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.

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.

Signature · 2 lines
George Anzinger   [email protected]
HRT (High-res-timers):  http://sourceforge.net/projects/high-res-timers/