Re: Recursion unwanted?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, 2006-03-24 at 08:42 +0100, Hendrik Post wrote:
> 
> Hi!
> 
> Is recursion in general considered bad style within the kernel? Or is 
> the use of recursive calls disencouraged because of possibly excessive 
> stack usage? Are there any examples within the kernel where recursion is 
> actually used?

unbounded recursion is bad (due to stack as you say)
There are a few cases where an explicitly bounded recursion is used; the
VFS is one of those (for recursive symlink resolution); in the USB layer
there is treelock(). But in general it is really best to avoid it if it
is at all possible, your stack is only between 4 and 6Kb in size after
all..



--
Kernelnewbies: Help each other learn about the Linux kernel.
Archive:       http://mail.nl.linux.org/kernelnewbies/
FAQ:           http://kernelnewbies.org/faq/


[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux