Re: volatile and caches

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

 



On Tue, Aug 27, 2002 at 01:52:13PM -0400, anton wilson wrote:
> Does a volatile variable never reside in cache?

It is my understanding of volatile that it will force the compiler to
never rely on a register for the value -- it must always fetch from
memory. The memory fetches will still go through cache. I think it is up
to the hardware to ensure that cache is coherent across all CPUs.

> struct _test{
>    volatile x;
>    char arr[1024];
> }test;
> 
> if I use x, will the first part
> of the arr string get read into cache or not?

I'd expect this to be highly dependant upon where the struct is located
in memory; there are probably places in memory where the first 28 bytes
f the array would be cached, and other places in memory where none of
the array would be cached. And, as always, this is highly platform
dependant. :)

-- 
It seems the power has been robbed from the founding fathers and is now
firmly in the hand of the funding fathers -- Rik van Riel

Attachment: pgp00154.pgp
Description: PGP signature


[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