LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Closed Thread
 
Search this Thread
Old 12-06-2008, 07:17 AM   #1
aravinda78
LQ Newbie
 
Registered: Nov 2008
Posts: 8

Rep: Reputation: 0
Getting the stack size of a process


Hi all,

How to get the stack size of the program dynamically ? Is there any system call or API to accomplish this ?

Thanks in advance,
Aravind.
 
Old 12-06-2008, 07:56 PM   #2
Guttorm
Senior Member
 
Registered: Dec 2003
Location: Trondheim, Norway
Distribution: Debian and Ubuntu
Posts: 1,136

Rep: Reputation: 230Reputation: 230Reputation: 230
Look at
man getrlimit
 
Old 12-07-2008, 04:42 AM   #3
ta0kira
Senior Member
 
Registered: Sep 2004
Distribution: FreeBSD 9.1, Kubuntu 12.10
Posts: 3,078

Rep: Reputation: Disabled
Is the stack size always the max? Will multiple threads share the same amount of stack space, or do they each get the max? I've never really pondered those things. For some reason I'm thinking that the stack size can change, or that the stack itself can be replaced.
ta0kira

Last edited by ta0kira; 12-07-2008 at 04:43 AM.
 
Old 12-07-2008, 07:01 AM   #4
Guttorm
Senior Member
 
Registered: Dec 2003
Location: Trondheim, Norway
Distribution: Debian and Ubuntu
Posts: 1,136

Rep: Reputation: 230Reputation: 230Reputation: 230
Hi

Sorry, getrlimit returns the max, not the current size. getrusage is maybe what you are looking for?

And setrlimit can be used to set the stack size.

I think multiple threads share both the size and the max. Because when you create a new thread it gets a copy of the current stack.
 
Old 12-12-2008, 08:32 AM   #5
pixellany
LQ Veteran
 
Registered: Nov 2005
Location: Annapolis, MD
Distribution: Arch/XFCE
Posts: 17,802

Rep: Reputation: 728Reputation: 728Reputation: 728Reputation: 728Reputation: 728Reputation: 728Reputation: 728
OP has been posting multiple homework questions---and in this case no follow-up
Reported for closure
 
  


Closed Thread


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
size of call stack? vkmgeek Programming 11 11-06-2006 09:42 AM
16K stack size in 2.6..xx quietguy47 Linux - Kernel 3 04-24-2006 01:21 PM
FC4 - new stack size? DJOtaku Fedora 2 10-07-2005 12:22 PM
stack trace of a process node047 Linux - Newbie 2 04-01-2005 09:11 PM
Stack Size Decision atul_mehrotra Linux - General 0 10-07-2004 01:01 AM


All times are GMT -5. The time now is 09:15 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration