From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.5-pre1 (2020-06-20) on ip-172-31-74-118.ec2.internal X-Spam-Level: X-Spam-Status: No, score=-0.0 required=3.0 tests=BAYES_20 autolearn=ham autolearn_force=no version=3.4.5-pre1 Date: 18 Sep 92 23:52:38 GMT From: sampson@cod.nosc.mil (Charles H. Sampson) Subject: Re: Using Global Variables Message-ID: <1992Sep18.235238.25207@nosc.mil> List-Id: In article <16864C1E7.M19481@mwvm.mitre.org> M19481@mwvm.mitre.org writes (in response to a question I posed about why anyone needs to use global variables): >The main reason I've heard used to justify the use of global variables is >performance of a real-time system. The argument goes that the overhead of >parameter passing is just too high to meet the performance requirements on >the target machine (which cannot be changed), hence global variables. Now >you may argue that the target machine should have been chosen more wisely, >or the choice delayed until after the software was totally developed so as >to be able to pick the right size machine -- but I imagine that that's what >Mr. Goffin had in mind when he used the term "real world." > >David - dhite@mitre.org On a lot of target architectures the major part of subprogram overhead in a recursive, stack-oriented language, like Ada, is in setting up the stack frame, which is often done by a call to a utility routine if the architecture is hostile enough. This overhead is paid on any call, even for parameterless subprograms, in order to allocate space on the stack for local data. On the other hand, parameter passage is usually pretty cheap, depending on the architecture and the cleverness of the compiler writers. So, my question now is: For those real-time systems for which global vari- ables are used instead of expensive parameter passage, was that decision based on inherent limitations of the hardware, lack of cleverness by the compiler writers, or poor analysis of the actual costs of parameter pas- sage? Charlie