Increasing the stack size of a Thread

Hii Alll

I am new to Threads in C. I am doing C in Unix Solaris.

In my program for creating Threads I am using the function
thr_create( NULL, 0, ThreadFunc, NULL, THR_BOUND, NULL ))
in which second argument indicates the stack size. 3rd argument
is function name in which Thread executes.

If we give it as 0 it takes default size of some bytes. In my case
I am using so many local variables of large character arrays.
so I need to increase stack size. If I am giving any other value
other than 0 as a second argument it is giving segmentation fault
in ThreadFunc().

Can anyone please suggest me How to increase the stack size of
a thread?

Thanks in advance.
prashas_d.
[752 byte] By [prashas_d] at [2007-11-20 0:27:54]
# 1 Re: Increasing the stack size of a Thread
You need to pass either 0 or a value greater than thr_min_stack(). The default size (when you pass 0) is (1 << 20) (e.g. 1 MB) on typical 32 bit platforms. Note that if you overflow the stack, you will get a seg fault.

Large stack based arrays are not really used in production code, since there is no measurable performance benefit to using them. If you use heap based arrays, you'll be able to stick to the default stack size.
TomWidmer at 2007-11-9 13:59:00 >
# 2 Re: Increasing the stack size of a Thread
Why not use dynamic arrays?

PS. Deja vu?
Hobson at 2007-11-9 14:00:00 >
# 3 Re: Increasing the stack size of a Thread
The default thread stack size on Windows is 1 MB (don't know about Unix / Solaris but it cant be miserably small).

Are you really allocating so much on the stack that the default isn't enough? If so, perhaps, you need to give your implementation a thorough review and like indicated above, verify the need for using static arrays.
In my case I am using so many local variables of large character arrays.This makes your implementation a good case for the usage of string classes like std::string, actually.
Siddhartha at 2007-11-9 14:01:09 >