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

yodaiken@chelm.cs.nmt.edu
Tue, 14 Dec 1999 07:38:51 -0700


On Tue, Nov 30, 1999 at 03:29:13PM -0500, Richard B. Johnson 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

More likely the compiler knows something that is false. Have you
used a __volatile ?

> there since the last time it read, so the data from the last read remains
> in its cache, never updated. Once a task-switch occurs, the loop
> will be broken. However, this limits the maximum data-change-rate
> to 100 Hz (the task-switch time).

On SMP Intels the cache will be updated correctly even if a remote
processor writes.

-
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/