Get the stack size and set the stack size of thread attribute in C Last Updated : 22 Sep, 2017 Summarize Comments Improve Suggest changes Share Like Article Like Report Prerequisite : Multithreading Syntax : C // to get size of stack int pthread_attr_getstacksize(const pthread_attr_t* restrict attr, size_t* restrict stacksize); // to set size of stack int pthread_attr_setstacksize(pthread_attr_t* attr, size_t stacksize); . pthread_attr_getstacksize() : It is use for get threads stack size. The stacksize attribute gives the minimum stack size allocated to threads stack. When successfully run then it gives 0 otherwise gives any value. First argument - It takes pthread attribute. Second argument - It takes a variable and give the size of the thread attribute. pthread_attr_setstacksize() : It is use for set new threads stack size. The stacksize attribute gives the minimum stack size allocated to threads stack. When successfully run then it gives 0 otherwise if error gives any value. First argument - It takes pthread attribute. Second argument - It takes the size of new stack (In bytes) C #include <stdio.h> #include <stdlib.h> #include <pthread.h> int main() { // for takes the size of threads stack size_t stksize; // attribute declaration pthread_attr_t atr; // it gets the threads stack size and give // value in stksize variable pthread_attr_getstacksize(&atr, &stksize); // print the current threads stack size printf("Current stack size - > %d\n", stksize); // then set the new threads stack size pthread_attr_setstacksize(&atr, 320000034); pthread_attr_getstacksize(&atr, &stksize); // print the new stack size printf("New stack size-> %d\n", stksize); return 0; } Output : Current stack size - > 4196464 New stack size-> 320000034 For compile use gcc program_name.c -lpthread Comment More infoAdvertise with us Next Article Get the stack size and set the stack size of thread attribute in C D Devanshu Agarwal Improve Article Tags : Misc C Language system-programming C-Library Practice Tags : Misc Similar Reads C# | Get object at the top of the Stack - Peek operation Stack represents a last-in, first out collection of object. It is used when you need a last-in, first-out access to items. When you add an item in the list, it is called pushing the item and when you remove it, it is called popping the item. Stack<T>.Peek Method is used to returns the object a 3 min read stack empty() and stack size() in C++ STL The std::stack::size() and std::stack::empty() in C++ are built-in functions that are used to provide information about the size of the stack. They are the member functions of the std::stack container defined inside <stack> header file.stack::empty()The stack::empty() method is used to check w 2 min read C# | Insert an object at the top of the Stack - Push Operation Stack represents a last-in, first out collection of object. It is used when you need a last-in, first-out access of items. When you add an item in the list, it is called pushing the item and when you remove it, it is called popping the item. Stack<T>.Push(T) Method is used to inserts an object 2 min read stack::push() and stack::pop() in C++ STL The stack::push() and stack::pop() method in stack container is used to insert and delete the element from the top of stack. They are the member functions of std::stack container defined inside <stack> header file. In this article, we will learn how to use stack::push() and stack::pop() method 2 min read Reverse a stack without using extra space in O(n) Reverse a Stack without using recursion and extra space. Even the functional Stack is not allowed. Examples: Input : 1->2->3->4 Output : 4->3->2->1 Input : 6->5->4 Output : 4->5->6 We have discussed a way of reversing a stack in the below post.Reverse a Stack using Recu 6 min read Like