Linux Thread Stack Size pthread_attr_setstacksize


 
Thread Tools Search this Thread
Operating Systems Linux Linux Thread Stack Size pthread_attr_setstacksize
# 1  
Old 02-10-2012
Linux Thread Stack Size pthread_attr_setstacksize

I have MultiThreaded Application in Linux.
I am Setting the stack size using pthread_attr_setstacksize.
The stack size i set is greter than PTHREAD_STACK_MIN i.e. 16384 bytes for my system.
i am setting the stack size to 17408 bytes, and my application crashes due to insufficient stack size. when i set the stack size to 17920 my application runs successfully.

But from my gathered statistics from /proc/<MY PROCESS PID>/task/<TID>/stat , the maximum stack size per thread ( which is the difference of stack pointer and bottom of stack) is not greater than 8KB or 9KB , then why is the process crashing at stack size 17408 bytes i.e. around 16KB.

Smilie

Kindly do clarify my doubts.

Thanking you in anticipation.
# 2  
Old 02-10-2012
Quote:
Originally Posted by Kedar Sabnis
the maximum stack size per thread ( which is the difference of stack pointer and bottom of stack) is not greater than 8KB or 9KB , then why is the process crashing at stack size 17408 bytes i.e. around 16KB.
Are you sure that's what it really means? That field isn't even documented in proc.txt under the Linux kernel documentation. Obviously if your thread needs more than 16K stack to live, and it's living, it has more than 16K stack...

---------- Post updated at 10:04 AM ---------- Previous update was at 09:52 AM ----------

Incidentally, since memory gets allocated in fixed chunks of 4K or 8K, you're probably not saving anything by giving them 16.01K instead of 20K.
Login or Register to Ask a Question

Previous Thread | Next Thread

8 More Discussions You Might Find Interesting

1. Red Hat

Cannot set 'soft limits' for 'maximum stack size' for a standard user

Hi Guys, I'm trying to install Oracle Database on to Oracle Linux 7.6 but when the database install package checks the OS set-up, it keeps on failing on the soft limits for the stack. It's default value is 8192 but I'm trying to set it to 10240. This is what I added to... (2 Replies)
Discussion started by: ASGR
2 Replies

2. Shell Programming and Scripting

How to find stack size at runtime?

hi, I just wondering is there any way that I can record the stack size of shell script at runtime. (2 Replies)
Discussion started by: yc962frank
2 Replies

3. UNIX for Advanced & Expert Users

How to identify maximum stack size?

Hi All, I have set max stack size as 4KB for my thread, but it always using very less. So I like to know what is the maximum stack size is used by my thread. I tried with gcc -fstack-usage command line option, but its not supported by mips. Kindly suggest me the way to find the max stack... (6 Replies)
Discussion started by: rajamohan
6 Replies

4. Programming

How to read max stack size -Xss that is set/default for a java program?

I need to know what is the maximum stack size i.e. -Xss my java program is running with. Is there a way to find that out from inside my java program code and outside of it. What i am looking for is to read whatever the current set max limit -Xss (stack sie) is for a particular JVM(not... (3 Replies)
Discussion started by: mohtashims
3 Replies

5. Programming

Threads and stack size

Can someone explain me, why when I create new threads with stack bigger than default (using pthread_attr_setstacksize()) i can create more? Each thread has it's own stack, so how bigger stack can cause possibility to create more threads? (7 Replies)
Discussion started by: dawwin
7 Replies

6. Programming

How to find out the stack size occupied for a process?

Hi, In Linux how to find out what will be the stack size allocated for a process? Actually i have to fork n number of processess, and will call exec. I will be execing an executable which is already multithreaded and each thread size is defined. My doubt is how to know if the size of the... (2 Replies)
Discussion started by: rvan
2 Replies

7. UNIX for Advanced & Expert Users

Stack size of Apps ?

hi all, I need to find out the Stack usage of an App which is basically an mpeg4 decoder. We are plannin to port the codec to an RTOS. so is there any way to find out the max stack size while the codec is running? saTs (1 Reply)
Discussion started by: satish_somu
1 Replies

8. Programming

How to increase the size of the stack

Hi!!, could someone tell me how to increase the stack size in HP-UX? Thanx (7 Replies)
Discussion started by: jyotipg
7 Replies
Login or Register to Ask a Question