Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
X
xv6-public
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
问题
0
问题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
银宸时代
OS Lab Group
奖励实验
xv6-public
提交
3a057d12
提交
3a057d12
8月 23, 2007
创建
作者:
rsc
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
avoid hardcoding init as pid 1 proc[0]
上级
1d7839a1
隐藏空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
13 行增加
和
7 行删除
+13
-7
proc.c
proc.c
+13
-7
没有找到文件。
proc.c
浏览文件 @
3a057d12
...
@@ -11,6 +11,8 @@ struct spinlock proc_table_lock;
...
@@ -11,6 +11,8 @@ struct spinlock proc_table_lock;
struct
proc
proc
[
NPROC
];
struct
proc
proc
[
NPROC
];
struct
proc
*
curproc
[
NCPU
];
struct
proc
*
curproc
[
NCPU
];
static
struct
proc
*
initproc
;
int
nextpid
=
1
;
int
nextpid
=
1
;
extern
void
forkret
(
void
);
extern
void
forkret
(
void
);
extern
void
forkret1
(
struct
trapframe
*
);
extern
void
forkret1
(
struct
trapframe
*
);
...
@@ -162,7 +164,7 @@ userinit(void)
...
@@ -162,7 +164,7 @@ userinit(void)
p
->
tf
->
eflags
=
FL_IF
;
p
->
tf
->
eflags
=
FL_IF
;
p
->
tf
->
esp
=
p
->
sz
;
p
->
tf
->
esp
=
p
->
sz
;
//
Push dummy return address to placat
e gcc.
//
Make return address readable; needed for som
e gcc.
p
->
tf
->
esp
-=
4
;
p
->
tf
->
esp
-=
4
;
*
(
uint
*
)(
p
->
mem
+
p
->
tf
->
esp
)
=
0xefefefef
;
*
(
uint
*
)(
p
->
mem
+
p
->
tf
->
esp
)
=
0xefefefef
;
...
@@ -170,6 +172,8 @@ userinit(void)
...
@@ -170,6 +172,8 @@ userinit(void)
memmove
(
p
->
mem
,
_binary_initcode_start
,
(
int
)
_binary_initcode_size
);
memmove
(
p
->
mem
,
_binary_initcode_start
,
(
int
)
_binary_initcode_size
);
safestrcpy
(
p
->
name
,
"initcode"
,
sizeof
(
p
->
name
));
safestrcpy
(
p
->
name
,
"initcode"
,
sizeof
(
p
->
name
));
p
->
state
=
RUNNABLE
;
p
->
state
=
RUNNABLE
;
initproc
=
p
;
}
}
//PAGEBREAK: 42
//PAGEBREAK: 42
...
@@ -346,7 +350,7 @@ proc_exit(void)
...
@@ -346,7 +350,7 @@ proc_exit(void)
struct
proc
*
p
;
struct
proc
*
p
;
int
fd
;
int
fd
;
if
(
cp
->
pid
==
1
)
if
(
cp
==
initproc
)
panic
(
"init exiting"
);
panic
(
"init exiting"
);
// Close all open files.
// Close all open files.
...
@@ -362,17 +366,19 @@ proc_exit(void)
...
@@ -362,17 +366,19 @@ proc_exit(void)
acquire
(
&
proc_table_lock
);
acquire
(
&
proc_table_lock
);
// Wake up
our
parent.
// Wake up
waiting
parent.
for
(
p
=
proc
;
p
<
&
proc
[
NPROC
];
p
++
)
for
(
p
=
proc
;
p
<
&
proc
[
NPROC
];
p
++
)
if
(
p
->
pid
==
cp
->
ppid
)
if
(
p
->
pid
==
cp
->
ppid
)
wakeup1
(
p
);
wakeup1
(
p
);
//
Reparent our children to process 1
.
//
Pass abandoned children to init
.
for
(
p
=
proc
;
p
<
&
proc
[
NPROC
];
p
++
)
for
(
p
=
proc
;
p
<
&
proc
[
NPROC
];
p
++
)
{
if
(
p
->
ppid
==
cp
->
pid
){
if
(
p
->
ppid
==
cp
->
pid
){
p
->
ppid
=
1
;
p
->
ppid
=
initproc
->
pid
;
wakeup1
(
&
proc
[
1
]);
// init
if
(
p
->
state
==
ZOMBIE
)
wakeup1
(
initproc
);
}
}
}
// Jump into the scheduler, never to return.
// Jump into the scheduler, never to return.
cp
->
killed
=
0
;
cp
->
killed
=
0
;
...
...
编写
预览
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论