Reputation: 2370
Does anyone know how to estimate the remaining parallel threads for user processes on a machine with N cores with hyper-threading enabled (i.e. there are 2*N parallel jobs). How many cores are taken up by the OS, e.g. Ubuntu?
Upvotes: 0
Views: 207
Reputation: 17169
Your OS implements preemptive multitasking. This means in particular, that no thread is getting hold of a core exclusively. Instead the slices of CPU time are distributed between the threads that are ready to continue. Such redistribution occurs many times within each second.
The uptime
command in Linux can tell you how many threads on average were ready to run within the last 1, 5 and 15 minute intervals.
$ uptime
23:18pm up 15:17, 3 users, load average: 0.73, 0.62, 0.74
Here we have about 0.7, less than 1 thread on average. Not a very busy machine.
On a busy machine this number may exceed the number of available logical CPUs. Therefore if your 2n user processes are indeed always ready to use the CPU and do not give it away because they are waiting for data from RAM or I/O, then the number of operating system threads can be estimated as
current load average - 2n
In the example above this formula would not work, since user processes are waiting for user input or I/O and the CPU is mostly idle.
Upvotes: 1