提交 9e2a60cb 创建 作者: Nickolai Zeldovich's avatar Nickolai Zeldovich

fix dirbench build

上级 f844189d
......@@ -90,6 +90,7 @@ UPROGS= \
_halt \
_time \
_sleep \
_dirbench \
_usertests
UPROGS := $(addprefix $(O)/, $(UPROGS))
......
......@@ -12,12 +12,12 @@ enum { nlookup = 100 };
char dirs[nthread][MAXNAME];
void
bench(uint tid)
bench(u32 tid)
{
char pn[MAXNAME];
for (uint x = 0; x < nloop; x++) {
for (uint i = 0; i < nfile; i++) {
for (u32 x = 0; x < nloop; x++) {
for (u32 i = 0; i < nfile; i++) {
snprintf(pn, sizeof(pn), "%s/f:%d:%d", dirs[tid], tid, i);
int fd = open(pn, O_CREATE | O_RDWR);
......@@ -27,7 +27,7 @@ bench(uint tid)
close(fd);
}
for (uint i = 0; i < nlookup; i++) {
for (u32 i = 0; i < nlookup; i++) {
snprintf(pn, sizeof(pn), "%s/f:%d:%d", dirs[tid], tid, (i % nfile));
int fd = open(pn, O_RDWR);
if (fd < 0)
......@@ -36,7 +36,7 @@ bench(uint tid)
close(fd);
}
for (uint i = 0; i < nfile; i++) {
for (u32 i = 0; i < nfile; i++) {
snprintf(pn, sizeof(pn), "%s/f:%d:%d", dirs[tid], tid, i);
if (unlink(pn) < 0)
printf(1, "unlink failed\n");
......@@ -49,27 +49,27 @@ bench(uint tid)
int
main(void)
{
for (uint i = 0; i < nthread; i++) {
for (u32 i = 0; i < nthread; i++) {
//snprintf(dirs[i], sizeof(dirs[i]), "/db%d", i);
snprintf(dirs[i], sizeof(dirs[i]), "/dbx");
if (mkdir(dirs[i]) < 0)
printf(1, "mkdir failed\n");
}
mtrace_enable_set(1, "xv6-dirbench");
// mtrace_enable_set(1, "xv6-dirbench");
printf(1, "dirbench[%d]: start\n", getpid());
for(uint i = 0; i < nthread; i++) {
for(u32 i = 0; i < nthread; i++) {
int pid = fork(0);
if (pid == 0)
bench(i);
}
for (uint i = 0; i < nthread; i++)
for (u32 i = 0; i < nthread; i++)
wait();
mtrace_enable_set(0, "xv6-dirbench");
// mtrace_enable_set(0, "xv6-dirbench");
printf(1, "dirbench[%d]: done\n", getpid());
halt();
// halt();
exit();
}
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论