Messages in this thread | | | Date | Mon, 28 Jun 1999 09:06:18 -0400 (EDT) | From | "Richard B. Johnson" <> | Subject | Re: question about kernel/sched.c - 2.2.10 |
| |
On Mon, 28 Jun 1999 linux1@siren.host4u.net wrote:
> > i definitely have no clue about what is going on inside > the kernel, but i'm trying to learn... > i was digging around sched.c (2.2.10)in schedule(). i > noticed a few goto statements that only return below > where they were called: specifically; handle_bh, > move_rr_last, and still_running. it _seems_ to me > that these gotos are not necessary. am i missing the > point? or is there a benefit in saying 'goto' rather > than just putting the code right there? help me > understand.
This is becoming a FAQ.
Generally, in some code that is speed-critical, one would like to have the main path through the code (the fast path), execute with no jumps that could force the CPU instruction cache to be refilled.
So you would like something like:
if(abnormal_condition == TRUE) goto quit; fast_path(); fast_path(); quit:;
Another situation where you would like to use a goto is:
if(a) { if(b) { if(c) { if(d) { if(error) goto quit;
The actual code generated by the compiler can be checked by compiling using the -S flag. You will note that, for a processor to do anything useful, there are lots and lots of 'gotos' (called jumps) in the actual machine code. Forcing the compiler to make a 'jump' where you want it, rather than where it would normally put it, can sometimes make faster executing code.
Cheers, Dick Johnson ***** FILE SYSTEM WAS MODIFIED ***** Penguin : Linux version 2.2.6 on an i686 machine (400.59 BogoMips). Warning : It's hard to remain at the trailing edge of technology.
- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.rutgers.edu Please read the FAQ at http://www.tux.org/lkml/
| |