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

Re: getrlimit( RLIMIT_STACK, ... )



Chris Herborth writes:
> Is there any particular reason why getrlimit( RLIMIT_STACK, &foo ) isn't
> implemented (it's supposed to return the max size of the stack)? 
> Couldn't it figure out the right value from _stksize?
> 
> It might make more sense to put this in the kernel (?), since it already
> knows how big the stack is for a process (it figures it out from
> _stksize and possibly the amount of RAM allowed for the process).
> 

Seems like you are on the wrong track. The kernel does not know
anything about _stksize :-( (It does not even load the symbol tables)

The global variable _stksize is just a feature of the MiNT Libs to
determine the size of the stack a program initialization. Also it is
quite tricky to determine the actual maximum size of the stack, as
there are configurations where the heap and the stack share the same
memory (heap growing up and stack growing down), so your maxmimum size
would change dynamically, depending on your current heap usage.

Actually RLIMIT_STACK makes sense in an environment where the stack
can grow dynamically. Un*x operating systems use virtual memory to
initialize the stack pointer to some high point in memory and just add
VM pages to the process while the stack is growing down. RLIMIT_STACK
just gives you a way to stop the stack from growing indefinitely.

Wolfgang

----
Wolfgang Lux
WZH Heidelberg, IBM Germany             Internet: lux@heidelbg.ibm.com
+49-6221-59-4546                        VNET:     LUX at HEIDELBG
+49-6221-59-3200 (fax)	                EARN:     LUX at DHDIBMIP