atomic_inc
来源:互联网 发布:kali linux和ubuntu 编辑:程序博客网 时间:2024/05/17 02:37
atomic_inc(&v)对变量v用锁定总线的单指令进行不可分解的"原子"级增量操作,避免v的值由于中断或多处理器同时操作造成不确定状态。
X86 用LOCK 指令实现, 不懂
ARM代码如下, ldrex :
This performs a load, then sets a monitor to “watch” the address
• STREX {<cond>} <Rd>, <Rm>, [<Rn>]
This performs a store and returns “success” in Rd if no intervening access
detected by the monitor.
This performs a load, then sets a monitor to “watch” the address
• STREX {<cond>} <Rd>, <Rm>, [<Rn>]
This performs a store and returns “success” in Rd if no intervening access
detected by the monitor.
This performs a load, then sets a monitor to “watch” the address
• STREX {<cond>} <Rd>, <Rm>, [<Rn>]
This performs a store and returns “success” in Rd if no intervening access
detected by the monitor.
static inline int atomic_add_return(int i, atomic_t *v)
{
unsigned long tmp;
int result;
__asm__ __volatile__("@ atomic_add_return/n"
"1: ldrex %0, [%2]/n"
" add %0, %0, %3/n"
" strex %1, %0, [%2]/n"
" teq %1, #0/n"
" bne 1b"
: "=&r" (result), "=&r" (tmp)
: "r" (&v->counter), "Ir" (i)
: "cc");
- atomic_inc
- atomic_inc
- atomic_inc 原子操作
- atomic_inc 原子操作
- atomic_inc 原子操作
- atomic_inc 原子操作
- atomic_inc 原子操作
- SQL SERVER 2000 数据库备份与还原
- barrier(wmb,mb,rmb)和cache coherence
- volatile的作用
- 职场点评:CEO妙语批点大学生简历
- WinASM Studio v5.1.1.0
- atomic_inc
- Linux下的sniffer工具--Tcpdump的安装和使用
- ifconfig promisc
- asp.net中常用33种代码(转)
- 网络经典命令行
- 十八个超经典故事 启迪你一生
- acegi整合CAS [摘]
- 网络socket编程
- 我要成为吝啬专家