Author: wmb Date: 2007-08-31 03:04:52 +0200 (Fri, 31 Aug 2007) New Revision: 590
Added: forth/lib/wrtime.fth Log: Added forth/lib/wrtime.fth - interval delays using wrapper calls.
Added: forth/lib/wrtime.fth =================================================================== --- forth/lib/wrtime.fth (rev 0) +++ forth/lib/wrtime.fth 2007-08-31 01:04:52 UTC (rev 590) @@ -0,0 +1,15 @@ +purpose: Timing using wrapper calls + +: get-usecs ( -- d.usec ) + d# 348 syscall retval 2@ ( usec sec ) + d# 1,000,000 um* rot 0 d+ +; + +\ We really should call usleep, but that wrapper doesn't have that +: (us) ( d.microseconds -- ) + get-usecs d+ ( d.target-time ) + begin 2dup get-usecs d- d0< until ( d.target-time ) + 2drop +; +: us ( microseconds -- ) 0 (us) ; +: ms ( milliseconds -- ) d# 1000 um* (us) ;