Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
X
xv6-public
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
问题
0
问题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
银宸时代
OS Lab Group
奖励实验
xv6-public
提交
3e89a345
提交
3e89a345
11月 10, 2011
创建
作者:
Silas Boyd-Wickizer
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Some forkexec stuff.
上级
d9f0899f
隐藏空白字符变更
内嵌
并排
正在显示
3 个修改的文件
包含
47 行增加
和
8 行删除
+47
-8
Makefile
Makefile
+2
-0
forkexecbench.c
forkexecbench.c
+39
-0
forkexectree.c
forkexectree.c
+6
-8
没有找到文件。
Makefile
浏览文件 @
3e89a345
...
@@ -64,6 +64,8 @@ ULIB = ulib.o usys.o printf.o umalloc.o uthread.o
...
@@ -64,6 +64,8 @@ ULIB = ulib.o usys.o printf.o umalloc.o uthread.o
UPROGS
=
\
UPROGS
=
\
_cat
\
_cat
\
_init
\
_init
\
_forkexectree
\
_forkexecbench
\
_forktree
\
_forktree
\
_ls
\
_ls
\
_mapbench
\
_mapbench
\
...
...
forkexecbench.c
0 → 100644
浏览文件 @
3e89a345
#include "types.h"
#include "stat.h"
#include "user.h"
#include "mtrace.h"
#include "amd64.h"
#define NITERS 64
static
void
execbench
(
void
)
{
u64
s
=
rdtsc
();
for
(
int
i
=
0
;
i
<
NITERS
;
i
++
)
{
int
pid
=
fork
(
0
);
if
(
pid
<
0
)
{
printf
(
1
,
"fork error
\n
"
);
exit
();
}
if
(
pid
==
0
)
{
char
*
av
[]
=
{
"forkexecbench"
,
"x"
,
0
};
exec
(
"forkexecbench"
,
av
);
printf
(
1
,
"exec failed
\n
"
);
exit
();
}
else
{
wait
();
}
}
u64
e
=
rdtsc
();
printf
(
1
,
"%lu
\n
"
,
(
e
-
s
)
/
NITERS
);
}
int
main
(
int
ac
,
char
**
av
)
{
if
(
ac
==
2
)
exit
();
execbench
();
exit
();
}
forkexectree.c
浏览文件 @
3e89a345
...
@@ -7,17 +7,17 @@
...
@@ -7,17 +7,17 @@
#define NDEPTH 7
#define NDEPTH 7
void
void
forktree
(
u
int
depth
)
forktree
(
int
depth
)
{
{
if
(
depth
==
0
)
{
if
(
depth
==
0
)
{
printf
(
1
,
"%d: forkexectree
\n
"
,
getpid
());
printf
(
1
,
"%d: forkexectree
\n
"
,
getpid
());
mt
race_enable_set
(
1
,
"xv6-fork
tree"
);
mt
enable
(
"xv6-forkexec
tree"
);
}
}
if
(
depth
>=
NDEPTH
)
if
(
depth
>=
NDEPTH
)
exit
();
exit
();
for
(
u
int
i
=
0
;
i
<
NCHILD
;
i
++
)
{
for
(
int
i
=
0
;
i
<
NCHILD
;
i
++
)
{
int
pid
=
fork
(
0
);
int
pid
=
fork
(
0
);
if
(
pid
<
0
)
{
if
(
pid
<
0
)
{
printf
(
1
,
"fork error
\n
"
);
printf
(
1
,
"fork error
\n
"
);
...
@@ -33,7 +33,7 @@ forktree(uint depth)
...
@@ -33,7 +33,7 @@ forktree(uint depth)
}
}
}
}
for
(
u
int
i
=
0
;
i
<
NCHILD
;
i
++
)
{
for
(
int
i
=
0
;
i
<
NCHILD
;
i
++
)
{
if
(
wait
()
<
0
)
{
if
(
wait
()
<
0
)
{
printf
(
1
,
"wait stopped early
\n
"
);
printf
(
1
,
"wait stopped early
\n
"
);
exit
();
exit
();
...
@@ -48,10 +48,8 @@ forktree(uint depth)
...
@@ -48,10 +48,8 @@ forktree(uint depth)
if
(
depth
>
0
)
if
(
depth
>
0
)
exit
();
exit
();
struct
mtrace_appdata_entry
entry
;
mtops
(
0
);
entry
.
u64
=
0
;
mtdisable
(
"xv6-forkexectree"
);
mtrace_appdata_register
(
&
entry
);
mtrace_enable_set
(
0
,
"xv6-forktree"
);
printf
(
1
,
"%d: forkexectree OK
\n
"
,
getpid
());
printf
(
1
,
"%d: forkexectree OK
\n
"
,
getpid
());
halt
();
halt
();
...
...
编写
预览
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论