From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.3 required=5.0 tests=BAYES_00,INVALID_MSGID, LOTS_OF_MONEY autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,567f87f476bd8e1c X-Google-Attributes: gid103376,public From: Alan Brain Subject: Re: Tips for realtime embedded Ada? Date: 1996/04/18 Message-ID: <4l54f0$sg0@fred.netinfo.com.au>#1/1 X-Deja-AN: 148160294 references: <4ku9jf$b7u@hacgate2.hac.com> content-type: text/plain; charset=us-ascii organization: At Home mime-version: 1.0 newsgroups: comp.lang.ada x-mailer: Mozilla 1.2N (Windows; I; 16bit) Date: 1996-04-18T00:00:00+00:00 List-Id: John Gluth wrote: >Howdy, > >I'm looking for wisdom regarding designing software for a realtime >embedded application. > >Can you suggest constructs, design philosophies, etc. to use/avoid >to avoid inefficient code? > >I realise that a lot of this will be compiler/platform dependent >(looks like we'll be going Rational/PowerPC, but not sure yet), >but any general tips you can suggest would be greatly appreciated. You mentioned 'Inneficient' - so I have assumed you want Best Possible performance, and Maintainability, Ease of Construction etc is secondary. 1) Don't use Tasking except as a Guardian of resources. Very few compilers do context-switching efficiently. Write a scheduler in assembler, or if you can, microcode. 2) The difference between efficiency of compiled code can be radically affected by the compiler you're using, and the version thereof. A 1994 vintage Ada 83 compiler will in my experience almost always generate much more efficient code than a 1990 ANSI C Compiler - but the converse holds true too. Thus the decision on whether to go for 100% Ada, or 80% with lots of pragma interfaces to C libraries, is intimately tied in with the exact compiler(s) you're using. 3) Keep it simple. 4) Design cleanly: Then go through with the performance analyser, trying to find the areas most often executed: often 100 hours of work here to save 2 machine cycles gives far better results than spending 1000 hours to save 2000 cycles elsewhere. FWIW, I've had really time-critical applications where much skull sweat was spent deciding whether to implement a bespoke scheduler, how much was to be in assembler, how much in C, whether to use Ada at all etc. I convinced management we needed a 'proof-of-principle' using a clean, unoptimised design in Ada first, with all checking mechanisms left in. It exceeded the specified speed by 14% at the first attempt, saving about two million bucks, because all estimations had been done with a 1984 model Ada compiler vs a 1989 model C compiler, and we used a 1992 model Aad compiler from a different vendor. Hence 3) above.