[squeak-dev] Re: Delay time question

John M McIntosh johnmci at smalltalkconsulting.com
Thu Feb 28 07:48:19 UTC 2008


On Feb 27, 2008, at 11:38 PM, Andreas Raab wrote:

> Also, keep in mind that no amount of C coding will increase the  
> accuracy of your OS' default timer. But if you happen to have a high- 
> quality timer it would be quite trivial to link this timer to the  
> TimerSemaphore and use it instead of whatever the VM gives you.
>
> Cheers,
>  - Andreas
>

I can't speak for Windows works but the magic on unix systems happens  
in ioRelinquishProcessorForMicroseconds

getNextWakeupTick()  is the known time we must wakeup to service the  
next delay, that is the delay wants to terminate then.

    setInterruptCheckCounter(0);   <= this ensure the interpreter  
interrupt logic fires really soon after we finish this call to switch  
perhaps to the other runable process

     now = (ioMSecs() & MillisecondClockMask);
     if (getNextWakeupTick() <= now)
         if (getNextWakeupTick() == 0)   <- with morphic this never  
happens
             realTimeToWait = 16;    <--- this value might be platform  
dependent
         else {
             return 0;  <= if time now is after the time of the next  
wakeup don't sleep.
     }
     else
         realTimeToWait = getNextWakeupTick() - now;    <==== this is  
where we estimate how long to sleep.

	platformSleep(realTimeToWait*1000);  <=== accuracy dictates how delay  
behaves.



--
= 
= 
= 
========================================================================
John M. McIntosh <johnmci at smalltalkconsulting.com>
Corporate Smalltalk Consulting Ltd.  http://www.smalltalkconsulting.com
= 
= 
= 
========================================================================





More information about the Squeak-dev mailing list