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


 
Thread Tools Search this Thread
Top Forums Programming How to find out the stack size occupied for a process?
# 1  
Old 01-22-2007
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 stack created by the process will be sufficient for the already existing multitthreaded process. Can anyone help me in this please??

Thanks
# 2  
Old 01-22-2007
hello !
maybe if u check out the man of brk command will help. Smilie
# 3  
Old 01-24-2007
Call sysconf() with PTHREAD_STACK_MIN - this gives you the minimum required stack for each thread. Multiply by the number of concurrent threads you know will exist.

Next, call getrlimit() with AS_STACK to see if there is a stack size limit for any new process your parent will create. If there is one and it is too small, then you have to call setrlimit (if you have privs) to raise the hard limit to get a stack size you can live with.

Most Linux systems have no stack limits set, but it sounds as if your does.

With regard to brk, ulimit() will return the current max brk size allowed -- with UL_GETMAXBRK. I don't know how that relates to your problem exactly.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. 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

2. 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

3. 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

4. Shell Programming and Scripting

script to display occupied and non occupied ports in unix

I want to extend this script. This must also be able to show me that a port is already assigned to a service but not running now there must be three different messages port 8949 is open but not listening port 8959 is open port 8999 hasn't been assigned to any service. I know that... (1 Reply)
Discussion started by: charan314
1 Replies

5. Programming

Find Virtual address space size for process

Hi, I am looking to work on unix systems which include (hp-ux, ibm aix, solaris and linux). I want to get the total virtual address space of a process, the used virtual memory i am able to get without any problem. I have tried using getrlimit and getrlimit64, but that gives only ... (4 Replies)
Discussion started by: uiqbal
4 Replies

6. Shell Programming and Scripting

find process size script

Hello i am working on a project here is part of script that i need a help in get process SpectroSERVER current size if it exceed 3850 MB then #pkill -TERM ArchMgr and wait to succfull shutdown message from the log file to proceed to the next step #tail -f $SPECROOT/SS/DDM/ARCHMGR.OUT... (7 Replies)
Discussion started by: mogabr
7 Replies

7. UNIX for Advanced & Expert Users

so there is no way to know the size occupied by data ?

I want to find out how many disk blocks are used by only data (and not metadata) by a file. But as far as I can tell, if the file has holes, then there is no way to know this. You can find out the logical size of the file (physical size + hole blocks). You can get the physical size of the... (3 Replies)
Discussion started by: the_learner
3 Replies

8. 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

9. 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

10. UNIX for Dummies Questions & Answers

How to find the size of Process Address space.

Hello, Please help me to know, How to find out the how much amount of process addres space is required/is used for/by a process. Tnx & Regards Vishwa. (1 Reply)
Discussion started by: S.Vishwanath
1 Replies
Login or Register to Ask a Question