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

Build mapbench.

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