Re: volatile and caches

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Jan Hudec <bulb@cimice.maxinet.cz> wrote:
>On Wed, Aug 28, 2002 at 08:34:25PM +0200, Bernd Petrovitsch wrote:
[...] 
>> Any variable that may change it's value without code at that place 
>> should be volatile (i.e. hardware status registers and similar, 
>> variables changed by signal handlers, etc.).
>> Otherwise the C compiler is allowed to assume that the variable's 
>> contents works like RAM and use that wisdom.
>
>Well, every variable that may change without code being in place must in
>first place be locked or operated using atomic operations. And these

ACK, but this has nothing to do with "volatile" and it's definition in
(ANSI-)C which is required here.
IOW : doing 
----  snip  ----
int x = 0; /* no volatile here */

...
while (x == 0) {
     sleep(1);
}
....
----  snip  ----

and waiting for x to change through some other means (as said above 
e.g. signal handlers) may not work.
And it basically has nothing to do with barriers and the like on 
simple uniprocessor sytems.

	Bernd
-- 
Bernd Petrovitsch                              Email : bernd@gams.at
g.a.m.s gmbh                                  Fax : +43 1 205255-900
Prinz-Eugen-Straße 8                    A-1040 Vienna/Austria/Europe
                     LUGA : http://www.luga.at


--
Kernelnewbies: Help each other learn about the Linux kernel.
Archive:       http://mail.nl.linux.org/kernelnewbies/
FAQ:           http://kernelnewbies.org/faq/


[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux