towards an accurate delay....
John M McIntosh
johnmci at smalltalkconsulting.com
Mon Mar 11 09:29:42 UTC 2002
How come that 20ms delay took 28ms?
Well I dug around in Interpreter>>checkForInterrupts looking for clues
Now actually I've my fingers on some of the decisions in here because the
switch from 68K to powerpc lead to some issues. Many years ago I
noted that if we called this routine say 2000 times a second, the
overhead of checking for the clock added a good 4-5% to execution of
squeak. A bad thing.
So I added some throttle code to keep the calls to about 200 a
second, or every 5ms. Ah but that has some implications.
Below is a trace, diff is the difference between the wakeup time for
the next pending delay and the time now. So 10 means we overshot by
10 microseconds, we're 10ms slow.The counter is a counter that starts
at 1000 and goes up by 10 or down by 12 based on last set of numbers
which is how long between check for interrupt calls, ie (3 21 2 3 9
11) ms That mostly drives how long between checks.
so for example if you take
diff is->0 counter is->10523 2 29
diff is->14 counter is->10603
that implies we called the checkforinterrupts code again after 2ms
and 29ms then overshot a delay timmer by 14ms.
Mmm I'm sure someone could run the statistics to show if we check
every N ms, with a +/- error rate then how much of an overrun will we
have.
So were does all this lead?
Well if you want a millisecond accurate delay, then we need another
way of doing it, versus looking at the clock every millisecond. Hint
OS timers come to mind.
Then again do we care?
diff is->10 counter is->10545 4 8
diff is->7 counter is->10403 2 22
diff is->14 counter is->10483 3 21 2 3 9 11
diff is->3 counter is->10526 2 40
diff is->31 counter is->10383 5 3 3 19
diff is->5 counter is->10442 3 10
diff is->0 counter is->10523 2 29
diff is->14 counter is->10603 4 2 31 3 19
diff is->2 counter is->10764 18
diff is->4 counter is->10743 23
diff is->10 counter is->10723 6 8
diff is->7 counter is->10582 6 9
diff is->4 counter is->10442 3 27
diff is->16 counter is->10523 2 2 23
diff is->5 counter is->10703 5 4 6 4 119 4 2 3 26
--
--
===========================================================================
John M. McIntosh <johnmci at smalltalkconsulting.com> 1-800-477-2659
Corporate Smalltalk Consulting Ltd. http://www.smalltalkconsulting.com
===========================================================================
More information about the Squeak-dev
mailing list
|