Re: userspace-app stack - dynamic?

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

 



On Fri, 12 Sep 2003, Lukas Ruf wrote:

> Guennadi Liakhovetski <gl@dsa-ac.de> [2003-09-12 11:21]:
> >
> > IIRC, user-space application stack can grow dynamically, right? Now, if
> > this is so, what happens in ENOMEM? Say, in a function, I can either
> > explicitly malloc(), or I can have a local char buf[...]. Will the app
> > just sleep "forever" waiting for RAM to become available?
> >
>
> it's questionable whether malloc() allocates buffer on stack.  I've
> always thought it was on heap.

Exactly, sorry, I didn't make it clear enough. My understanding was:
char x[y]; - stack
malloc(y); - heap

> if you have
>
> int foo()
> {
>   char buffer[XYZ];
> }
>
> buffer would be on stack.  Stack size can be calculated at
> compile-time.  ENOMEM should never be returned there IIRC.

Wait, no, don't think so. buffer above has scope local to foo(){}, so, it
should be allocated on stack only when we are in this function. So, you
can't know exactly how deep on the stack you are at this moment at compile
time. So, this allocation should be resolved at run-time. IIRC, task stack
can be grown dynamically by the kernel at run-time - of course, if there
is space... If not?...

Guennadi
---------------------------------
Guennadi Liakhovetski, Ph.D.
DSA Daten- und Systemtechnik GmbH
Pascalstr. 28
D-52076 Aachen
Germany

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