Subject: Re: Fwd: Located problem in pcn driver...
To: None <email@example.com>
From: der Mouse <mouse@Rodents.Montreal.QC.CA>
Date: 04/21/2003 01:07:11
> [...] logic [...] to decide if it(load/store) is meant for I/O device
> or memory and probably bypasses cache as a result for I/O operations
> without the volatile keyword being used.
The volatile keyword has nothing to do with bypassing cache in the
memory-subsystem sense; it exists to prevent the compiler from cacheing
"stored" values, optimizing it away, rearranging it with respect to
other volatile-marked stores, or suchlike.
For example, if I wrote
...compute something in i and j, don't modify vp...
*vp = i;
*vp = j;
the compiler would be justified in optimizing the first store out of
existence (since vp cannot point to either i or j, because it had its
value before i and j existed, the first line cannot change j and thus
cannot change the value left in *vp). But "volatile int *vp" would
prevent this. This, of course, is completely orthogonal to bypassing
memory-subsystem cache (which is important in some but not all of the
cases in which volatile is necessary).
/~\ The ASCII der Mouse
\ / Ribbon Campaign
X Against HTML firstname.lastname@example.org
/ \ Email! 7D C8 61 52 5D E7 2D 39 4E F1 31 3E E8 B3 27 4B