I'm aware of the use of volatile
in Java.
That is (based on the wikipedia article):
There is a global ordering on the reads and writes to a volatile variable. This implies that every thread accessing a volatile field will read its current value before continuing, instead of (potentially) using a cached value.
I also I'm aware that there exists the volatile
keyword in C but in a quite different context, mainly to be used in memory-mapped I/O.
So I was wondering, is there some construct like Java's volatile
in C? Which will prevent
reading cached values of a variable?
If it doesn't exist in C, is there perhaps a library with such a construct, like pthread
?