Re: Shared memory not SMP safe to user-mode code.

Rogier Wolff (R.E.Wolff@BitWizard.nl)
Wed, 1 Dec 1999 09:51:42 +0100 (MET)


Alan Cox wrote:
> > Currently, if you were to do the trivial:
> >
> > *ptr = shared_memory;
> >
> > while (!*ptr)
> > ;
> >
> > This will loop forever, even when hardware writes non-zero to shared
> > memory. This is because the CPU "knows" that it didn't write something
>
> If *ptr is in PCI space it will be uncached, if it is in main memory it will
> cause a cache line invalidation on the CPUs holding the line.

Right, but you do have to declare *ptr to be volatile, otherwise the
compiler won't (*) generate a reload of the memory location.

Roger.

(*) or "is allowed not to": You'll see it working when compiled without -O.

-- 
** R.E.Wolff@BitWizard.nl ** http://www.BitWizard.nl/ ** +31-15-2137555 **
*-- BitWizard writes Linux device drivers for any device you may have! --*
 "I didn't say it was your fault. I said I was going to blame it on you."

- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.rutgers.edu Please read the FAQ at http://www.tux.org/lkml/