If you are using typical GNU code 8 megabytes may be too small.
If you use good thread safe programming practices without large
automatic arrays and the like you can get by with numbers in the
8k range or even smaller. (AmigaDOS really beat this into its
programmers, over and over again. It was a multi-threaded OS from
the git go. It was easy to blow it away by exceeding stack allocations.
Eventually one of the SAS-C geniuses developed automatic stack extension
code that worked remarkably well. Unfortunately this is probably not
allowed with in the POSIX concepts.)

Some of the basic rules run like this:
1) Minimize use of automatic variables. malloc and free are your friends.
2) When you use recursion be particularly careful about ending conditions
   and starting conditions so that the recursion stays within reasonable
   bounds. Each recursion eats stack.
3) Be conservative on stack usage estimates. If you THINK it only uses
   100 bytes presume it uses 120 in calculations.
4) Toss in some safety factors when you get all done.
5) Tune stack size for the needs of each thread. One size fits all is
   neither realistic in tailoring or in programming.

And so forth, remember, malloc and free are your very best friends.

{^_^}

----- Original Message ----- 
From: "Aaron Kenny" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Wednesday, March 12, 2003 10:44 AM
Subject: RE: NPTL on Pheobe


> One remaining question?  How to determine the stack size?  Is there a
> formula for that?
>
> -----Original Message-----
> From: [EMAIL PROTECTED]
> [mailto:[EMAIL PROTECTED] Behalf Of jdow
> Sent: Wednesday, March 12, 2003 1:21 PM
> To: [EMAIL PROTECTED]
> Subject: Re: NPTL on Pheobe
>
>
> The magic in Matt's code is where he sets the stack size:
> > pthread_attr_setstacksize(&attr, 16384);
>
> {^_^}
> ----- Original Message -----
> From: "Aaron Kenny" <[EMAIL PROTECTED]>
>
>
> > Thanks Matt, that was magic.  8154 threads as root!  I had played with
> > setstacksize after my last post and it still wasn't working.  I'll
analyze
> > your code and see what I was doing wrong.
> >
> > Thanks all who posted.
> >
> > - Aaron
>
>
>
> --
> Phoebe-list mailing list
> [EMAIL PROTECTED]
> https://listman.redhat.com/mailman/listinfo/phoebe-list
>
>
>
> -- 
> Phoebe-list mailing list
> [EMAIL PROTECTED]
> https://listman.redhat.com/mailman/listinfo/phoebe-list
>



-- 
Phoebe-list mailing list
[EMAIL PROTECTED]
https://listman.redhat.com/mailman/listinfo/phoebe-list

Reply via email to