3

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?

  • 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
6

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.

  • 1
    "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

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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