bcx@eeg.UUCP (07/11/86)
I am trying to develope a sleep() function under Latice C that takes an argument in milliseconds. I tried BIOS interupt 15 function 86, with no luck. Any and all help will be greatly appreciated. -- Bryan Costales, EEG Systems Laboratory 1855 Folsom St, San Francisco, Ca 94103 (415) 621-8343 {ihnp4,lll-crg,dual,qantel,pyramid}!ptsfa!eeg!bcx
bc@cyb-eng.UUCP (07/15/86)
> I am trying to develope a sleep() function under Latice C that > takes an argument in milliseconds. I tried BIOS interupt > 15 function 86, with no luck. Any and all help will be greatly > appreciated. > -- > Bryan Costales, EEG Systems Laboratory The following works (I use Lattice 2.15 still) in tenths of a second. Presumably, the factor could be changed to from 1.82 to 182. to get milliseconds, but I would watch out for the overhead of the functions themselves, especially since I have dragged in the floating point divide. I expanded the register union from a header file from memory. I hope I got it right. ------------------------------ cut here --------------------------------- static union { struct { unsigned ax; unsigned bx; unsigned cx; unsigned dx; unsigned si; unsigned di; } x; struct { char al; char ah; char bl; char bh; char cl; char ch; char dl; char dh; } h; } regs; #define TIME_OF_DAY 0x1A /* --------------------------------------------------------------------- now obtains the value of the tick counter expressed as a long in tenths of a second. --------------------------------------------------------------------- */ long now () { regs.x.ax = 0; int86 (TIME_OF_DAY, ®s, ®s); return (long) ((((long) regs.x.cx << 16) | (long) regs.x.dx) / 1.82); } /* --------------------------------------------------------------------- sleep causes the program to be put to sleep (to pause) for the given period, expressed in tenths of a second. --------------------------------------------------------------------- */ sleep (dur) unsigned dur; { long time, now(); time = now(); while (now() - time < (long) dur) ; } -- bc Bill Crews @ NetCor Data International, Inc ..!{seismo,gatech,ihnp4}!ut-sally!cyb-eng!bc (512) 835-2266