Fetch the repository succeeded.
count 自增
add $0x1,%edx
inc $edx
组成原理 / 体系结构
x86 汇编 CPU 执行流程分析
count = 4
t3: count=4 t4: count=5 CPU1 写入 t5: count=5 CPU2 写入 t6: count=5 …
t: 0 1 2 3 4 5 6 ----------------------------- CPU1: |F | | | | | | | | |D | | | | | | | | |M/4| | | | | | | | |E/5| | | | | | | | |W/5| | | | | | | | | | | ----------------------------- CPU2: | |F | | | | | | | | |D | | | | | | | | |M/4| | | | | | | | |E/5| | | | | | | | |W/5| | | | | | | | | | -----------------------------
lock addl $0x1,0x0(%eax)
lock
t: 0 1 2 3 4 5 6 ----------------------------- CPU1: |F | | | | | | | | |D | | | | | | | | |M/4| | | | | | | | |E/5| | | | | | | | |W/5| | | | | | | | | | | ----------------------------- CPU2: | | | | | |F | | | | | | | | | | | | |D | | | | | | | | | | | | |M/4| | | | | | | | | | | | |E/5| | | | | | | | | | | | |W/5| | | | | | | | | | | | | | -----------------------------
../../study/os/xv6-public/spinlock.h
// Mutual exclusion lock.
struct spinlock {
uint locked; // Is the lock held?
// For debugging:
char *name; // Name of lock.
struct cpu *cpu; // The cpu holding the lock.
uint pcs[10]; // The call stack (an array of program counters)
// that locked the lock.
};
rg -n initlock $PWD | sort
/data/gitana/study/os/xv6-public/bio.c:43: initlock(&bcache.lock, "bcache"); /data/gitana/study/os/xv6-public/console.c:289: initlock(&cons.lock, "console"); /data/gitana/study/os/xv6-public/defs.h:130:void initlock(struct spinlock*, char*); /data/gitana/study/os/xv6-public/file.c:22: initlock(&ftable.lock, "ftable"); /data/gitana/study/os/xv6-public/fs.c:176: initlock(&icache.lock, "icache"); /data/gitana/study/os/xv6-public/ide.c:55: initlock(&idelock, "ide"); /data/gitana/study/os/xv6-public/kalloc.c:34: initlock(&kmem.lock, "kmem"); /data/gitana/study/os/xv6-public/log.c:60: initlock(&log.lock, "log"); /data/gitana/study/os/xv6-public/pipe.c:37: initlock(&p->lock, "pipe"); /data/gitana/study/os/xv6-public/proc.c:26: initlock(&ptable.lock, "ptable"); /data/gitana/study/os/xv6-public/sleeplock.c:16: initlock(&lk->lk, "sleep lock"); /data/gitana/study/os/xv6-public/spinlock.c:13:initlock(struct spinlock *lk, char *name) /data/gitana/study/os/xv6-public/trap.c:26: initlock(&tickslock, "time");
lock; xchgl %0, %1
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。