Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I think I have found something that I need from the Linux kernel that is not currently implemented.

I need a way to set a max thread limit per process.

Is this possible?

share|improve this question
1  
Just curious, why you need to limit the number of threads per process? –  Andrew Case Aug 16 '12 at 22:04
    
Are you trying to set a system-wide limit on threads per process? Or are you trying to make it so that a particular process can set its own thread limit? Or what? –  David Schwartz Aug 17 '12 at 0:12
    
I was hoping for the following functionality: "setthreadlimit -p 12543 -l 40" where -p is the pid and -l is the thread limit. So I want to be able to set a particular thread limit for a certain pid. –  cat pants Aug 17 '12 at 17:25

1 Answer 1

up vote 4 down vote accepted

From StackOverflow:

Linux doesn't have a separate threads per process limit, just a limit on the total number of processes on the system (threads are essentially just processes with a shared address space on Linux) which you can view like this:

cat /proc/sys/kernel/threads-max

The default is the number of memory pages/4. You can increase this like:

echo 100000 > /proc/sys/kernel/threads-max

There is also a limit on the number of processes (an hence threads) that a single user may create, see ulimit/getrlimit for details regarding these limits.

share|improve this answer
    
"Linux doesn't have a separate threads per process limit, just a limit on the total number of processes on the system" So it looks like what I need is not currently possible. Time to go bug the kernel devs? :P (not really though) Thanks! –  cat pants Aug 20 '12 at 19:47

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.