avr-libc-dev
[Top][All Lists]
Advanced

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

[avr-libc-dev] [bug #14616] definition of sei() in interrupts.h is fault


From: anonymous
Subject: [avr-libc-dev] [bug #14616] definition of sei() in interrupts.h is faulty
Date: Fri, 23 Sep 2005 06:44:50 +0000
User-agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0)

Follow-up Comment #3, bug #14616 (project avr-libc):

Dimitry wrote:
>May be, if necessary it is better to add 'volatile' in
>definition of a concrete variable, than to endow speed always?

The problem is that declaring the variable to be volatile does not prevent
the problem. The issue is that your code example

asm volatile ("cli");
acc += val;
asm volatile ("sei");

does not result in a protection of acc += val; ! The compiler
will possibly reorder the sei such that it ends up before the
acc += val; line. I have a test case where the reordering does not depend on
whether acc is declared volatile or not! IMO, the correct specification for
gcc's asm statement in order to enforce that reordering is avoided is the
"clobber memory" information.

Since cli(); and sei() look like function calls, the user
(IMO) must have the right to assume that these statements are issued in
chronological order and are not reordered.
I agree that the performance penilty is there for a couple of cases but I
think that correctness comes first and speed second. Also because I think
that sei() is issued fairly seldomly.

Yours,

Bjoern.

    _______________________________________________________

Reply to this item at:

  <http://savannah.nongnu.org/bugs/?func=detailitem&item_id=14616>

_______________________________________________
  Nachricht geschickt von/durch Savannah
  http://savannah.nongnu.org/





reply via email to

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