Re: volatile and caches

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

 



On Wed, Aug 28, 2002 at 08:34:25PM +0200, Bernd Petrovitsch wrote:
> >> So volatile by itself gives nothing. In kernel you have to use barrier()
> >Not True. volatille is very usefull. 'jiffies' are volatile, and many
> >status registers variables for devices are volatile. Volatile means 'don't
> >trust the cached value, reread it.' Any variable that changes very fast or
> >very often should be volatile. The barrier() functions are used for
> 
> 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
usualy tell comiler it must not assume anything about memory contents
before and after by some means (in gcc by specifying "memory" clobber to
(possibly empty) assembly block).

-------------------------------------------------------------------------------
						 Jan 'Bulb' Hudec <bulb@ucw.cz>
--
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