[concurrency-interest] a question regarding volatile & cache flushing/invalidating

Yechiel Feffer yechielf at gigaspaces.com
Thu May 14 07:16:16 EDT 2009

When a thread writes (assigns)  values to some non-volatile variables
and then to a volatile variable, in order to make the non-volatile
values visible to any other thread which reads the volatile variable,
the writing thread has to flush all its dirty cache to main memory.

Is it a  correct assumption? 

For the reading thread, when reading from the volatile variable it has
to invalidate its (non-dirty) cache in order to retrieve the values of
the non-volatile vars from main memory- in order to get the correct
values of the non-volatiles when accessed after reading the volatile

Is it a correct assumption?


If so- doesn't it mean that

1.	touching (writing to or reading from) volatile must be heavier
when large caches are used or caches are fuller?
2.	most multi threading programs are using ,explicitly or
implicitly (via concurrent data structures) volatiles or locks. Does it
mean that caches are becoming quite useless or even a burden in such



Yechiel Fefer




-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://cs.oswego.edu/pipermail/concurrency-interest/attachments/20090514/58805c4d/attachment-0001.html>

More information about the Concurrency-interest mailing list