Tristan \(do not reply by email\)
7/24/2004 3:47:00 AM
"Joe Seigh" <jseigh_01@xemaps.com> wrote in message
news:4101C5AB.F31259A@xemaps.com...
>
>
> "Tristan (do not reply by email)" wrote:
> >
> > so are you saying that a thread reading an unprotected variable while
> > another thread could possibly write the same variable is always safe ?
> >
> > i was under the impression that when two threads can possibly access
> > simultanously the same memory address (e.g. one reading and the other
> > writing), then on some multiprocessor architectures, this could produce
a
> > fault.
> >
> > you seem to be all very convinved that it cannot (ever) be a probem.
> >
> > can you point me to a definitive document that explains why this is in
fact
> > never a problem, and that it is absolutely 100% definitively garanteed
that
> > this will work fine on all multiprocessor architectures ?
>
> It's not a problem since the only way you can see a non zero value is if
> somebody set it.
i was not refering to that.
i was refering to the fact that you can get a memory exception when
accessing a memory address while another thread (running on another
processor, in a multiprocessor architecture) accesses it.
i clearly remember seeing memory fault happen in this case, but that was not
under the windows operating system.
so i know that the case is possible, and that happens.
are you saying that it is garanteed somewhere (where is that written ?) that
under any flavor of the windows OS that uses multople processors, this
cannot happen ?
> If the accessing the variable is atomic
accessing a variable is not garanteed to be an atomic operation, is it ? it
certainely depends on the size of the variable, the instructions that the
compiler will use to access the variable (i.e. nothing guarantees that the
compiler will not access the two 16-bit words when you read a 32-0bit
variable) and the way the memory is accessed. accessing a double is likely
to not be an atomic operation.
so your statement "accessing the variable is atomic" is incorrect, as a
general statement.