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

maptest and thrtest.c

上级 0c7ee376
......@@ -67,6 +67,7 @@ UPROGS= \
_mapbench \
_maptest \
_sh \
_thrtest \
%.o: %.c
@echo " CC $@"
......
......@@ -11,8 +11,10 @@ enum { nthread = 4 };
enum { readaccess = 0 };
void
thr(int tid)
thr(void *arg)
{
u64 tid = (u64)arg;
for (int i = 0; i < 100; i++) {
volatile char *p = (char*) (0x40000UL + tid * 8 * 4096);
if (map((void *) p, 8 * 4096) < 0) {
......@@ -35,7 +37,6 @@ thr(int tid)
// printf(1, "mapbench[%d]: done\n", getpid());
tcount++;
release(&l);
exit();
}
int
......@@ -47,9 +48,10 @@ main(void)
printf(1, "mapbench[%d]: start esp %x\n", getpid(), rrsp());
for(int i = 0; i < nthread; i++) {
sbrk(4096);
sbrk(8192);
void *tstack = sbrk(0);
int tid = forkt(tstack, thr);
printf(1, "tstack %lx\n", tstack);
int tid = forkt(tstack, thr, (void *)(u64)i);
if (0) printf(1, "mapbench[%d]: child %d\n", getpid(), tid);
}
......
......@@ -55,7 +55,7 @@ main(void)
}
sbrk(4096);
forkt(sbrk(0), thr);
forkt(sbrk(0), thr, 0);
acquire(&l);
state = 1;
......
......@@ -6,14 +6,14 @@
#include "uspinlock.h"
static struct uspinlock l;
static volatile uint tcount;
static volatile int tcount;
enum { nthread = 4 };
void
thr(uint arg)
thr(void *arg)
{
acquire(&l);
printf(1, "thrtest[%d]: arg 0x%x esp %x\n", getpid(), arg, resp());
printf(1, "thrtest[%d]: arg 0x%lx rsp %lx\n", getpid(), arg, rrsp());
tcount++;
release(&l);
exit();
......@@ -23,19 +23,17 @@ int
main(void)
{
acquire(&l);
printf(1, "thrtest[%d]: start esp %x\n", getpid(), resp());
printf(1, "thrtest[%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] = 0xc0ffee00 | i;
int tid = forkt(&tstack[-2], thr);
void *tstack = sbrk(0);
int tid = forkt(tstack, thr, (void*)(u64)(0xc0ffee00|i));
printf(1, "thrtest[%d]: child %d\n", getpid(), tid);
}
for(;;){
uint lastc = tcount;
int lastc = tcount;
printf(1, "thrtest[%d]: tcount=%d\n", getpid(), lastc);
release(&l);
if(lastc==nthread)
......@@ -47,7 +45,7 @@ main(void)
release(&l);
printf(1, "thrtest[%d]: done\n", getpid());
for(uint i = 0; i < nthread; i++)
for(int i = 0; i < nthread; i++)
wait();
exit();
}
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论