[time-nuts] time-nuts Digest, Vol 66, Issue 6

Christopher Hoover ch at murgatroid.com
Mon Jan 4 04:30:57 UTC 2010


On 1/3/2010 5:53 PM, time-nuts-request at febo.com wrote:
> It's not an issue, except possibly vis-a-vis battery life in a laptop.
>    

I haven't looked at the source code, but there are other concerns with 
the "while (true) { checkStuff(); Sleep(0); }" approach.

According to the TFM, Sleep(0) is effectively a NOP when there are no 
other processes at that priorty ("If there are no other threads of equal 
priority ready to run, the function returns immediately, and the thread 
continues execution.").

It also follow from the TFM that it will keep lower priority processes 
from running at all.

For me, I'm most worried about behavior under virtualization -- this is 
unlikely to play nice under a VM  unless you choose a non-work 
conserving scheduler (which most people don't choose).

I would add that laptops are not the only machines these day that do 
effective power management.   This will likely keep your cores out of 
any P-states, and the higher power dissipation will keep fans running 
(higher).

As I mentioned off list, a better approach, if it can be made to work 
with the current code structure, is select(2) or poll(2) (or one of the 
newer variants) on UN*X..   The equivalent, TTBOMK, for Win32 is 
WaitForMultipleObjects.    All of these leave the process unscheduled 
until there I/O is available or a timeout occurs.

-ch










More information about the Time-nuts_lists.febo.com mailing list