Open recumbentbirder opened 5 years ago
To get this correct in Android is probably quite tricky due to the moving between C and Java, thus I am not surprised by your observation. If you look at the same for a desktop platform, which natively runs C-compiled code, you should be able to do much smaller periods.
Thanks so far! Will look into it.
For now, I use this:
(define (wait msec)
(do ((t (current-milliseconds)))
((>= (current-milliseconds) (+ t msec)))
))
Which isn't a work of beauty because of CPU load. But does what it's supposed to.
I can't think of anything else to suggest at the moment, but if I do I'll let you know. Similarly, if you could share any better ideas you come across this would be appreciated!
I try to time space sampling from the accelerometer, at the moment on Android. To get a sampling rate of 50 Hz, I need a sleep of +/- 0.02 ms (depending on data fetching from the accelerometer, but that is fast).
I now found, that the call to
thread-sleep!
itself takes between 15 and 33 ms, even for very small values of the parameter:Not so, though, for
(thread-sleep! 0
, which probably just returns immediately.Is there an alternative to
thread-sleep!
or some hint on how to get a reliable sleep for small values?