atomic.h vs spinlock.h
Hi -
2 questions actually:
1) what is the difference between the macros defined in asm/atomic.h and asm/spinlock.h. (usage and purpose wise)?
2) If I need to use asm/atomic.h, which macro can I use to test-and-set?
thanks,
Umut
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line · Umut Aymakoglu
Umut> 1) what is the difference between the macros defined in Umut> asm/atomic.h and asm/spinlock.h. (usage and purpose wise)?
The first provides atomic operations, such as increment and decrement; the second provides spinlocks. I'm afraid I'm just stating the obvious here.
In case you have a copy of my book (ia64 linux kernel), atomic ops and spinlocks are described in sections 3.3.2 and 3.3.5, respectively. (Of course, I wouldn't recommend to get the book _just_ because of this.)
Umut> 2) If I need to use asm/atomic.h, which macro can I use to Umut> test-and-set?
cmpxchg() is the closest thing to test-and-set. Not all platforms support it. Platforms that do support it (such as ia64), define macro __HAVE_ARCH_CMPXCHG.
--david