Regarding threads in Linux

How many threads can one process process on Linux (RHEL-5)? Once threads are created, how many stacks can each thread get?

+3
source share
4 answers

Maximum threads: Maximum threads for a process on Linux?

Stack size:

Even if pthread_attr_setstacksize () and pthread_attr_setstackaddr () are now available, we still recommend that you not use them unless you really have good reason for this. The default stack allocation strategy for LinuxThreads is almost optimal: stacks start small (4k) and automatically grow on demand to a fairly large limit (2M). In addition, there is no portable way to evaluate thread flow requirements, so adjusting the stack size makes your program less reliable and non-portable.

(from http://pauillac.inria.fr/~xleroy/linuxthreads/faq.html )

+3
source

In the process, there is no maximum number of threads.

. , :

cat /proc/sys/kernel/threads-max

:

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

, .

+1

32- , , , , < 10 000 .

10k-, , , , , , .

, 10k, , , 64- , .

+1

The thread stack size is configured using the pthread_attr_setstack method. The number of imho threads is limited only by the resources you have, more than 2K threads work in the application that I know.

0
source

Source: https://habr.com/ru/post/1728019/


All Articles