How to set the stack size of thread attribute in C

1 Answer

0 votes
#include <stdio.h>
#include <pthread.h>
  
int main()
{
    size_t stacksize;
    pthread_attr_t attr;
  
    pthread_attr_getstacksize(&attr, &stacksize);
  
    printf("threads stack size: %lu\n", stacksize);
  
    // set new threads stack size
    pthread_attr_setstacksize(&attr, 987234);
    pthread_attr_getstacksize(&attr, &stacksize);
  
    printf("new threads stack size: %lu\n", stacksize);
     
    return 0;
}
 
 
/*
run:
  
threads stack size: 3
new threads stack size: 987234
 
*/

 



answered Jul 5, 2018 by avibootz

Related questions

...