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

fix dirbench build

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