Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
X
xv6-public
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
问题
0
问题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
银宸时代
OS Lab Group
奖励实验
xv6-public
提交
d3c7235d
提交
d3c7235d
10月 29, 2011
创建
作者:
Silas Boyd-Wickizer
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
maptest and thrtest.c
上级
0c7ee376
隐藏空白字符变更
内嵌
并排
正在显示
4 个修改的文件
包含
17 行增加
和
16 行删除
+17
-16
Makefile
Makefile
+1
-0
mapbench.c
mapbench.c
+6
-4
maptest.c
maptest.c
+1
-1
thrtest.c
thrtest.c
+9
-11
没有找到文件。
Makefile
浏览文件 @
d3c7235d
...
...
@@ -67,6 +67,7 @@ UPROGS= \
_mapbench
\
_maptest
\
_sh
\
_thrtest
\
%.o
:
%.c
@
echo
" CC
$@
"
...
...
mapbench.c
浏览文件 @
d3c7235d
...
...
@@ -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
);
}
...
...
maptest.c
浏览文件 @
d3c7235d
...
...
@@ -55,7 +55,7 @@ main(void)
}
sbrk
(
4096
);
forkt
(
sbrk
(
0
),
thr
);
forkt
(
sbrk
(
0
),
thr
,
0
);
acquire
(
&
l
);
state
=
1
;
...
...
thrtest.c
浏览文件 @
d3c7235d
...
...
@@ -6,14 +6,14 @@
#include "uspinlock.h"
static
struct
uspinlock
l
;
static
volatile
u
int
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
,
re
sp
());
printf
(
1
,
"thrtest[%d]: arg 0x%
lx rsp %lx
\n
"
,
getpid
(),
arg
,
rr
sp
());
tcount
++
;
release
(
&
l
);
exit
();
...
...
@@ -23,19 +23,17 @@ int
main
(
void
)
{
acquire
(
&
l
);
printf
(
1
,
"thrtest[%d]: start esp %x
\n
"
,
getpid
(),
r
e
sp
());
printf
(
1
,
"thrtest[%d]: start esp %x
\n
"
,
getpid
(),
r
r
sp
());
for
(
u
int
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
(;;){
u
int
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
(
u
int
i
=
0
;
i
<
nthread
;
i
++
)
for
(
int
i
=
0
;
i
<
nthread
;
i
++
)
wait
();
exit
();
}
编写
预览
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论