Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
X
xv6-public
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
问题
0
问题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
银宸时代
OS Lab Group
奖励实验
xv6-public
提交
c2da23f1
提交
c2da23f1
4月 07, 2012
创建
作者:
Nickolai Zeldovich
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
make finishproc the opposite of proc::alloc
hopefully this fixes the filetable 0x..08 corruption bug
上级
e9ed7152
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
19 行增加
和
10 行删除
+19
-10
kernel.hh
include/kernel.hh
+1
-1
proc.cc
kernel/proc.cc
+18
-9
没有找到文件。
include/kernel.hh
浏览文件 @
c2da23f1
...
@@ -164,7 +164,7 @@ int pipewrite(struct pipe*, const char*, int);
...
@@ -164,7 +164,7 @@ int pipewrite(struct pipe*, const char*, int);
// proc.c
// proc.c
struct
proc
*
copyproc
(
struct
proc
*
);
struct
proc
*
copyproc
(
struct
proc
*
);
void
finishproc
(
struct
proc
*
);
void
finishproc
(
struct
proc
*
,
bool
removepid
=
true
);
void
exit
(
void
);
void
exit
(
void
);
int
fork
(
int
);
int
fork
(
int
);
int
growproc
(
int
);
int
growproc
(
int
);
...
...
kernel/proc.cc
浏览文件 @
c2da23f1
...
@@ -354,10 +354,10 @@ fork(int flags)
...
@@ -354,10 +354,10 @@ fork(int flags)
throw_bad_alloc
();
throw_bad_alloc
();
auto
proc_cleanup
=
scoped_cleanup
([
&
np
]()
{
auto
proc_cleanup
=
scoped_cleanup
([
&
np
]()
{
if
(
!
xnspid
->
remove
(
np
->
pid
,
&
np
))
if
(
!
xnspid
->
remove
(
np
->
pid
,
&
np
))
panic
(
"fork: ns_remove"
);
panic
(
"fork: ns_remove"
);
freeproc
(
np
);
freeproc
(
np
);
});
});
if
(
flags
&
FORK_SHARE_VMAP
)
{
if
(
flags
&
FORK_SHARE_VMAP
)
{
np
->
vmap
=
myproc
()
->
vmap
;
np
->
vmap
=
myproc
()
->
vmap
;
...
@@ -400,8 +400,10 @@ fork(int flags)
...
@@ -400,8 +400,10 @@ fork(int flags)
}
}
void
void
finishproc
(
struct
proc
*
p
)
finishproc
(
struct
proc
*
p
,
bool
removepid
)
{
{
if
(
removepid
&&
!
xnspid
->
remove
(
p
->
pid
,
&
p
))
panic
(
"finishproc: ns_remove"
);
if
(
p
->
vmap
!=
nullptr
)
if
(
p
->
vmap
!=
nullptr
)
p
->
vmap
->
decref
();
p
->
vmap
->
decref
();
if
(
p
->
uwq
!=
nullptr
)
if
(
p
->
uwq
!=
nullptr
)
...
@@ -444,6 +446,7 @@ wait(void)
...
@@ -444,6 +446,7 @@ wait(void)
assert
(
w
);
assert
(
w
);
w
->
rip
=
(
void
*
)
finishproc
;
w
->
rip
=
(
void
*
)
finishproc
;
w
->
arg0
=
p
;
w
->
arg0
=
p
;
w
->
arg1
=
0
;
assert
(
wqcrit_push
(
w
,
p
->
run_cpuid_
)
>=
0
);
assert
(
wqcrit_push
(
w
,
p
->
run_cpuid_
)
>=
0
);
return
pid
;
return
pid
;
...
@@ -481,18 +484,24 @@ threadalloc(void (*fn)(void *), void *arg)
...
@@ -481,18 +484,24 @@ threadalloc(void (*fn)(void *), void *arg)
p
=
proc
::
alloc
();
p
=
proc
::
alloc
();
if
(
p
==
nullptr
)
if
(
p
==
nullptr
)
return
0
;
return
0
;
p
->
vmap
=
vmap
::
alloc
();
auto
proc_cleanup
=
scoped_cleanup
([
&
p
]()
{
if
(
p
->
vmap
==
nullptr
)
{
if
(
!
xnspid
->
remove
(
p
->
pid
,
&
p
))
panic
(
"fork: ns_remove"
);
freeproc
(
p
);
freeproc
(
p
);
});
p
->
vmap
=
vmap
::
alloc
();
if
(
p
->
vmap
==
nullptr
)
return
0
;
return
0
;
}
p
->
context
->
rip
=
(
u64
)
threadstub
;
p
->
context
->
rip
=
(
u64
)
threadstub
;
p
->
context
->
r12
=
(
u64
)
fn
;
p
->
context
->
r12
=
(
u64
)
fn
;
p
->
context
->
r13
=
(
u64
)
arg
;
p
->
context
->
r13
=
(
u64
)
arg
;
p
->
parent
=
nullptr
;
p
->
parent
=
nullptr
;
p
->
cwd
=
nullptr
;
p
->
cwd
=
nullptr
;
proc_cleanup
.
dismiss
();
return
p
;
return
p
;
}
}
...
...
编写
预览
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论