Subject: Re: For your edification...
To: Bill Studenmund <wrstuden@netbsd.org>
From: Monroe Williams <monroe@pobox.com>
List: port-macppc
Date: 02/13/2003 18:09:22
on 2/13/03 5:03 PM, Bill Studenmund at wrstuden@netbsd.org wrote:

> On Thu, 13 Feb 2003, Monroe Williams wrote:
> 
>> on 2/13/03 2:31 PM, Cliff Neighbors at cliff@allegronetworks.com wrote:
>> 
>>> this won't work unless all access to `ipending' also use lwarx/stwcx
>>> otherwise you will not detect and avoid the race.
>> 
>> That's what the code does.
> 
> I think Cliff's comment was different. I think he was saying make sure
> that all writes to this variable use this code. It does not good if one
> (or most) writer does this while others don't.
> 
> I think reads are fine, since I gather that ipending is an int, so it can
> be read atomicly.

Aha...

I see that I had misread the section on lwarx/stwcx.  I didn't realize that
normal stores to the reserved address didn't clear the reservation.  This
fact isn't clearly called out in section 4.2.6 of the PowerPC Enviromnents
book, although it can be inferred from a careful reading of the bulleted
list of things that may clear a reservation.

I was further confused by the fact that stores by any _other_ CPU or
mechanism in the system would clear the reservation.

Well, so much for that idea...

Thanks all,
-- monroe
------------------------------------------------------------------------
Monroe Williams                                         monroe@pobox.com