Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
X
xv6-public
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
问题
0
问题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
银宸时代
OS Lab Group
奖励实验
xv6-public
提交
643b122b
提交
643b122b
7月 15, 2006
创建
作者:
rsc
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
move everything having to do with proc_table_lock into proc.c
上级
34976701
隐藏空白字符变更
内嵌
并排
正在显示
4 个修改的文件
包含
62 行增加
和
47 行删除
+62
-47
defs.h
defs.h
+2
-0
picirq.c
picirq.c
+1
-1
proc.c
proc.c
+50
-0
syscall.c
syscall.c
+9
-46
没有找到文件。
defs.h
浏览文件 @
643b122b
...
...
@@ -19,6 +19,8 @@ void sleep(void *, struct spinlock *);
void
wakeup
(
void
*
);
void
scheduler
(
void
);
void
proc_exit
(
void
);
int
proc_kill
(
int
);
int
proc_wait
(
void
);
void
yield
(
void
);
void
cli
(
void
);
void
sti
(
void
);
...
...
picirq.c
浏览文件 @
643b122b
...
...
@@ -53,7 +53,7 @@ pic_init(void)
outb
(
IO_PIC2
+
1
,
IRQ_SLAVE
);
// ICW3
// NB Automatic EOI mode doesn't tend to work on the slave.
// Linux source code says it's "to be investigated".
outb
(
IO_PIC2
+
1
,
0x
3
);
// ICW4
outb
(
IO_PIC2
+
1
,
0x
1
);
// ICW4
// OCW3: 0ef01prs
// ef: 0x = NOP, 10 = clear specific mask, 11 = set specific mask
...
...
proc.c
浏览文件 @
643b122b
...
...
@@ -281,6 +281,56 @@ proc_exit()
panic
(
"a zombie revived"
);
}
int
proc_wait
(
void
)
{
struct
proc
*
p
;
struct
proc
*
cp
=
curproc
[
cpu
()];
int
any
,
pid
;
acquire
(
&
proc_table_lock
);
while
(
1
){
any
=
0
;
for
(
p
=
proc
;
p
<
&
proc
[
NPROC
];
p
++
){
if
(
p
->
state
==
ZOMBIE
&&
p
->
ppid
==
cp
->
pid
){
kfree
(
p
->
mem
,
p
->
sz
);
kfree
(
p
->
kstack
,
KSTACKSIZE
);
pid
=
p
->
pid
;
p
->
state
=
UNUSED
;
release
(
&
proc_table_lock
);
return
pid
;
}
if
(
p
->
state
!=
UNUSED
&&
p
->
ppid
==
cp
->
pid
)
any
=
1
;
}
if
(
any
==
0
){
release
(
&
proc_table_lock
);
return
-
1
;
}
sleep
(
cp
,
&
proc_table_lock
);
}
}
int
proc_kill
(
int
pid
)
{
struct
proc
*
p
;
acquire
(
&
proc_table_lock
);
for
(
p
=
proc
;
p
<
&
proc
[
NPROC
];
p
++
){
if
(
p
->
pid
==
pid
&&
p
->
state
!=
UNUSED
){
p
->
killed
=
1
;
if
(
p
->
state
==
WAITING
)
p
->
state
=
RUNNABLE
;
release
(
&
proc_table_lock
);
return
0
;
}
}
release
(
&
proc_table_lock
);
return
-
1
;
}
// disable interrupts
void
cli
(
void
)
...
...
syscall.c
浏览文件 @
643b122b
...
...
@@ -162,38 +162,22 @@ int
sys_exit
(
void
)
{
proc_exit
();
return
0
;
return
0
;
// not reached
}
int
sys_wait
(
void
)
{
struct
proc
*
p
;
struct
proc
*
cp
=
curproc
[
cpu
()];
int
any
,
pid
;
return
proc_wait
();
}
acquire
(
&
proc_table_lock
);
int
sys_kill
(
void
)
{
int
pid
;
while
(
1
){
any
=
0
;
for
(
p
=
proc
;
p
<
&
proc
[
NPROC
];
p
++
){
if
(
p
->
state
==
ZOMBIE
&&
p
->
ppid
==
cp
->
pid
){
kfree
(
p
->
mem
,
p
->
sz
);
kfree
(
p
->
kstack
,
KSTACKSIZE
);
pid
=
p
->
pid
;
p
->
state
=
UNUSED
;
release
(
&
proc_table_lock
);
return
pid
;
}
if
(
p
->
state
!=
UNUSED
&&
p
->
ppid
==
cp
->
pid
)
any
=
1
;
}
if
(
any
==
0
){
release
(
&
proc_table_lock
);
return
-
1
;
}
sleep
(
cp
,
&
proc_table_lock
);
}
fetcharg
(
0
,
&
pid
);
return
proc_kill
(
pid
);
}
int
...
...
@@ -232,27 +216,6 @@ sys_block(void)
}
int
sys_kill
(
void
)
{
int
pid
;
struct
proc
*
p
;
fetcharg
(
0
,
&
pid
);
acquire
(
&
proc_table_lock
);
for
(
p
=
proc
;
p
<
&
proc
[
NPROC
];
p
++
){
if
(
p
->
pid
==
pid
&&
p
->
state
!=
UNUSED
){
p
->
killed
=
1
;
if
(
p
->
state
==
WAITING
)
p
->
state
=
RUNNABLE
;
release
(
&
proc_table_lock
);
return
0
;
}
}
release
(
&
proc_table_lock
);
return
-
1
;
}
int
sys_panic
(
void
)
{
struct
proc
*
p
=
curproc
[
cpu
()];
...
...
编写
预览
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论