Need help with communication between multiple threads
gamerChad at _spamIsBad_gmail.com
Tue Feb 20 08:53:15 PST 2007
I'm a bit of a newbie to this whole multithreading thing, so I'm hoping
someone can help me with this.
First, what I know (or what I think I know): So I've been reading about
this, and apparently there's this problem where two threads that are
reading a value from the same address in memory at the same time may end
up with two completely different values. Apparently this is because
when you write something, it may just end up in the cache and not be
updated in global memory. Also, when reading, you may end up with
something that is just an outdated copy in the cache, and not the actual
thing from global memory. But it doesn't stop there, apparently x86
computers are very forgiving on this stuff so if you make a mistake you
won't know it until your program is run on some more obscure hardware.
Now then, my question: In D, how do I ensure that when I write
something, the write is to global memory, and when I read something, the
read is from global memory?
Some more info: This comes up because I am trying to write a Timer
class for Tango, and it will include timers that trigger events at a
later date, which requires multithreading. So it'd be most helpful if I
could accomplish this using only D features and/or Tango.
More information about the Digitalmars-d-learn