- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
What is the maximum number of threads per process in Linux?
There are multiple ways with which we can check the maximum number of threads that Linux has allocated to a particular process.
Approach 1
cat /proc/sys/kernel/threads-max
Output
61741
We can also increase the default value set by linux with the help of the command shown below −
echo 123456789 > /proc/sys/kernel/threads-max
where 123456789 = Number of threads
Approach 2
It is also known that Linux doesn’t have a separate threads per limit and it basically implemented the maximum number of threads per process indirectly.
Command
number of threads = total virtual memory / (stack size*1024*1024)
So the threads per process can be increased by decreasing the stack size or increasing the virtual memory.
We can also increase the virtual memory on our machine with the help of the command shown below −
ulimit -s newvalue
In the above command, you should replace the new value with the value that you want to put as the limit.
The stack size can be increased with the help of the command shown below −
ulimit -v newvalue
In the above command you should replace the new value with the value that you want to put as the limit.