provide rtc-read # real time clock support code "rtc.pfo" pfo "/dev/rtc" "r" open-file constant RTC variable RTC-tickfreq : RTC-tickfreq! dup RTC rtc-freq! RTC-tickfreq ! ; 1024 RTC-tickfreq! : ms>nbticks .001 * # nb of seconds / period RTC-tickfreq @ # nb of ticks / second * # nb of ticks / period .5 + >int # round ; : rtc-flush try begin dup rtc-read again recover 2drop endtry ; : rtc-block try rtc-read recover e_eof or-throw drop dup block-read pass rtc-block endtry ; : RTC-ms-sync ms>nbticks dup if for RTC rtc-block next else # need to yield at least once !! block-poll then ; ' RTC-ms-sync is ms-sync "using RTC, with timer resolution:" p RTC-tickfreq @ p "Hz" p cr # using 0.977 ms resolution. need this as root: # mknod /dev/rtc c 10 135 # echo 1024 > /proc/sys/dev/rtc/max-user-freq