Path: utzoo!utgpu!water!watmath!clyde!att-cb!osu-cis!tut.cis.ohio-state.edu!husc6!cmcl2!rutgers!rochester!crowl From: crowl@cs.rochester.edu (Lawrence Crowl) Newsgroups: comp.lang.c Subject: Volatile is Necessary Message-ID: <8107@sol.ARPA> Date: 27 Mar 88 18:51:27 GMT References: <12578@brl-adm.ARPA> <1988Mar25.172355.348@utzoo.uucp> Reply-To: crowl@cs.rochester.edu (Lawrence Crowl) Organization: U of Rochester, CS Dept, Rochester, NY Lines: 19 The `volatile' type qualifier of ANSI C has recently been criticized as a frill. While this assertion is arguable for uniprocessors, it is not true for shared-memory multiprocessors. Processes on such machines communicate via updates to a shared variables. These updates may occur at arbitrary times relative to one of the observing processes. If there is no mechanism to indicate when a variable referenced by one process may be modified by another process, the compiler must assume that all variables may be modified at any time. In other words, the compiler must assume that all variables are `volatile'. This limits the optimizing effectiveness of compilers substantially. This limitation is severe because most variables are not shared. The compiler is forced to use sub-optimial code for 99% of its references in order to obtain correctness on the other 1%. Shared-memory multiprocessors need the `volatile' concept in order to use highly optimizing compilers. The `volatile' concept could be provided as a pragma, but the concept must exist. -- Lawrence Crowl 716-275-9499 University of Rochester crowl@cs.rochester.edu Computer Science Department ...!{allegra,decvax,rutgers}!rochester!crowl Rochester, New York, 14627