Path: utzoo!mnetor!uunet!husc6!rutgers!mtunx!whuts!homxb!houxs!daw From: daw@houxs.UUCP (David Wolverton) Newsgroups: comp.lang.c Subject: Re: Volatile is Necessary Message-ID: <807@houxs.UUCP> Date: 31 Mar 88 14:40:45 GMT References: <8107@sol.ARPA> <77200028@uiucdcsp> Organization: AT&T Data Systems Group, Holmdel, NJ Lines: 26 Summary: folks are missing the point In article <77200028@uiucdcsp>, gillies@uiucdcsp.cs.uiuc.edu writes: [stuff deleted about multiprocessing] > THE ONLY reason to keep it [volatile] in the language is if you can argue it's > important for uniprocessing.... [I think this discussion is getting sidetracked. The question is whether the volatile type qualifier should have been included in the ANSI C (draft) standard.] As an implementor of an optimizer, I rejoiced when I saw that the committee had added 'volatile' to the language. The point of volatile is that 98% of a program's variables (and 99% in portable programs) will *not* be qualified with 'volatile', which allows optimizers to make assumptions about the optimizations which can be applied to a variable. Without 'volatile', the optimizer has to use a pessimistic assumption about the variables so that it won't stomp on the 1-5% of the variables which care about it! 'volatile' is *not* present to help any specific thing like interrupt handlers, multiprocessing, shared memory, etc. Rather, it helps them all, because its *absence* in "normal" code tells the optimizer that none of those funky things are happening behind its back. That is why 'volatile' is in the language. Dave Wolverton AT&T