How to tell my current stack size?

I am using ‘tfork()’ under QNX 4.25 (yes I am planning on porting to
RTP to get real threads :slight_smile:). The example in the doc shows calling ‘tfork’ with a
stack size of 2000 bytes. I copied this but crashed horribly when
my ‘thread’ executed ‘gethostbyname()’. I increased the stack size to
20000 bytes and all worked fine.

My question is how does one know a good size to make the stack? In this
case 2000 was too small. How can I tell the stack size of a QNX
process to get some ideas of what’s normal?

Thanks.

Check out _beginthread instead of tfork.

“art” <avhays@nih.gov> wrote in message
news:Voyager.001207090630.1916959A@lsr-tstc.lsrnet.nei.nih.gov

I am using ‘tfork()’ under QNX 4.25 (yes I am planning on porting to
RTP to get real threads > :slight_smile:> ). The example in the doc shows calling
‘tfork’ with a
stack size of 2000 bytes. I copied this but crashed horribly when
my ‘thread’ executed ‘gethostbyname()’. I increased the stack size to
20000 bytes and all worked fine.

TCP/IP is NOT thread safe. nor is Photon for that matter

My question is how does one know a good size to make the stack? In this
case 2000 was too small. How can I tell the stack size of a QNX
process to get some ideas of what’s normal?

Allocate the stack yourself, fill it with a know pattern,
when the thread is terminated scan the stack memory where
the pattern stops that will tell ya the max stack size use
by that program at the time :wink:

Thanks.

If you wanted to look at other apps to get a feel what they are using “size”
can provide the info.

“art” <avhays@nih.gov> wrote in message
news:Voyager.001207090630.1916959A@lsr-tstc.lsrnet.nei.nih.gov

I am using ‘tfork()’ under QNX 4.25 (yes I am planning on porting to
RTP to get real threads > :slight_smile:> ). The example in the doc shows calling
‘tfork’ with a
stack size of 2000 bytes. I copied this but crashed horribly when
my ‘thread’ executed ‘gethostbyname()’. I increased the stack size to
20000 bytes and all worked fine.

My question is how does one know a good size to make the stack? In this
case 2000 was too small. How can I tell the stack size of a QNX
process to get some ideas of what’s normal?

Thanks.

_beginthread turn on some flags so the C libraries attemps t
to be has thread safe as possible.

“Art Hays” <avhays@nih.gov> wrote in message
news:Voyager.001208033645.1916959B@lsr-tstc.lsrnet.nei.nih.gov

What is the difference between tfork and _beginthread?


Previously, Mario Charest wrote in qdn.public.qnx4:

Check out _beginthread instead of tfork.

“art” <> avhays@nih.gov> > wrote in message
news:> Voyager.001207090630.1916959A@lsr-tstc.lsrnet.nei.nih.gov> …
I am using ‘tfork()’ under QNX 4.25 (yes I am planning on porting to
RTP to get real threads > :slight_smile:> ). The example in the doc shows calling
‘tfork’ with a
stack size of 2000 bytes. I copied this but crashed horribly when
my ‘thread’ executed ‘gethostbyname()’. I increased the stack size to
20000 bytes and all worked fine.


TCP/IP is NOT thread safe. nor is Photon for that matter

My question is how does one know a good size to make the stack? In
this
case 2000 was too small. How can I tell the stack size of a QNX
process to get some ideas of what’s normal?

Allocate the stack yourself, fill it with a know pattern,
when the thread is terminated scan the stack memory where
the pattern stops that will tell ya the max stack size use
by that program at the time > :wink:


Thanks.
\

What is the difference between tfork and _beginthread?


Previously, Mario Charest wrote in qdn.public.qnx4:

Check out _beginthread instead of tfork.

“art” <> avhays@nih.gov> > wrote in message
news:> Voyager.001207090630.1916959A@lsr-tstc.lsrnet.nei.nih.gov> …
I am using ‘tfork()’ under QNX 4.25 (yes I am planning on porting to
RTP to get real threads > :slight_smile:> ). The example in the doc shows calling
‘tfork’ with a
stack size of 2000 bytes. I copied this but crashed horribly when
my ‘thread’ executed ‘gethostbyname()’. I increased the stack size to
20000 bytes and all worked fine.


TCP/IP is NOT thread safe. nor is Photon for that matter

My question is how does one know a good size to make the stack? In this
case 2000 was too small. How can I tell the stack size of a QNX
process to get some ideas of what’s normal?

Allocate the stack yourself, fill it with a know pattern,
when the thread is terminated scan the stack memory where
the pattern stops that will tell ya the max stack size use
by that program at the time > :wink:


Thanks.