Link to home
Start Free TrialLog in
Avatar of bachra04
bachra04Flag for Canada

asked on

pthread stack size on linux

Is it a good practice to specify the thread size at the time of the thread creation ?

I thought that this is better handled by the OS.
Any reference to this ?

Thanks
Avatar of David Favor
David Favor
Flag of United States of America image

Usually best to allow OS to manage this + then use ulimit -s in a startup script to change this on a per application basis.

All applications are different, so if you hit a limit, you'll have to determine if writing code is better or ulimit changing is better.
Avatar of phoffric
phoffric

What issue with the stack size are you concerned about? Maybe good practice for one issue is not good for another.
What OS version and platform are you dealing with?
Avatar of bachra04

ASKER

linux and QNX, some people are concerned about the limit of the stack size ( apparently some issues seen in the past).
ASKER CERTIFIED SOLUTION
Avatar of phoffric
phoffric

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thanks. Is there any good reference to  understand virtual memory vs physical memory and how it can be contiguous on the virtual side but not necessarily contiguous on the physical side ?
This video playlist is very well presented by a Stanford researcher.
https://www.youtube.com/watch?v=qcBIvnQt0Bw&list=PLiwt1iVUib9s2Uo5BeYmwkDFUh70fJPxX


If this aspect of computer architecture interests you, then here is a more in-depth video course given at Georgia Tech. (It's free if you do not want credit.) It goes well beyond the above discussion.
https://www.youtube.com/watch?v=Dz9Hgq65iJw&index=1&list=PLAwxTw4SYaPn79fsplIuZG34KwbkYSedj

If you prefer reading over watching videos, here is a good discussion of linux memory management. Take a look at the section on Demand Paging.
http://www.tldp.org/LDP/tlk/mm/memory.html

Here is Red  Hat documentation on Physical and Virtual Memory:
https://access.redhat.com/documentation/en-US/Red_Hat_Enterprise_Linux/4/html/Introduction_To_System_Administration/ch-memory.html


After going through the above, you probably won't be needing the wiki page:
https://en.wikipedia.org/wiki/Virtual_memory