avr-gcc-list
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[avr-gcc-list] race condition in sleep_mode()


From: Andreas Kaiser
Subject: [avr-gcc-list] race condition in sleep_mode()
Date: Sun, 18 Dec 2005 23:39:22 +0100

On Sun, 18 Dec 2005 20:37:51 +0100 (MET), address@hidden (Joerg
Wunsch) wrote:

>That one looks a bit more sophisticated than your proposal (at least
>from the description, I didn't really examine the patch itself), so
>I'm considering to add it within the next couple of days.

While the patch solves my problem, IMHO it violates the principles of
the C language and looks like a perfect example for some peoples
arguments to remove the preprocessor from the language.

sleep_if() looks like a function call, yet it cannot be implemented as
such, not even inlined, because it no longer works if the argument is
processed the way C arguments are - the condition must be evaluated
with interrupts disabled, thus from within the call beyond the cli
(I've heard Algol had such a parameter passing concept). Also it
limits the condition to an expression. More complex conditions which
cannot easily be passed as a condition argument cannot be used.

I prefer a more general solution. When dealing with race conditions,
the programmer must unavoidably be aware of interrupt control anyway,
so I'd rather not to hide the facts and use
        cli
        if condition is met
                sleep_xxx()
        sei
instead.

>(Btw., if you resend your message from a different address as you've
>been told the first time the message is held for approval, please also
>take the time to withdraw your first message.)

Sorry. Cancelling mails does not seem to be a feature offered by the
mail/newsreader used. I've sent the 2nd before I got the note,
expecting the 1st one to be silently deleted by a spam filter.

Gruss, Andreas





reply via email to

[Prev in Thread] Current Thread [Next in Thread]