Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How often per second does Windows do a thread switch? [closed]

How often does Windows (usually) do a thread switch per second? Is this different from .NET threads? Or asked the other way around: How long is a thread (of, say, normal thread priority) allowed to run?

like image 892
Sebastian Krysmanski Avatar asked Sep 07 '12 15:09

Sebastian Krysmanski


1 Answers

How often Windows context switches depends on the system "quantum". This quantum ranges from 10-15 milliseconds (66-100 times per second) depending on whether the OS is client or server. For more detail I recommend reading Joe Duffy's book Concurrent Programming on Windows; it goes into great detail about things like this--e.g. details that "client OSes ... is 2 clock intervals. ...on server OSes... is 12 clock intervals". Also, his article [CLR Inside Out: Using concurrency for scalability][1] is a must read.

You can sort of "edit" the quantum length. If you set the "Adjust for best performance of:" in Performance Options/Advanced in System Properties to "Programs", you'll get a shorter quantum. If you set it to "Background services" you'll get a longer quantum.

If there's no reason to context switch, a thread will get as much time as it needs.

[1] http://www.360doc.cn/article/28217_2474333.html

like image 136
Peter Ritchie Avatar answered Sep 21 '22 12:09

Peter Ritchie