提交 87304b5d 创建 作者: Austin Clements's avatar Austin Clements 提交者: Silas Boyd-Wickizer

Add PAUSE to acquire and idleloop

With the mtrace QEMU, which now switches VCPUs when there's a PAUSE, this speeds up my lame test (usertests vmoverlap) by a factor of 7 and certainly makes xv6 feel much faster.
上级 6a371af4
...@@ -127,6 +127,7 @@ idleloop(void) ...@@ -127,6 +127,7 @@ idleloop(void)
exit(); exit();
} while(worked); } while(worked);
sti(); sti();
nop_pause();
} }
} }
} }
......
...@@ -301,8 +301,10 @@ acquire(struct spinlock *lk) ...@@ -301,8 +301,10 @@ acquire(struct spinlock *lk)
locking(lk); locking(lk);
retries = 0; retries = 0;
while(xchg32(&lk->locked, 1) != 0) while(xchg32(&lk->locked, 1) != 0) {
retries++; retries++;
nop_pause();
}
locked(lk, retries); locked(lk, retries);
} }
......
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论