Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the maximum number of threads a process can have in windows

Tags:

In a windows process is there any limit for the threads to be used at a time. If so what is the maximum number of threads that can be used per process?

like image 722
CodeRider Avatar asked May 23 '13 09:05

CodeRider


People also ask

How many threads can Windows 10 handle?

Windows 10 limits max number (32) of threads with MMCSS priority, affecting Digital Audio Workstation software on multi-core CPUs.

How many threads can a process have?

Every process has at least one thread, but there is no maximum number of threads a process can use. For specialized tasks, the more threads you have, the better your computer's performance will be. With multiple threads, a single process can handle a variety of tasks simultaneously.

How many threads can windows server handle?

Each core can only run 1 thread at a time, i.e. hyperthreading is disabled. So, you can have a total maximum of 20 threads executing in parallel, one thread per CPU/core.

Is there a limit on the number of threads?

The maximum threads setting specifies the maximum number of simultaneous transactions that the Web Server can handle. The default value is greater of 128 or the number of processors in the system. Changes to this value can be used to throttle the server, minimizing latencies for the transactions that are performed.


1 Answers

There is no limit that I know of, but there are two practical limits:

  1. The virtual space for the stacks. For example in 32-bits the virtual space of the process is 4GB, but only about 2G are available for general use. By default each thread will reserve 1MB of stack space, so the top value are 2000 threads. Naturally you can change the size of the stack and make it lower so more threads will fit in (parameter dwStackSize in CreateThread or option /STACK in the linker command). If you use a 64-bits system this limit practically dissapears.
  2. The scheduler overhead. Once you read the thousands of threads, just scheduling them will eat nearly 100% of your CPU time, so they are mostly useless anyway. This is not a hard limit, just your program will be slower and slower the more threads you create.
like image 139
rodrigo Avatar answered Sep 18 '22 11:09

rodrigo