[BusyBox] choice for reserving buffers

Vladimir N. Oleynik dzo at simtreas.ru
Fri Jan 26 17:25:10 UTC 2001


Manuel Novoa III wrote:

Big to you thank for the given analysis with digits.

> Vladimir, you are assuming that the system does lazy BSS memory
> allocation.

> 1) the kernel does lazy allocation of memory (MMU)
>    a) stack mem (coded or alloca)-- limited space, but is this really
> a problem?

"Segmentaion faults" - bad detector this problem. ;)

> Each instance gets a new stack and, since we have an MMU, that stack
> is probably more than large enough for our needs.  In this case,
> do we really have a risk of exhausting stack mem in busybox?

The utility will not be started at all if not memory for BSS though
certainly it and will not be selected at once will suffice. 
Other business, that further we have buffers addresses, and with the
stack we only shall try to make it without indication of success and
with increase of a size of the code (this too memory), 
as addresses not constants.

> b) BSS mem -- Not actually allocated until needed.  Depending on
> mapping of variables in mem, max possible wastage is 2*(page size)-2
> for each data structure.

It is any random generator, instead of structures. :)
Each utility place the structures sequentially in memory, and
for kernel this not interesting.

> c) malloc'd mem -- Not actually allocated until needed.  
> Some overhead for malloc data structures and for each allocation.
> Could be more or less wastage then BSS.  The app has a chance 
> to deal with the situation if malloc fails.

Your (c) argument with MMU is not necessary, in this case 
naturally will win BSS.
Result size usage memory ~equivalet.  
If require dynamic memory - please use malloc, alloca
function is machine dependent.
and trivail buff[const_size] - faults if memory exhausting not
detected in program.

> 2) the kernel does not do lazy allocation (no MMU)

I seem already have convinced Larry to make correct preprocessor`s
macros.  


--w
vodz





More information about the busybox mailing list