Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Yes, it is possible and it happens pretty often.<br/>The OS <em>tries</em> to not switch one thread between CPUs (you can make it try harder setting the threads <em>preferred processor</em>, or you can even lock it to single processor via affinity).<br/>Windows' process is not an execution unit by itself - from this viewpoint, its basically just a context for its threads.</p> <p><strong>EDIT</strong> (further clarifications)</p> <p>There's nothing like a "process context switch". Basically, the OS scheduler assigns the threads via a (very adaptive) round-robin algorithm to any free processor/core (as the affinity allows), if the "previous" processor isn't immediately available, regardless of the processes (which means multi-threaded processes can steal much more CPU power).</p> <p>This "jumping" may seem expensive, considering at least the L1 (and sometimes L2) caches are per-core (apart from different slot/package processors), but it's still cheaper than delays caused by waiting to the "right" processor and inability to do elaborate load-balancing (which the "jumping" scheme makes possible).<br/>This <em>may</em> not apply to the NUMA architecture, but there are much more considerations invoved (e.g. adapting all memory-allocations to be thread- <em>and</em> processor-bound and avoiding as much state/memory sharing as possible).</p> <p>As for affinity: you can set affinity masks per-thread or per-process (which supersedes all process' threads' settings), but the OS enforces least one logical processor affiliated per thread (you <strong><em>never</em></strong> end up with a zero mask).</p> <p>A process' default affinity mask is inherited from its parent process (which allows you to create single-core loaders for problematic legacy executables), and threads inherit the mask from the process they belong to. </p> <p>You may <em>not</em> set a threads affinity to a processor outside the process' affinity, but you can further limit it.</p> <p>Any <strong>thread</strong> by default, <strong><em>will</em></strong> jump between the available logical processors (especially if it yields, calls to kernel, etc), <strong><em>may</em></strong> jump even if it has its <em>preferred processor</em> set, but only if it has to, but it <strong><em>will NOT</em></strong> jump to a processor outside its affinity mask (which may lead to considerable delays).</p> <p>I'm not sure if the scheduler sees any difference between physical and hyper-threaded processors, but even if it doesn't (which I assume), the consequences are in most cases not of a concern, i.e. there <em>should not</em> be <em>much</em> difference between multiple threads sharing physical or logical processors if the thread count is just the same. Regardless, there <em>are</em> some reports of cache-thrashing in this scenario, mainly in high-performance heavily multithreaded applications, like SQL server or .NET and Java VMs, which <em>may</em> or may not benefit from HyperThreading turned off.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload