Pheonix
Pheonix

Reputation: 6052

why is default stack size 0

i am reading pthreads from https://computing.llnl.gov/tutorials/pthreads/ and it says

Default thread stack size varies greatly. The maximum size that can be obtained also varies greatly, and may depend upon the number of threads per node. Both past and present architectures are shown to demonstrate the wide variation in default thread stack size.

then it lists some default values for a couple of processors, but it never says 0 for any processor. So i copy pasted its C program and executed. The relevant part being :

   size_t stacksize;     
   pthread_attr_init(&attr);
   pthread_attr_getstacksize (&attr, &stacksize);
   printf("Default stack size = %li\n", stacksize);

i get the output :

Default stack size = 0

Why 0 ?

Upvotes: 1

Views: 1715

Answers (1)

paxdiablo
paxdiablo

Reputation: 882756

The stack size in the attribute is the minimum stack size, which may well be zero. I suspect in that case, any thread created with that attribute gets a sensible default, 4M for example.

The idea is to leave the attribute stack size alone if you want the default, and set it to something else if you want to force it to a specific minimum.

Upvotes: 3

Related Questions