info about no. of stack frames...!!!!

Discussion in 'C Programming' started by Rajshekhar, Apr 11, 2005.

  1. Rajshekhar

    Rajshekhar Guest

    Hi,
    I would like to know who decides the limit on the number of stack
    frames/pointers in a system for a program?
    for e.g in a recursion program if it loops for 'n' times then
    accordingly stack frames are incremented ..
    my question is who decides the maximum no.of stack frames for a
    program is it 1.system architecture or
    2.compiler dependent or
    3.implementation dependent.???

    is this number is fixed or variable..??

    TIA
    Regards,
    Rajshekhar
     
    Rajshekhar, Apr 11, 2005
    #1
    1. Advertising

  2. On 11 Apr 2005 02:24:23 -0700, Rajshekhar
    <> wrote:

    > I would like to know who decides the limit on the number of stack
    > frames/pointers in a system for a program?


    Probably no one, it just goes until the memory available for the
    stack[1] runs out.

    > for e.g in a recursion program if it loops for 'n' times then
    > accordingly stack frames are incremented ..
    > my question is who decides the maximum no.of stack frames for a
    > program is it 1.system architecture or


    Possibly.

    > 2.compiler dependent or


    Possibly.

    > 3.implementation dependent.???


    Possibly.

    > is this number is fixed or variable..??


    Probably.

    It's some combination of the above three variables, plus it could depend
    on the configuration at that time (for instance how much memory is being
    used by other programs). On embedded systems, for instance, it's common
    to give each task (process) its own dedicated stack, the size determined
    at build time, on some PC systems the stack grows down until it meets
    the heap of free memory used by malloc(), on others it is in its own
    memory space and can use swap space, etc.

    On some systems the "stack frame" format is defined by hardware, on most
    it is determined by the operating system needs. In general, your
    question can't be answered without knowing the system, and it may not
    even be answerable...

    [1] Or whatever is used. On at least one system I know it uses a linked
    list of 'frames', on another a pointer to the 'frame' is passed to the
    called function in a register and the memory for the 'frame' comes from
    wherever the calling code gets it.

    Chris C
     
    Chris Croughton, Apr 11, 2005
    #2
    1. Advertising

  3. In article <>,
    Rajshekhar <> wrote:

    > I would like to know who decides the limit on the number of stack
    >frames/pointers in a system for a program?


    This is a property of the operating system or possibly the C
    implementation, not the language.

    A reasonable general-purpose operating system will give the user or
    administrator some way to specify the maximum stack size. Obviously
    this will be limited by the address space of the processor and the
    amount of (virtual) memory on the system. The *number* of frames is
    unlikely to be relevant, rather it will be the space they occupy.

    For example, in unix there is a "setrlimit" system call that can be
    used, and it can be accessed from the shell by using the "limit" or
    "ulimit" command.

    If you're using an embedded system, or an unreasonable general-purpose
    one, then there are other possibilities, such as "it keeps going until
    the system crashes".

    -- Richard
     
    Richard Tobin, Apr 11, 2005
    #3
  4. Rajshekhar

    CBFalconer Guest

    Chris Croughton wrote:
    > <> wrote:
    >
    >> I would like to know who decides the limit on the number of stack
    >> frames/pointers in a system for a program?

    >
    > Probably no one, it just goes until the memory available for the
    > stack[1] runs out.


    Please don't encourage this sort of off-topic query by answering
    it, other than to redirect the OP to an appropriate newsgroup.
    Besides being off-topic, in most cases the experts on the subject
    are not here, and erroneous answers will go uncorrected.

    --
    "If you want to post a followup via groups.google.com, don't use
    the broken "Reply" link at the bottom of the article. Click on
    "show options" at the top of the article, then click on the
    "Reply" at the bottom of the article headers." - Keith Thompson
     
    CBFalconer, Apr 11, 2005
    #4
  5. Rajshekhar

    Nagaraj L Guest

    Re: info about no. of stack frames...!!!!

    It is only the system RAM memory limit that would restrict your program
    from functioning.
     
    Nagaraj L, Apr 11, 2005
    #5
  6. Rajshekhar

    SM Ryan Guest

    (Rajshekhar) wrote:
    # Hi,
    # I would like to know who decides the limit on the number of stack
    # frames/pointers in a system for a program?

    System dependent. Some allow you specify in program start up, or link-load, or
    elsewhere stack size limits; others do not. Those that do allow the limits to
    be set, vary in how they set those limits. You'll need system specific code
    or scripting for each different system.

    --
    SM Ryan http://www.rawbw.com/~wyrmwif/
    So....that would make Bethany part black?
     
    SM Ryan, Apr 11, 2005
    #6

  7. > for e.g in a recursion program if it loops for 'n' times then
    > accordingly stack frames are incremented ..


    Just as an aside, if you do a tail-recursive function, GCC can often
    make it run in constant stack space. With a slightly different ABI it
    would be possible to eliminate all tail-calls whether recursive or not,
    but now I'm completely off-topic :)

    Jon
    ----
    Learn to program using Linux assembly language
    http://www.cafeshops.com/bartlettpublish.8640017
     
    Jonathan Bartlett, Apr 11, 2005
    #7
  8. Rajshekhar

    SM Ryan Guest

    Re: info about no. of stack frames...!!!!

    "Nagaraj L" <> wrote:
    # It is only the system RAM memory limit that would restrict your program
    # from functioning.

    With VM its the segment size and/or available disc space. On some CPUs
    its the hardware register size, like 65535 for an 80286. On some systems
    it's some bozo who decides nobody will ever need more than a 640K of space
    and wires that it into the operating system.

    --
    SM Ryan http://www.rawbw.com/~wyrmwif/
    You face forward, or you face the possibility of shock and damage.
     
    SM Ryan, Apr 11, 2005
    #8
  9. Rajshekhar

    Alan Balmer Guest

    On Mon, 11 Apr 2005 11:51:25 +0100, Chris Croughton
    <> wrote:

    >On 11 Apr 2005 02:24:23 -0700, Rajshekhar
    > <> wrote:
    >
    >> I would like to know who decides the limit on the number of stack
    >> frames/pointers in a system for a program?

    >
    >Probably no one, it just goes until the memory available for the
    >stack[1] runs out.


    Please do the OP the service of directing him to a more appropriate
    newsgroup, rather than answering such off-topic questions here.

    To the OP - The answer to your question

    >1.system architecture or
    >2.compiler dependent or
    >3.implementation dependent.???


    is Yes. Make your query in a newsgroup which deals with the system
    architecture, compiler and implementation you are working with.

    --
    Al Balmer
    Balmer Consulting
     
    Alan Balmer, Apr 11, 2005
    #9
  10. Re: info about no. of stack frames...!!!!

    "Nagaraj L" <> writes:
    > It is only the system RAM memory limit that would restrict your program
    > from functioning.


    Not true. On many systems, virtual memory is bigger than physical
    RAM. Also, the memory available to a given program may not be related
    to the amount available to the entire system.

    The details are off-topic. The C standard requires certain minimum
    resource levels, but otherwise doesn't say anything about how much
    memory is available to a program under what circumstances.

    --
    Keith Thompson (The_Other_Keith) <http://www.ghoti.net/~kst>
    San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
    We must do something. This is something. Therefore, we must do this.
     
    Keith Thompson, Apr 11, 2005
    #10
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Surinder Singh
    Replies:
    1
    Views:
    1,242
    Richard Bos
    Dec 20, 2007
  2. Casey Hawthorne
    Replies:
    3
    Views:
    1,137
    Flash Gordon
    Nov 1, 2009
  3. Debajit Adhikary
    Replies:
    36
    Views:
    2,378
    Andre Kaufmann
    Feb 10, 2011
  4. Sam Roberts
    Replies:
    1
    Views:
    234
    Yukihiro Matsumoto
    Feb 11, 2005
  5. Kenneth McDonald

    Why stack overflow with such a small stack?

    Kenneth McDonald, Aug 30, 2007, in forum: Ruby
    Replies:
    7
    Views:
    286
    Kenneth McDonald
    Sep 1, 2007
Loading...

Share This Page