Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
X
xv6-public
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
问题
0
问题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
银宸时代
OS Lab Group
奖励实验
xv6-public
提交
25641b3a
提交
25641b3a
3月 07, 2012
创建
作者:
Silas Boyd-Wickizer
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
If fork flags != 0, share the file table..
..now xdu and xls work in xv6 userspace with the wq stuff..
上级
33750412
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
46 行增加
和
5 行删除
+46
-5
usertests.cc
bin/usertests.cc
+36
-0
proc.cc
kernel/proc.cc
+10
-5
没有找到文件。
bin/usertests.cc
浏览文件 @
25641b3a
...
...
@@ -1628,6 +1628,41 @@ tls_test(void)
fprintf
(
1
,
"tls_test ok
\n
"
);
}
static
pthread_barrier_t
ftable_bar
;
static
volatile
int
ftable_fd
;
static
void
*
ftablethr
(
void
*
arg
)
{
char
buf
[
32
];
int
r
;
pthread_barrier_wait
(
&
ftable_bar
);
r
=
read
(
ftable_fd
,
buf
,
sizeof
(
buf
));
if
(
r
<
0
)
fprintf
(
2
,
"ftablethr: FAILED bad fd
\n
"
);
return
0
;
}
static
void
ftabletest
(
void
)
{
printf
(
"ftabletest...
\n
"
);
pthread_barrier_init
(
&
ftable_bar
,
0
,
2
);
pthread_t
th
;
pthread_create
(
&
th
,
0
,
&
ftablethr
,
0
);
ftable_fd
=
open
(
"README"
,
0
);
if
(
ftable_fd
<
0
)
die
(
"open"
);
pthread_barrier_wait
(
&
ftable_bar
);
wait
();
printf
(
"ftabletest ok
\n
"
);
}
static
pthread_key_t
tkey
;
static
pthread_barrier_t
bar0
,
bar1
;
enum
{
nthread
=
8
};
...
...
@@ -1718,6 +1753,7 @@ main(int argc, char *argv[])
bigdir
();
// slow
tls_test
();
thrtest
();
ftabletest
();
exectest
();
...
...
kernel/proc.cc
浏览文件 @
25641b3a
...
...
@@ -460,11 +460,16 @@ fork(int flags)
// Clear %eax so that fork returns 0 in the child.
np
->
tf
->
rax
=
0
;
np
->
ftable
=
new
filetable
(
*
myproc
()
->
ftable
);
if
(
np
->
ftable
==
nullptr
)
{
// XXX(sbw) leaking?
freeproc
(
np
);
return
-
1
;
if
(
flags
==
0
)
{
np
->
ftable
=
new
filetable
(
*
myproc
()
->
ftable
);
if
(
np
->
ftable
==
nullptr
)
{
// XXX(sbw) leaking?
freeproc
(
np
);
return
-
1
;
}
}
else
{
myproc
()
->
ftable
->
incref
();
np
->
ftable
=
myproc
()
->
ftable
;
}
np
->
cwd
=
idup
(
myproc
()
->
cwd
);
...
...
编写
预览
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论