Re: recursion bad?

Jesse Pollard (pollard@tomcat.admin.navo.hpc.mil)
Sun, 21 Nov 1999 09:41:37 -0600 (CST)


>Hi there. I'm implementing union-mount, and I find the need to store
>info on a stack. My question is: I see a good bit of code that could
>have been recursively written, but prolly intentionally wasn't. Is
>there a reason, like ``recursion is frowned upon in the kernel?'' Or
>is it, ``iterative, while more confusing to read and write, is more
>efficient.''

I believe it is more related to the limited kernel stack. You don't ever
want a stack overflow in the kernel.

>
>I'd rather use the execution stack than code my own stack and worry about
>memory management (which I'm still not comfortable with, in the kernel).
>Recursive calls would be fairly rare -- only at crossing mountpoints on
>unioned mounts.

I think you will want to avoid recursion - it makes debugging/tracing
a crash difficult when there are no stack frames for reference.

-------------------------------------------------------------------------
Jesse I Pollard, II
Email: pollard@navo.hpc.mil

Any opinions expressed are solely my own.

-
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/