LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 08-01-2014, 09:37 AM   #1
jana_van
LQ Newbie
 
Registered: Aug 2014
Posts: 3

Rep: Reputation: Disabled
What is the lower limit on the stack size ?


I want to run a process which has 7 threads internally with 8K stack size for each thread in a linux system(fedora 18)

I gave the below command in the terminal before I run my process

$ulmit -s 8 //Want to run my process and its threads each with 8K stack size

$./a.out // I started my process

With this command system hanged up and there is no response.But when I give the command $ulimit -s 16 //MY process successfully started.

When I tried with 8K, before setting 8K I have changed the 'PTHREAD_STACK_MIN'(in /usr/include/bits/local_lim.h) value to 8192 and by default it was 16384.

Can we run the process with 8K stack size? Is there any lower limit ? or Is it that any thread in my process consuming more than 8K stack size ?


Thanks
Janardhan.
 
Old 08-01-2014, 02:34 PM   #2
rtmistler
Moderator
 
Registered: Mar 2011
Location: Sutton, MA. USA
Distribution: MINT Debian, Angstrom, SUSE, Ubuntu
Posts: 4,087
Blog Entries: 10

Rep: Reputation: 1521Reputation: 1521Reputation: 1521Reputation: 1521Reputation: 1521Reputation: 1521Reputation: 1521Reputation: 1521Reputation: 1521Reputation: 1521Reputation: 1521
There's no lower limit to my knowledge and the usage of stack depends on how you coded your process.

You can get the limits from within your program just to verify that you have either properly inherited it from the shell you invoked it from, or also to set these values within your program. Look into getrlimit() and setrlimit(). You would be using RLIMIT_STACK.

I'm assuming you recompiled the pthread library when you altered the PTHREAD_STACK_MIN setting?
 
Old 08-02-2014, 02:55 AM   #3
jana_van
LQ Newbie
 
Registered: Aug 2014
Posts: 3

Original Poster
Rep: Reputation: Disabled
Hi,
No, I did not recompile the pthread library. Could you let me know the instructions how to recompile the pthread library when we change parameter values in pthread.h ?

Thanks
 
Old 08-02-2014, 02:58 AM   #4
jana_van
LQ Newbie
 
Registered: Aug 2014
Posts: 3

Original Poster
Rep: Reputation: Disabled
Hi,
I have one more question that when I set $ulimit -s 8 on the terminal, the stack size of 8K is applicable to only main process ? or is it applicable to other threads which are spawned by main process as well ?

Thanks
 
Old 08-02-2014, 05:51 AM   #5
jpollard
Senior Member
 
Registered: Dec 2012
Location: Washington DC area
Distribution: Fedora, CentOS, Slackware
Posts: 4,601

Rep: Reputation: 1241Reputation: 1241Reputation: 1241Reputation: 1241Reputation: 1241Reputation: 1241Reputation: 1241Reputation: 1241Reputation: 1241
Quote:
Originally Posted by jana_van View Post
Hi,
I have one more question that when I set $ulimit -s 8 on the terminal, the stack size of 8K is applicable to only main process ? or is it applicable to other threads which are spawned by main process as well ?

Thanks
http://stackoverflow.com/questions/2...-fork-and-exec

You can control the stack yourself, no need to rebuild the library:

https://computing.llnl.gov/tutorials/pthreads/#Stack
 
Old 08-04-2014, 07:49 AM   #6
rtmistler
Moderator
 
Registered: Mar 2011
Location: Sutton, MA. USA
Distribution: MINT Debian, Angstrom, SUSE, Ubuntu
Posts: 4,087
Blog Entries: 10

Rep: Reputation: 1521Reputation: 1521Reputation: 1521Reputation: 1521Reputation: 1521Reputation: 1521Reputation: 1521Reputation: 1521Reputation: 1521Reputation: 1521Reputation: 1521
Quote:
Originally Posted by jana_van View Post
Hi,
I have one more question that when I set $ulimit -s 8 on the terminal, the stack size of 8K is applicable to only main process ? or is it applicable to other threads which are spawned by main process as well ?

Thanks
The setting of stack limit is applicable to all processes and threads which are childs to the process where you issued the ulimit call; providing the child processes do not further make their own settings changes.

I wasn't 100% sure about whether or not pthreads would need to be remade when you mentioned that you altered a #define; it made me think you edited pthread source code. The link jpollard sent is very helpful and appears to be the correct way to do this; I would give that a try instead of changing that #define.
 
  


Reply


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
Why multipath device size is lower than lun size cormanstnl Linux - General 1 01-06-2012 09:32 AM
Why the stack size limit? hydraMax Programming 4 05-02-2011 09:07 PM
How to set Stack/Heap Limit ? gloridel Linux - Kernel 1 06-11-2007 03:56 AM
Max Stack Size limit on Linux 2.4 rhegde Debian 0 08-08-2006 03:18 PM
Removing 4k stack size limit on 2.6.7-1.456 Corallis Fedora 2 07-23-2004 10:46 PM


All times are GMT -5. The time now is 07:57 PM.

Main Menu
Advertisement
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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration