Re: [PATCH] include/asm-i386/semaphore.h speedup

Richard B. Johnson (root@chaos.analogic.com)
Thu, 14 Jan 1999 08:35:18 -0500 (EST)


On Wed, 13 Jan 1999, Colin Plumb wrote:

> I was looking at this code and noticed the comment lamenting the inefficiency
> is not necessary on a 486 and up.
>
> Could someone please check out the following. In particular, is the
> lock prefix required for cmpxchg, or is it already implicit?
> --
> -Colin

It is not implicit. "This instruction can be used with the lock prefix";
"In order to simplify interface to the processor's bus, the destination
operand receives a write cycle without regard to the result of the
comparison. DEST is writtem back back if the comparison fails, and SRC
is written into the destination otherwise. (The processor never produces
a locked read without also producing a locked write)". pp 26-63 Intel's
'486 rag.

Note that, without locking, the destination receiving the first write-
cycle, i.e., a copy of the source, may receive the wrong value if
either source or destination changes. Therefore you need the lock
prefix for atomic operations.

Cheers,
Dick Johnson
***** FILE SYSTEM WAS MODIFIED *****
Penguin : Linux version 2.1.131 on an i686 machine (400.59 BogoMips).
Warning : It's hard to remain at the trailing edge of technology.
Wisdom : It's not a Y2K problem. It's a Y2Day problem.

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