From owner-freebsd-questions Thu Jan 13 5: 7:12 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 91472154E2 for ; Thu, 13 Jan 2000 05:07:09 -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 IAA06766 for ; Thu, 13 Jan 2000 08:07:01 -0500 (EST) Message-ID: <00f401bf5dc7$1bb3b360$fc353018@evstiouninadelphia.net.pit.adelphia.net> From: "Mikhail Evstiounin" To: Subject: Re: Volatile variables Date: Thu, 13 Jan 2000 08:07:12 -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: Oliver Fromme To: freebsd-questions@FreeBSD.ORG Date: Thursday, January 13, 2000 12:07 AM Subject: Re: Volatile variables >Mikhail Evstiounin wrote in list.freebsd-questions: > > 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. > >You _do_ need "volatile" in that case. It is necessary for >all variables whose contents can change asynchronously, i.e. >outside of the normal program flow. For example, this is true >for variables which are mapped to hardware registers, and for >variables which are located in a shared memory reagion (which >is shared with other processes), and for variables which are that is - in ways not specified by the language. >accessed from within signal handlers. This is, in my mind, slightly different. Could you explain me how it helps in your example? I pointed, that you can get signal between two assembler commands and it does destroys all your assumptions. > > > 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. > >No, those are different things. The "register" qualifier is, >indeed, just a hint for the compiler that it might be worth to >hold this variable in a register if possible. The compiler is >allowed to completely ignore it. A compiler that doesn't even >implement that register optimization at all would still be >perfectly ANSI-compliant. > >But, the "volatile" qualifier must _never_ be ignored. It is >not just a hint. > > > 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. > >But you cannot switch off multitasking. ??? relationship to volatile ??? > >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