From owner-freebsd-questions Wed Jan 12 19:36: 5 2000 Delivered-To: freebsd-questions@freebsd.org Received: from alpha.pit.adelphia.net (alpha.pit.adelphia.net [24.48.44.2]) by hub.freebsd.org (Postfix) with ESMTP id C747414CD0 for ; Wed, 12 Jan 2000 19:36:00 -0800 (PST) (envelope-from evstiounin@adelphia.net) Received: from evstiouninadelphia (surf15-222.pit.adelphia.net [24.48.53.222]) by alpha.pit.adelphia.net (8.9.2/8.9.2) with SMTP id WAA20196; Wed, 12 Jan 2000 22:30:23 -0500 (EST) Message-ID: <00c801bf5d76$dcae5580$fc353018@evstiouninadelphia.net.pit.adelphia.net> From: "Mikhail Evstiounin" To: "Mikhail Evstiounin" , Subject: Re: Volatile variables Date: Wed, 12 Jan 2000 22:32:47 -0500 MIME-Version: 1.0 Content-Type: text/plain; charset="koi8-r" Content-Transfer-Encoding: 8bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 4.72.3110.1 X-MimeOLE: Produced By Microsoft MimeOLE V4.72.3110.3 Sender: owner-freebsd-questions@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG -----Original Message----- From: Mikhail Evstiounin To: freebsd-questions@FreeBSD.ORG Date: Wednesday, January 12, 2000 10:02 PM Subject: Re: Volatile variables > >-----Original Message----- >From: Oliver Fromme >To: freebsd-questions@FreeBSD.ORG >Date: Wednesday, January 12, 2000 9:47 PM >Subject: Re: Volatile variables > > >>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 > > >agreed, I wasn't clear, but again - back to standard - >"so that aggresive optimization must be avoided". > >>written asynchronously, i.e. its value might not be consistent > > >should add - in ways not specified by the language. You can chage a >global variable in different threads - asynchroniosly, you should >synchromize >access - you don't need vilotile here. > >>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. My error again - ignore is bad word, - can I say - use in a different way? >> >>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. > > >I was not talking aboutt "ignore", I was talking about "hint", ehich >in my mind means - if you can provide protection, you can use >aggresive optimization. Your example still leaves variable >in a "stale" mode. And yes, it's a compiler to make sure that the >program works, but there are different ways. In my mind, it's pretty close >to register specifier - compiler will try to allocate variablue in a >registere, >but if there is not enough registers then compiler will allocate variable >in memory. It's still works, but not as fast as author wanted. The same is >with vilotile - if there is a way to provide an "atomic" way for some part >of code then compiler can use some pretty aggresive optimizations. > >> >> > 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. :) >> > >It doesn't matter, it was just an example, and BTW, you can configure >segments in a way when it would be true. And even in Unix world you can >use sigmask. > >>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 > > > >To Unsubscribe: send mail to majordomo@FreeBSD.org >with "unsubscribe freebsd-questions" in the body of the message To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-questions" in the body of the message