- 论坛徽章:
- 0
|
- linux-2.6.31/arch/arm/include/asm/bitops.h
- static inline int
- ____atomic_test_and_set_bit(unsigned int bit, volatile unsigned long *p)
- {
- unsigned long flags;
- unsigned int res;
- unsigned long mask = 1UL << (bit & 31);
- p += bit >> 5;
- raw_local_irq_save(flags);
- res = *p;
- *p = res | mask;
- raw_local_irq_restore(flags);
- return res & mask;
- }
复制代码 如上所示,设置*p的第bit位,并返回原值。在操作中首先禁中断,防止中断打断原子操作,
但是这里并没有使用ARMv6开始提供的锁总线指令ldrex和strex,那么是如何保证原子操作的呢?
而且从CONFIG_SMP宏的配置来看,该版本的内核是明确支持ARM SMP系统的,如果不能保证位
的原子操作,又何谈SMP的支持呢? |
|