Path: utzoo!mnetor!uunet!lll-winken!lll-lcc!ames!umd5!brl-adm!adm!christiansen@chewi.che.wisc.EDU From: christiansen@chewi.che.wisc.EDU (REED CHRISTIANSEN) Newsgroups: comp.lang.c Subject: A different view of volatile Message-ID: <13120@brl-adm.ARPA> Date: 26 Apr 88 18:23:02 GMT Sender: news@brl-adm.ARPA Lines: 48 > >From: Hank Dietz >Subject: A different view of volatile >Message-ID: <7996@pur-ee.UUCP> >Date: 26 Apr 88 00:29:37 GMT > > [Text Deleted. Professor Dietz proposes the use of REGISTER to denote > data objects that cannot possibly be VOLATILE, since a REGISTER item > does not have an address.] > >although I have nothing against volatile, per se, isn't it better to go with >the more aggressive compiler optimization only when a person has specifically >hinted that it's ok, as opposed to the "volatile" scheme of aggressively >optimizing unless you're told no? Besides, by now we all know how to spell >"register." My observation is that the number of data items in a program that are VOLATILE (that is, whose value(s) can change asynchronously due to action by another process or by hardware action) is very small. Even in implementing real-time process control systems, the D/A and A/D handlers are a small portion of the entire package. It seems much easier to declare these few variables as special cases than to declare all non-special variables to be REGISTER. I have no problem with aggressive optimization--I would prefer that the compiler do as much optimization as it can, as long as I can point out the VERY FEW data items that are non-deterministic. In fact, our never-ending problem is to squeeze more complicated mathematical models into our real-time packages in order to do state-estimation, etc. The faster these computational loops run, the more realistic our models can become. If you hate VOLATILE and need to do real-time work, you have these options: (1) Optimize and use REGISTER, which is a burdensome but workable alternative, requiring one to modify 90+% of declarations in one's code from conventional C technique [TEDIOUS BUT SUITABLE CHOICE], (2) Don't optimize, which will limit your ability to do computations in real-time loops [VERY BAD CHOICE], (3) Optimize computational modules; don't optimize the control loops; make sure there is no module with both, document what you're doing, and hope that the next fool to work on your project understands what is going on [POTENTIALLY DANGEROUS CHOICE]. I prefer VOLATILE. ------