提交 977b07a9 创建 作者: Silas Boyd-Wickizer's avatar Silas Boyd-Wickizer

Build mapbench.

上级 7d2f082e
...@@ -19,5 +19,5 @@ mkfs ...@@ -19,5 +19,5 @@ mkfs
/mscan.out /mscan.out
/mscan.sorted /mscan.sorted
/mscan.syms /mscan.syms
/mscan.kernel /mscan.kern
config.mk config.mk
...@@ -64,6 +64,7 @@ UPROGS= \ ...@@ -64,6 +64,7 @@ UPROGS= \
_init \ _init \
_forktree \ _forktree \
_ls \ _ls \
_mapbench \
_maptest \ _maptest \
_sh \ _sh \
......
...@@ -118,6 +118,14 @@ void hlt(void) ...@@ -118,6 +118,14 @@ void hlt(void)
__asm volatile("hlt"); __asm volatile("hlt");
} }
static inline u64
rrsp(void)
{
u64 val;
__asm volatile("movq %%rsp,%0" : "=r" (val));
return val;
}
static inline void static inline void
lcr3(u64 val) lcr3(u64 val)
{ {
......
...@@ -6,22 +6,22 @@ ...@@ -6,22 +6,22 @@
#include "uspinlock.h" #include "uspinlock.h"
static struct uspinlock l; static struct uspinlock l;
static volatile uint tcount; static volatile int tcount;
enum { nthread = 4 }; enum { nthread = 4 };
enum { readaccess = 0 }; enum { readaccess = 0 };
void void
thr(uint tid) thr(int tid)
{ {
for (uint i = 0; i < 100; i++) { for (int i = 0; i < 100; i++) {
volatile char *p = (char*) (0x40000 + tid * 8 * 4096); volatile char *p = (char*) (0x40000UL + tid * 8 * 4096);
if (map((void *) p, 8 * 4096) < 0) { if (map((void *) p, 8 * 4096) < 0) {
printf(1, "%d: map failed\n", tid); printf(1, "%d: map failed\n", tid);
exit(); exit();
} }
if (readaccess) { if (readaccess) {
for (uint j = 0; j < 8 * 4096; j++) for (int j = 0; j < 8 * 4096; j++)
p[j] = '\0'; p[j] = '\0';
} }
...@@ -44,19 +44,17 @@ main(void) ...@@ -44,19 +44,17 @@ main(void)
mtrace_enable_set(1, "xv6-mapbench"); mtrace_enable_set(1, "xv6-mapbench");
acquire(&l); acquire(&l);
printf(1, "mapbench[%d]: start esp %x\n", getpid(), resp()); printf(1, "mapbench[%d]: start esp %x\n", getpid(), rrsp());
for(uint i = 0; i < nthread; i++) { for(int i = 0; i < nthread; i++) {
sbrk(4096); sbrk(4096);
uint *tstack = (uint*) sbrk(0); void *tstack = sbrk(0);
tstack[-1] = i; int tid = forkt(tstack, thr);
int tid = forkt(&tstack[-2], thr);
if (0) printf(1, "mapbench[%d]: child %d\n", getpid(), tid); if (0) printf(1, "mapbench[%d]: child %d\n", getpid(), tid);
} }
for(;;){ for(;;){
uint lastc = tcount; int lastc = tcount;
// printf(1, "mapbench[%d]: tcount=%d\n", getpid(), lastc); // printf(1, "mapbench[%d]: tcount=%d\n", getpid(), lastc);
release(&l); release(&l);
if(lastc==nthread) if(lastc==nthread)
...@@ -68,7 +66,7 @@ main(void) ...@@ -68,7 +66,7 @@ main(void)
release(&l); release(&l);
printf(1, "mapbench[%d]: done\n", getpid()); printf(1, "mapbench[%d]: done\n", getpid());
for(uint i = 0; i < nthread; i++) for(int i = 0; i < nthread; i++)
wait(); wait();
mtrace_enable_set(0, "xv6-mapbench"); mtrace_enable_set(0, "xv6-mapbench");
......
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论