Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!swrinde!mips!prls!philabs!sxm From: sxm@bebop.Philips.Com (Sandeep Mehta) Newsgroups: comp.unix.internals Subject: Re: Can Unix sleep in terms of mili/micro? Message-ID: Date: 13 Sep 90 13:36:08 GMT References: <24437@adm.BRL.MIL> <84@dlss2.UUCP> Sender: news@philabs.Philips.Com Organization: Autonomous Systems, Philips Labs, Briarcliff Manor, NY Lines: 41 In-reply-to: mutchler@zule.EBay.Sun's message of 11 Sep 90 21:05:10 GMT Distribution: james@dlss2.UUCP (James Cummings) writes: TAYBENGH%NUSDISCS.BITNET@cunyvm.cuny.edu writes: > > Can Unix sleep in terms of mili or mirco second? I am aware that >sleep() can only sleep in terms of second. Please specify the Unix Dialect >when u reply. Thanks. How 'bout: sleep_less_than_sec(x) int x; { int i; for (i = 0;i <= x;i++) ; } For many (obvious) reasons a dummy loop is not the best idea. Besides you may not have a real time clock in your UNIX box, e.g., Sun 3's (at least the ones I use) use the Intersil 7170 "real-time" clock in 100 Hz periodic mode, giving a resolution of only 10 milliseconds. Using the clock(3C) function yields CPU time used only up to a 16.667 milliseconds accuracy. Sun 3 (SunOS 4.0) getrusage() assumes tick intervals of 20msec, for Sun 4's 10msec. I know that struct timerval' has a "usec" field but of course the value is hardware dependent. You might write your own little assembler routine to use a spare counter or something (not advisable :-)) which will suffer from all the restrictions of the process that uses it. I know that some folks @ Berkeley have a real-time timer facility for Sun 3's under SunOS and it's (h'ware + s'ware) pretty cheap. But then again, is UNIX/SunOS real-time ? Don't know if I answered the question either ? sandeep -- sxm@philabs.Philips.Com "Jazz is Happiness" - Le Sony'Ra