Windows – What causes Context Switching on Windows

multi-threadingprocesswindows

On Linux context switching can occur because an application makes a system call, or because the scheduler swaps processes out of the CPU for another process.

On Windows what are the possible causes of a context switch? Specifically, from the literature I have read, high thread count is the only cause of high context switching I have run into so far. Are there others?

Finally, is the cost of swapping out two threads of the same process different than the cost of swaping out two different processes?

Best Answer

The ability to do context switching is an essential component for any multitasking OS. The same type of things that cause context switching in Linux would cause context switching in Windows as well.

All a high thread count means is that the CPU will be forced to switch contexts more often to fulfill the processing requirements of the scheduler.