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

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

Re: [avr-gcc-list] generic queue library for AVR GCC?


From: Richard Urwin
Subject: Re: [avr-gcc-list] generic queue library for AVR GCC?
Date: Thu, 18 Nov 2004 08:12:35 +0000
User-agent: KMail/1.5.3

On Wednesday 17 Nov 2004 8:07 pm, Mike Panetta wrote:
> On Wed, 2004-11-17 at 12:30, E. Weddington wrote:
> > David Brown wrote:
> > >Personally, I'd like to see the addition of a "critical" function
> > > attribute, like in mspgcc.  It is clearly readable, avoids any
> > > requirements for extra local variables, generates optimal code,
> > > and generates any required "goto out" automatically.  You can use
> > > it on inlined functions to avoid function call overheads if you
> > > want.
> >
> > I think that's a *great* idea!

> ACK!  NOO!!  Its bad bad bad.  It hides the fact that the function is
> critical so well that it makes it many times easier to make a simple
> mistake that would throw interrupt latency (or worse) all to hell,
> and the programmer may not even know why!

Just catching up here. I was mainly having fun, seeing how the standard 
C constructs could be used for this simple task. And (even) I learned 
something; why use do while(0) instead of just a pair of braces.

In my view, a critical section is simple enough that it should be 
programmed directly, using any of the methods given. The code in the 
section must be simple enough that it is efficient. Any more complex 
code should be protected by semaphores, themselves implemented with 
critical sections. In a large project you should probably only use 
semaphores in the interests of clarity. We lose clarity and ease of 
maintenance by coding the sections explicitly, but we gain efficiency. 
Embedded code is always about finding the happy medium between the two.

-- 
Richard Urwin


reply via email to

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