[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: spin lock struct and locking (2.6.9)



On Thu, Mar 03, 2005 at 04:29:03PM -0800, Om wrote:
> In an smp environment, what prevents 2 different cpu's from aquiring
> same spin lock at exactly the same time? I was expecting `lock` to be
> atomic, and the inc and dec operations were also atomic operations.

You're looking at the wrong definition of _raw_spin_lock(). For x86,
look at include/asm-i386/spinlock.h, where you can find it uses
spin_lock_string, which uses a "lock" prefix to atomically increment or
decrement the lock.


Erik

-- 
Erik Mouw
J.A.K.Mouw@xxxxxxxxxxxxxx  mouw@xxxxxxxxxxxx

Attachment: signature.asc
Description: Digital signature