atomic operations in user space

Liu Dave-r63238 DaveLiu at
Wed Aug 30 12:17:05 EST 2006

> I surely know all the theories you mentioned clearly.  But 
> please do look at the case I gave.  Correct me if I missed 
> anything.  Thanks
> All the lwarx and stwcx operate on the same address.
> > Task A		Task B
> > lwarx				
> > 			......
> > 			lwarx
> > 			stwcx
> // RESERVATION cleared
> >
> > 			.....
> > 			.....
> > 			lwarx
> // Get RESERVATION again
> > stwcx				
> //Note here: RESERVATION is valid, address is the same.
> So the result is commited, no retry for task A
> > .....
> > 			stwcx
> //RESERVATION is cleared, retry atomic op for task B
> Please be noted that reservation is only identified by 
> reservation bit and address operated on.  So different 
> lwarx's on the same address, may be considered as the same 
> reservation.

Is this your reason we cannot do atomic operation in user space?

How about the kernel space? You can image it.
The context switching as above also happen in kernel space,
Why we can do atomic operation in kernel space, not do in user space?

You are assuming the context switching cause the reservation broken.
but we can do atomic operation in kernel space.  The context switching
really is the execption of processor, If we can clear the wrong
before exception return, I think we can solve this problem. We can dummy
stwcx. before exception return or the processor automaticly clear the
reservation in exception. 

Are you missing these important things?


More information about the Linuxppc-dev mailing list