Date: Thu, 13 Jan 2000 08:07:12 -0500 From: "Mikhail Evstiounin" <evstiounin@adelphia.net> To: <freebsd-questions@FreeBSD.ORG> Subject: Re: Volatile variables Message-ID: <00f401bf5dc7$1bb3b360$fc353018@evstiouninadelphia.net.pit.adelphia.net>
next in thread | raw e-mail | index | archive | help
-----Original Message----- From: Oliver Fromme <olli@dorifer.heim3.tu-clausthal.de> To: freebsd-questions@FreeBSD.ORG <freebsd-questions@FreeBSD.ORG> Date: Thursday, January 13, 2000 12:07 AM Subject: Re: Volatile variables >Mikhail Evstiounin <evstiounin@adelphia.net> 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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?00f401bf5dc7$1bb3b360$fc353018>