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: Ben L. Titzer
Subject: Re: [avr-gcc-list] generic queue library for AVR GCC?
Date: Wed, 17 Nov 2004 10:12:21 -0800


On Nov 17, 2004, at 10:05 AM, address@hidden wrote:

   Date: Wed, 17 Nov 2004 10:30:24 -0700
   From: "E. Weddington" <address@hidden>
   To: David Brown <address@hidden>
   Subject: Re: [avr-gcc-list] generic queue library for AVR GCC?
   Cc: avr-gcc-list <address@hidden>

   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!

Wouldn't that require a change to the syntax of the c language?  Not
that it's a bad idea but just don't expect to see it soon unless
someone else has already proposed it to whatever committee oversees
the language.

As an aside, Java has a construct that would help here; you can put a
"try" around code that might fail and have a "finally" block that
always gets executed:

        try {
            begin_critical();
            if (something_fails())
                return;
            more_code();
        }
        finally {
            end_critical();
        }

So even though there's a "return" in the try block, the "finally"
block will still get executed before the "return".

(I've been a c programmer for years and have just recently dipped my
toes in the Java waters.  Java does have some nice ideas.)



Better yet, Java has its own locks--object monitors--that are automatically released by the VM when the stack is being unwound after an exception. It also has condition variables--Object.wait() and Object.notifyAll()--so implementing queues, lists, etc, is extremely easy.

-B

========================================================
Opportunity is missed by most people because it is dressed in overalls and looks like work.
-- Thomas Edison



reply via email to

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