Path: utzoo!utgpu!news-server.csri.toronto.edu!rutgers!ucsd!sdd.hp.com!samsung!uunet!metaware!johnv From: johnv@metaware.metaware.com (John Vinopal) Newsgroups: comp.unix.internals Subject: Re: Can Unix sleep in terms of mili/micro? Message-ID: <595@metaware.metaware.com> Date: 13 Sep 90 18:56:42 GMT References: <24437@adm.BRL.MIL> <84@dlss2.UUCP> Reply-To: johnv@metaware.COM (John Vinopal) Distribution: usa Organization: Metaware Incorporated, Santa Cruz, CA Lines: 48 I seem to recall mutchler@zule.EBay.Sun (Dan Mutchler) saying: > james@dlss2.UUCP (James Cummings) writes: > In article <24437@adm.BRL.MIL> TAYBENGH%NUSDISCS.BITNET 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. > > main() > { > sleep_less_than_sec(25); > exit(0); > } > > sleep_less_than_sec(x) > int x; > { > int i; > > for (i = 0;i <= x;i++) > ; > } > > I'd think that would give you approx. 25 clock cycles, dependent on > the machine, the load on the machine, etc. You assume that you have a remarkably dumb compiler. How is that code any different to an optimizing compiler than say: #define DEBUG 0 foobar(int x) { int i; for (i = 0; i <= x; i++) if ( DEBUG ) { crash_n_burn(); } } You wouldn't want THAT code stuck in your executable now would you? Both come out to be NULL and both should be removed! Optimize, optimize, optimize! -- The Wailer at the Gates of Dawn | johnv@metaware.com | #include | uunet!metaware!johnv | void puke(struct dinner *p) { free(p); } | banshee@ucsc{b,f}.UCSC.EDU | 2,3,5,7,13,17,19,31,61,89,107,127,521,607....| banshee@ucsc{b,f}.BITNET |