Georg Bauhaus <[EMAIL PROTECTED]> writes:

| Joe Buck wrote:
| 
| > Are you using "volatile" correctly?  There are situations where "volatile"
| > alone does not suffice and you need more locking, but the Linux and BSD
| > kernel folks manage to optimize their device driver code.
| 
| We have just been discussing a similar topic in a de.* newsgroup.
| 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)
|           ;

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.

-- Gaby

Reply via email to