[fpc-pascal] fpnanosleep (again)
John Coppens
john at jcoppens.com
Thu Nov 8 02:37:51 CET 2007
On Wed, 7 Nov 2007 19:27:39 -0300
John Coppens <john at jcoppens.com> wrote:
> Is there any simple way (short of writing a kernel module) of delaying
> less than the HZ value?
Very unelegant, but it works:
procedure usleep(time: longint);
var
tv: timeval;
tz: timezone;
diff,
ref: clong;
begin
fpGetTimeOfDay(@tv, @tz);
ref := tv.tv_usec;
repeat
fpGetTimeOfDay(@tv, @tz);
diff := tv.tv_usec - ref;
if diff < 0 then
diff := diff + 1000000;
until diff > time;
end;
in case someone is interested.
John
More information about the fpc-pascal
mailing list