From owner-freebsd-questions Wed Jan 12 18:45:51 2000 Delivered-To: freebsd-questions@freebsd.org Received: from dorifer.heim3.tu-clausthal.de (dorifer.heim3.tu-clausthal.de [139.174.243.252]) by hub.freebsd.org (Postfix) with ESMTP id 3C7AB14D8C for ; Wed, 12 Jan 2000 18:45:48 -0800 (PST) (envelope-from olli@dorifer.heim3.tu-clausthal.de) Received: (from olli@localhost) by dorifer.heim3.tu-clausthal.de (8.9.3/8.9.3) id DAA65229; Thu, 13 Jan 2000 03:45:47 +0100 (CET) (envelope-from olli) Date: Thu, 13 Jan 2000 03:45:47 +0100 (CET) Message-Id: <200001130245.DAA65229@dorifer.heim3.tu-clausthal.de> From: Oliver Fromme To: freebsd-questions@FreeBSD.ORG Reply-To: freebsd-questions@FreeBSD.ORG Subject: Re: Volatile variables X-Newsgroups: list.freebsd-questions In-Reply-To: <85jdi6$1paq$1@atlantis.rz.tu-clausthal.de> User-Agent: tin/1.4.1-19991201 ("Polish") (UNIX) (FreeBSD/3.4-19991219-STABLE (i386)) MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit Sender: owner-freebsd-questions@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG Mikhail Evstiounin wrote in list.freebsd-questions: > [...] > Like I told above it should be done in atomic way, but vilotale means - > avoid > optimiozations. "volatile" does not mean that the compiler should not optimize. It only means that the compiler must not make certain assumptions about a variable, and that its value may be read or written asynchronously, i.e. its value might not be consistent between statements. No more, no less. Of course, this inhibits certain types of optimizations, naturally. > And again it's a hint - just a hint. Some aggresive > optimizers > could ignore it. No! A C compiler must not ignore the "volatile" qualifier. It's the compiler's job to make sure that the program is not working with a "stale" variable value. > For example, if commands cli/sti could be used by compiler > and works like it work in 8086, optimizer could do the following: Yeah, it could, but this is UNIX, not DOS. :) Regards Oliver -- Oliver Fromme, Leibnizstr. 18/61, 38678 Clausthal, Germany (Info: finger userinfo:olli@dorifer.heim3.tu-clausthal.de) "In jedem Stück Kohle wartet ein Diamant auf seine Geburt" (Terry Pratchett) To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-questions" in the body of the message