Subject: lwarx/stwcx [Re: For your edification...]
To: Jason R Thorpe <thorpej@wasabisystems.com>
From: cliff neighbors <cliff@allegronetworks.com>
List: port-macppc
Date: 02/14/2003 19:14:00
Not so useless I think.  The reservation set/clear can be used to wrap arbitrary chunks of code
allowing much flexibility to implement atomic ops, as long as the code inside can manage a restart
when the reservation collision is detected.

The reason it shouldn't clear on access from local CPU is exactly becauase the local CPU gets the reservation.
To use reservation within a single CPU, just dump it on context switch or reentrance -- e.g. when switching processes
(switch_exited:\powerpc/locore.S).

One might use the reservation mechanism to implement shared memory lock primitives,
on single CPU systems (e.g. mem shared between processes) as well as SMP.

    -cliff-



Jason R Thorpe wrote:

> On Thu, Feb 13, 2003 at 02:31:19PM -0800, Cliff Neighbors wrote:
>
>  > this won't work unless all access to `ipending' also use lwarx/stwcx
>  > otherwise you will not detect and avoid the race.
>
> Uh, normal stores don't reset the "locked" memory location??  Wow, that
> seems ... useless!
>
> --
>         -- Jason R. Thorpe <thorpej@wasabisystems.com>