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

Alan Cox (alan@lxorguk.ukuu.org.uk)
Tue, 30 Nov 1999 16:08:29 +0000 (GMT)


> The following program shows that shared memory is not SMP safe.
> It is my understanding that, from the user's code point-of-view,
> the fact that a machine may have two (or more) processors should
> be invisible.

Not entirely.

> It appears as though, on a SMP machine, shared memory is not the same
> page shared amongst tasks. It appears (emphasis upon appears) as though
> shared-memory is a copy of something that does not get updated properly
> after a write (like it's in one CPU's cache, but not in another). I
> think one has to invalidate the cache after a write to shared memory??

Your code is broken.

> #define cli __asm__ __volatile__("cli\n")
> #define sti __asm__ __volatile__("sti\n")

These only affect the local CPU

> while((key = pars->key++) == 0)

This isnt SMP safe

> pars->spin += key;

This isnt SMP safe etc..

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