8 Sep
2013
8 Sep
'13
6:17 p.m.
El 08/09/2013 7:39, Gottlob Frege escribió:
I haven't looked at the code, but I see mention of Sleep(0) here. Does everyone realize the special behavior of Sleep(0) ?
It only gives up a timeslice to threads of >= priority. Starving lower priority threads (if you were to spin with only that).
Yes we take in care this Sleep(0) behaviour. In fact Sleep was changed starting with Windows Server 2003 and now it can relinquish the remainder of its time slice to any other thread that is ready to run. The code uses a combination of SwitchToThread + Sleep(0) plus Sleep(1) to avoid starvation. Best, Ion