Project Home
Project Home
Trackers
Trackers
Documents
Documents
Wiki
Wiki
Discussion Forums
Discussions
Project Information
Project Info
Forum Topic - How to increase available stack?: (5 Items)
   
How to increase available stack?  
If I request __stackavail() [1] it returns something slightly above 500K (I have qnx 6.3.2)

but ulimit says that stack is unlimited [2]

How can I increase stack size available for alloca?

Thanks a lot!

[1]
#include <alloca.h> 
main() {
int n = __stackavail();
printf("avail: %d\n", n);
}

[2]
bash-2.05a$ ulimit -a
core file size        (blocks, -c) unlimited
data seg size         (kbytes, -d) unlimited
file size             (blocks, -f) unlimited
max locked memory     (kbytes, -l) unlimited
max memory size       (kbytes, -m) unlimited
open files                    (-n) 1000
pipe size          (512 bytes, -p) 10
stack size            (kbytes, -s) unlimited
cpu time             (seconds, -t) unlimited
max user processes            (-u) unlimited
virtual memory        (kbytes, -v) unlimited
Re: How to increase available stack?  
> If I request __stackavail() [1] it returns something slightly above 500K (I 
> have qnx 6.3.2)
> 
> but ulimit says that stack is unlimited [2]
> 
> How can I increase stack size available for alloca?

You can give your executable a stack note so the loader gives a larger default stack size with ldrel -S 

Regards,

Ryan Mansfield
Re: How to increase available stack?  
> > How can I increase stack size available for alloca?
> 
> You can give your executable a stack note so the loader gives a larger default
>  stack size with ldrel -S 

it works, thanks a lot!

are there other ways? I have a 3rd party stuff that builds and runs an application. I'm reluctant to modify it, can I 
get the same by passing anything to gcc/ld or by changing loader settings?
Re: How to increase available stack?  
> > > How can I increase stack size available for alloca?
> > 
> > You can give your executable a stack note so the loader gives a larger 
> default
> >  stack size with ldrel -S 
> 
> it works, thanks a lot!
> 
> are there other ways? I have a 3rd party stuff that builds and runs an 
> application. I'm reluctant to modify it, can I get the same by passing 
> anything to gcc/ld or by changing loader settings?

If you're using qcc, you can use qcc -N which spawns ldrel -S. If you're using the gcc driver, you have to call ldrel 
postlink.  I don't think there are any other ways to set the initial default stack size. 

If you can't modify the executable to add a stack note at all, one option would be to modify the loader to give all 
programs a larger stack size. Look for DEF_VIRTUAL_FIRST_THREAD_STACKSIZE in services/system/proc/loader_elf.c (the 
source is available in the OS project).
I'm not endorsing this as a solution but mentioning it in case you're completely stuck. :)

Regards,

Ryan Mansfield
Re: How to increase available stack?  
Thanks, Ryan