Can Unix sleep in terms of mili/micro?
John Vinopal
johnv at metaware.metaware.com
Fri Sep 14 04:56:42 AEST 1990
I seem to recall mutchler at zule.EBay.Sun (Dan Mutchler) saying:
> james at dlss2.UUCP (James Cummings) writes:
> In article <24437 at 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 at metaware.com |
#include <vomit.h> | uunet!metaware!johnv |
void puke(struct dinner *p) { free(p); } | banshee at ucsc{b,f}.UCSC.EDU |
2,3,5,7,13,17,19,31,61,89,107,127,521,607....| banshee at ucsc{b,f}.BITNET |
More information about the Comp.unix.internals
mailing list