Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.2 9/18/84; site rtp47.UUCP Path: utzoo!linus!philabs!cmcl2!seismo!harvard!think!mit-eddie!genrad!decvax!mcnc!rti-sel!rtp47!gamma From: gamma@rtp47.UUCP (Michael Meissner) Newsgroups: net.lang.c Subject: Re: Volatile type in ANSI C Message-ID: <31@rtp47.UUCP> Date: Fri, 26-Apr-85 10:22:43 EDT Article-I.D.: rtp47.31 Posted: Fri Apr 26 10:22:43 1985 Date-Received: Mon, 29-Apr-85 07:08:50 EDT References: <543@lll-crg.ARPA> Reply-To: gamma@rtp47.UUCP (Michael Meissner) Distribution: net Organization: Data General, RTP, NC Lines: 18 Keywords: ANSI volatile Both flavors of volatile have their uses: 1) volatile int *p; /* p is a non-volatile ptr to volatile mem */ The compiler can optimize `p' into a register, or some such, but every access to the memory p points to cannot be optimized. 2) int * volatile q; /* q is a volatile ptr to non-volatile mem */ This is useful for things like multi-processor implementations, where q can be modified at any time (though obviously you might get strange results if q is not aligned correctly, and the other processor takes more than 1 memory cycle to update q). Because q is volitle, it means that anything it points cannot be optimized, and probably it should read: volatile int * volatile q; Michael Meissner Data General Corporation ...ihnp4!mcnc!rti-sel!rtp47