Keith Thompson said:
If you're "really not that technically knowledgeable", you really
should pay attention to those of us who are.
Heh...the really operative part of what I wrote above was:
Kinda like some asswipe mechanic who completely rips off old
ladies with bogus auto repairs and couldn't actually fix a car correctly
to save his worthless life...
I dangled that little piece of bait of "really not that technically
knowledgeable", and EVERY SINGLE ABUSIVE IDIOT in
this thread hit at it like a brain-damaged bass, even when told
explicitly what I was actually "angling" for.
Bottom line: there are those people who TELL you they know
everything, and then those who truly know a lot. And telling the
difference between the two is just as simple as that...
[...]
As far as the "fine" documentation is concerned, give me a break...
void _sleep(unsigned seconds);
Description
Suspends execution for an interval (seconds).
With a call to _sleep, the current program is suspended from
execution for the number of seconds specified by the argument
seconds. The interval is accurate only to the nearest hundredth of a
second or to the accuracy of the operating system clock, whichever
is less accurate.
Return Value
None.
---end of compiler package "man page"
Great. What does you're implementation's documentation say about the
clock() function?
Not that it matters, but it appears to be a typically garbled and
contradictory re-write of the standard language:
clock_t clock(void);
Description
Determines processor time.
clock can be used to determine the time interval between two events.
To determine the time in seconds, the value returned by clock should
be divided by the value of the macro CLK_TCK.
Return Value
On success, clock returns the processor time elapsed since the
beginning of the program invocation.
On error (if the processor time is not available or its value cannot be
represented), clock returns -1.
---end of compiler package "man page"
Seems to be talking out of both ends of its ass (a little like the
standard description of "clock"). By the way, I dug into the header
file and CLK_TICK is just a macro re-define of CLOCKS_PER_SEC.
Either one works the same.
Likewise, _sleep() is just a re-define of sleep(), but using sleep()
generates a warning about "obsolete function" or something like that...
[...]
* people who think that a "sleep" function on a modern
multi-tasking operating system performs a "busy-wait" because
of some interpretation of the "C" standard "requirement" for
"clock()" deserve all the abuse that can be heaped upon
their heads, 'specially if they state that they have some type
of superior technical "knowledge" that brought them to
that conclusion...
Who claimed that a sleep function performs a busy-wait?
Everybody but me!
"I have no idea how your '_sleep' function works. I suspect
that either '_sleep' delays for a specified interval of CPU time,
or your program is using exactly 1 second of CPU time per
second of real time." - "Keith Thompson"
"My guess: when you're running this process, it takes
100% of hte CPU available for the duration of hte "busy
wait" loop." - "Mark McIntyre"
"Yet you seem to be claiming in other messages that your
_sleep function does not consume any significant amount
of processor time while it is 'running'." - "Old Wolf"
Actually, one poster calling themself "buuuuuum" ran a
little test and had the same results as what I got, that clock()
on his system apparently just measures the dreaded (to
some) "wall clock" time, but nobody responded to him
because after all, he admitted he's a "buuuuuum"...
And yes, my compiler really IS broken, if the definition of
"broken" is does not meet the mealy-mouthed "standard" for
clock(). It even measures friggin USER WAIT, for cryin'
out loud. I added a gets() to my test code, and sure enough,
I can set my watch by timing the number of seconds I while
away before I press RETURN:
int main(void) {
int inc;
clock_t start,end;
for(inc=1;inc<5;inc++) {
printf("Sleeping for %d seconds\n",inc);
start=clock();
_sleep(inc);
end=clock();
printf("Slept for %f seconds\n",((end-start)/CLOCKS_PER_SEC));
}
start=clock();
printf("Press RETURN after a few well-timed seconds\n");
gets(choice);
end=clock();
printf("Delayed for %f seconds\n",((end-start)/CLOCKS_PER_SEC));
return 0;
}
So in addition to the truths I listed in my last post, add "might
as well just change your oil yourself, since the creep at the shop
will just charge you money and not even do it, and if you point
out the oil still looks dirty, will tell you that you don't know anything
about cars."
Oh, and do your own programming too...