[BusyBox] choice for reserving buffers
Manuel Novoa III
mnovoa3 at bellsouth.net
Sat Jan 27 04:28:43 UTC 2001
On Fri, 26 Jan 2001, Tomi Ollila wrote:
> Friday Jan 26 14:01:16 -0600 2001 Manuel Novoa III <mnovoa3 at bellsouth.net> wrote:
> >
> > Also, as mentioned in a follow-up post, if you're on a system with no MMU, you
> > are already "paying" for the stack... it is allocated. Why throw something in
> > BSS or malloc it and require the system to allocate more memory to your app?
> >
>
> I´d rather go with "pre-paid" small stack than a larger one and then
> allocate from heap when necessary to get more. This way the applets that
> doesn´t require so much memory doesn´t need to "pay" for the stack they
> doesn´t need. If there are many concurrent processes all having big stacks
> the memory may be eaten out pretty quick... I remember Amiga OS used to
> have default stack size per process something like 4K in the early times
> and that machine sure could run dozens of processes concurrently if needed...
Everything depends on the system and the application in question of course.
As another example, consider the case of MINIX for the 8086 though. As I
recall, the amount of stack space to allocate for an application was actually
stored in the executable header. It was set to a default value by the compiler,
but was tunable by using a utility.
But even in the case you mention, it might be worthwhile to allocate a large
chunk of space on the stack. If your application only needed a buffer for 1k
or so and wasn't hard on the stack in other ways (recursive/deeply nested
function calls/etc) it would probably be better to put that buffer on the stack
as that memory isn't being used but is already allocated.
Manuel
More information about the busybox
mailing list