4 ms·
Does the CPU interrupt threads running happily on cores even when there are no other threads which want to run or which have affinity that would allow them to r
by chrisseaton 10y ago
Does the CPU interrupt threads running happily on cores even when there are no other threads which want to run or which have affinity that would allow them to run on that core?
But creating more threads will cause each to run slower as their caches are ruined by each context switch aren't they?
- otabdeveloper 10y ago> Does the CPU interrupt threads running happily on cores even when there are no other threads which want to run or which have affinity that would allow them to run on that core? Yes. Even if you are careful to ever run only one process (so: no monitoring, no logging, no VM's, no 'middleware', etc.) and limit the number of threads to strictly equal the number of processors, you still have background kernel threads that force your process to context switch.
- gpderetta 10y agoTough you can instruct the kernel not to run anything (not even interrupt handlers) on specific cores, except for manually pinned processes.
- marcosdumay 10y agoYes, it does interrupt them, but if the kernel decides to keep the same thread there's no context switch. (In other words, there's a penalty, but it is much smaller.) Your conclusion is correct. By creating more CPU hungry threads than you have CPUs you will reduce the total throughput of the computer.