As I understand, the default stack size for a pthread on Linux is 16K. I am getting strange results on my 64-bit Ubuntu install.$ ulimit -s8192Alsopthread_attr_init(&attr);pthread_attr_getstacksize(&attr, &stacksize);printf(Thread stack size = %d bytes \n, stacksize);Prints    Thread stack size = 8388608 bytesI am quite sure the stack size if not 8388608. What could be wrong ?
Default stack size for pthreads
c;multithreading
int pthread_attr_setstacksize(pthread_attr_t *attr, size_t stacksize);The stacksize attribute shall define the minimum stack size (in  bytes) allocated for the created threads stack.In your example, the stack size is set to 8388608 bytes which corresponds to 8MB, as returned by the command ulimit -sSo that matches.From the pthread_create() description:On Linux/x86-32, the default stack size for a new thread is 2         megabytes.  Under the NPTL threading implementation, if the         RLIMIT_STACK soft resource limit at the time the program started has         any value other than unlimited, then it determines the default         stack size of new threads.  Using pthread_attr_setstacksize(3), the         stack size attribute can be explicitly set in the attr argument used         to create a thread, in order to obtain a stack size other than the         default.So the thread stack size can be set either via the set function above, or the ulimit system property.For the 16k you're referring to, it's not clear on which platform you've seen that and/or if any system limit was set for this.See the pthread_create page and here for some interesting examples on this.