Ritesh
--
http://www.cs.unc.edu/~ritesh/
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majo...@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
On FreeBSD the default thread stack size is not computed from ulimit -s,
but is constant. They apparently only recently increased it to 1MB
(resp. 2MB on 64-bit arches), from 64K.
On Linux, the default thread stack size (except with fixed stack LinuxThreads)
is determined from ulimit -s (with a constant default if ulimit -s is
unlimited).
If your threaded application has specific needs for stack sizes, it can
always pthread_attr_setstacksize to whatever you find appropriate.
The thread library needs to know the stack size limit before creating
the thread, that can't be changed dynamically.
Jakub
Hi Jakub,
Thanks for your reply. I actually went ahead after getting your
mail and coded up a small program to check the stack limit
deliberately. The program is shown inline.
#include <stdio.h>
#define BUF_SIZE 1024000
void recurse(int n){
char ch[BUF_SIZE];
if(n<=0)
return;
else
recurse(n-1);
}
int main(argc, argv)
int argc;
char **argv;
{
if(argc!=2){
printf("Usage: %s <n (megabytes)>\n", argv[0]);
return 1;
}
printf("Checking for %dMB\n", atoi(argv[1]));
recurse(atoi(argv[1]));
}
Its a fairly crude way to find out the actual stack limit. Basically,
the resurse function recurses each time allocating ~1MB of space on
the stack. The program segfaults exactly at the ulimit -s value of
stack size on both linux and freebsd. So it does seem that the ulimit
-s is the value of stack limit used on FreeBSD.
Ritesh
--
http://www.cs.unc.edu/~ritesh/
For the main stack sure. But now try to call that recurse in
some other thread.
Jakub
Oh great... I see your point now. I called the same recurse in an
alternative thread and found the limit to be 8M on Linux ( and Mac OS
X (Panther)) but around 1MB on FreeBSD. Thanks for the clarification!
Ritesh
--
http://www.cs.unc.edu/~ritesh/