On P2, P3 and P4, the MESI protocol should take care of the cache protocol
issue. Take a look at Mindshare’s books.
Alberto.
-----Original Message-----
From: Ntdev Reader [mailto:xxxxx@yahoo.com]
Sent: Tuesday, January 28, 2003 12:57 PM
To: NT Developers Interest List
Subject: [ntdev] Re: CPU cache, memory and multiple CPUs
Since some questions have arised, let me add more details and make the code
more sensible. Surely, this code is not from a real driver, it is merely
used
to illustrate my question.
Suppose I have the following code:
KeAcquireSpinlock( &DevExt->mylock, &oldirql);
if( DevExt->bDoStuff == 1)
{
DoStuff();
DevExt->bDoStuff = 0;
}
KeReleaseSpinlock( &DevExt->mylock, oldirql);
It can be executed by multiple CPU’s. Is this guaranteed (and, most
important,
by whom) that the next CPU to enter the protected section of code will see 0
and not the old value in bDoStuff? My concern is whether it can happen that
when the first CPU modifies bDoStuff it does that in its cache and has not
written it to the main memory yet at the time the spinlock is released.
More specifically, must I use one of “Interlocked” functions to assign 0 to
bDoStuff in this case? Or does KeReleaseSpinlock do a cache flush?
An answer such as “x86, as of today, automatically maintains cache coherency
between CPUs and so you don’t need “Interlocked” on x86”, or similar answers
in context of particular CPU implementation details do not answer this
question, for I’m looking for a right, Microsoft guaranteed, way to do this,
very basic, thing.
Do you Yahoo!?
Yahoo! Mail Plus - Powerful. Affordable. Sign up now.
http://mailplus.yahoo.com
You are currently subscribed to ntdev as: xxxxx@compuware.com
To unsubscribe send a blank email to xxxxx@lists.osr.com
The contents of this e-mail are intended for the named addressee only. It
contains information that may be confidential. Unless you are the named
addressee or an authorized designee, you may not copy or use it, or disclose
it to anyone else. If you received it in error please notify us immediately
and then destroy it.