> Joe Buck wrote:
>>Georg Bauhaus <[EMAIL PROTECTED]> writes:
>> | A busy-loop function is used to effect a delay, not too precise,
>> | but portably. Like
>> | 
>> | #define COUNT 1000
>> | 
>> | void f() {
>> |    /*volatile*/ /*register*/ int i;
>> | 
>> |    for (i = 0; i < COUNT; ++i)
>> |           ;
>
> >On Sat, Apr 02, 2005 at 01:48:56AM +0200, Gabriel Dos Reis wrote:
>> This must be an FAQ.  The above is no way of (no matter how popular
>> the urban legend makes it) implementing delay.  Adding a #pragma just
>> makes teh situation worse.
>
> Unfortunately, where there is a good argument for not using empty loops
> as busy-waits, at one time it was documented GCC behavior that it would
> work, so we can't really blame the users for trusting the doc.
> 
> That's not to say that it was ever a good idea, because of the lack of
> control.  If you need a precisely timed busy-wait, an inline assembly
> construct is the best bet.

Fully agree, a C based delay loop which easily has a 2x margin of error
is basically useless (even if the clock frequency were precisely known).



Reply via email to