Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
X
xv6-public
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
问题
0
问题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
银宸时代
OS Lab Group
奖励实验
xv6-public
提交
c4cda662
提交
c4cda662
5月 10, 2011
创建
作者:
Nickolai Zeldovich
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
threads work (or at least thrtest)
上级
71f48f08
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
18 行增加
和
11 行删除
+18
-11
thrtest.c
thrtest.c
+17
-10
uspinlock.h
uspinlock.h
+1
-1
没有找到文件。
thrtest.c
浏览文件 @
c4cda662
...
@@ -7,7 +7,7 @@
...
@@ -7,7 +7,7 @@
static
struct
uspinlock
l
;
static
struct
uspinlock
l
;
static
volatile
uint
tcount
;
static
volatile
uint
tcount
;
enum
{
nthread
=
1
};
enum
{
nthread
=
4
};
void
void
thr
(
uint
arg
)
thr
(
uint
arg
)
...
@@ -23,7 +23,7 @@ int
...
@@ -23,7 +23,7 @@ int
main
(
void
)
main
(
void
)
{
{
acquire
(
&
l
);
acquire
(
&
l
);
printf
(
1
,
"thrtest[%d]: start
\n
"
,
getpid
());
printf
(
1
,
"thrtest[%d]: start
esp %x
\n
"
,
getpid
(),
resp
());
for
(
uint
i
=
0
;
i
<
nthread
;
i
++
)
{
for
(
uint
i
=
0
;
i
<
nthread
;
i
++
)
{
sbrk
(
4096
);
sbrk
(
4096
);
...
@@ -31,16 +31,23 @@ main(void)
...
@@ -31,16 +31,23 @@ main(void)
tstack
[
-
1
]
=
0xc0ffee00
|
i
;
tstack
[
-
1
]
=
0xc0ffee00
|
i
;
int
tid
=
forkt
(
&
tstack
[
-
2
],
thr
);
int
tid
=
forkt
(
&
tstack
[
-
2
],
thr
);
printf
(
1
,
"thrtest[%d]: child %d
esp %x
\n
"
,
getpid
(),
tid
,
resp
()
);
printf
(
1
,
"thrtest[%d]: child %d
\n
"
,
getpid
(),
tid
);
}
}
for
(;;){
uint
lastc
=
tcount
;
printf
(
1
,
"thrtest[%d]: tcount=%d
\n
"
,
getpid
(),
lastc
);
release
(
&
l
);
if
(
lastc
==
nthread
)
break
;
while
(
tcount
==
lastc
)
__asm
__volatile
(
""
);
acquire
(
&
l
);
}
release
(
&
l
);
release
(
&
l
);
exit
(
);
printf
(
1
,
"thrtest[%d]: done
\n
"
,
getpid
()
);
do
{
for
(
uint
i
=
0
;
i
<
nthread
;
i
++
)
printf
(
1
,
"thrtest[%d]: %d
\n
"
,
getpid
(),
tcount
);
wait
();
for
(
uint
i
=
0
;
i
<
100000
;
i
++
)
exit
();
;
//sleep(1);
}
while
(
tcount
<
nthread
);
}
}
uspinlock.h
浏览文件 @
c4cda662
...
@@ -2,7 +2,7 @@
...
@@ -2,7 +2,7 @@
#include "x86.h"
#include "x86.h"
struct
uspinlock
{
struct
uspinlock
{
uint
locked
;
// Is the lock held?
volatile
uint
locked
;
// Is the lock held?
};
};
static
void
inline
__attribute__
((
always_inline
))
static
void
inline
__attribute__
((
always_inline
))
...
...
编写
预览
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论