Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
X
xv6-public
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
问题
0
问题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
银宸时代
OS Lab Group
奖励实验
xv6-public
提交
18432ed5
提交
18432ed5
8月 29, 2006
创建
作者:
rtm
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
nits
上级
7a37578e
隐藏空白字符变更
内嵌
并排
正在显示
3 个修改的文件
包含
10 行增加
和
15 行删除
+10
-15
Notes
Notes
+2
-2
proc.c
proc.c
+5
-9
proc.h
proc.h
+3
-4
没有找到文件。
Notes
浏览文件 @
18432ed5
...
@@ -101,7 +101,6 @@ test: one process unlinks a file while another links to it
...
@@ -101,7 +101,6 @@ test: one process unlinks a file while another links to it
test: one process opens a file while another deletes it
test: one process opens a file while another deletes it
test: deadlock d/.. vs ../d, two processes.
test: deadlock d/.. vs ../d, two processes.
test: dup() shared fd->off
test: dup() shared fd->off
test: sbrk
test: does echo foo > x truncate x?
test: does echo foo > x truncate x?
sh: support pipes? leave it for the class?
sh: support pipes? leave it for the class?
...
@@ -119,4 +118,5 @@ echo foo > bar should truncate bar
...
@@ -119,4 +118,5 @@ echo foo > bar should truncate bar
but O_TRUNC should
but O_TRUNC should
make it work on one cpu
make it work on one cpu
make it work on amsterdam
make it work on a real machine
release before acquire at end of sleep?
proc.c
浏览文件 @
18432ed5
...
@@ -38,8 +38,6 @@ setupsegs(struct proc *p)
...
@@ -38,8 +38,6 @@ setupsegs(struct proc *p)
c
->
ts
.
esp0
=
0xffffffff
;
c
->
ts
.
esp0
=
0xffffffff
;
}
}
// XXX it may be wrong to modify the current segment table!
c
->
gdt
[
0
]
=
SEG_NULL
;
c
->
gdt
[
0
]
=
SEG_NULL
;
c
->
gdt
[
SEG_KCODE
]
=
SEG
(
STA_X
|
STA_R
,
0
,
0x100000
+
64
*
1024
,
0
);
// xxx
c
->
gdt
[
SEG_KCODE
]
=
SEG
(
STA_X
|
STA_R
,
0
,
0x100000
+
64
*
1024
,
0
);
// xxx
c
->
gdt
[
SEG_KDATA
]
=
SEG
(
STA_W
,
0
,
0xffffffff
,
0
);
c
->
gdt
[
SEG_KDATA
]
=
SEG
(
STA_W
,
0
,
0xffffffff
,
0
);
...
@@ -96,7 +94,7 @@ copyproc(struct proc* p)
...
@@ -96,7 +94,7 @@ copyproc(struct proc* p)
np
->
ppid
=
p
->
pid
;
np
->
ppid
=
p
->
pid
;
release
(
&
proc_table_lock
);
release
(
&
proc_table_lock
);
// Copy
process image
memory.
// Copy
user
memory.
np
->
sz
=
p
->
sz
;
np
->
sz
=
p
->
sz
;
np
->
mem
=
kalloc
(
np
->
sz
);
np
->
mem
=
kalloc
(
np
->
sz
);
if
(
np
->
mem
==
0
){
if
(
np
->
mem
==
0
){
...
@@ -214,18 +212,16 @@ sched(void)
...
@@ -214,18 +212,16 @@ sched(void)
void
void
yield
(
void
)
yield
(
void
)
{
{
struct
proc
*
p
;
struct
proc
*
p
=
curproc
[
cpu
()]
;
if
((
p
=
curproc
[
cpu
()])
==
0
||
curproc
[
cpu
()]
->
state
!=
RUNNING
)
panic
(
"yield"
);
acquire
(
&
proc_table_lock
);
acquire
(
&
proc_table_lock
);
p
->
state
=
RUNNABLE
;
p
->
state
=
RUNNABLE
;
sched
();
sched
();
release
(
&
proc_table_lock
);
release
(
&
proc_table_lock
);
}
}
// A
process
's very first scheduling by scheduler()
// A
fork child
's very first scheduling by scheduler()
// will longjmp here
to do the first jump in
to user space.
// will longjmp here
. "return"
to user space.
void
void
forkret
(
void
)
forkret
(
void
)
{
{
...
@@ -371,7 +367,7 @@ proc_wait(void)
...
@@ -371,7 +367,7 @@ proc_wait(void)
acquire
(
&
proc_table_lock
);
acquire
(
&
proc_table_lock
);
for
(;;){
for
(;;){
// Scan through table looking zombie children.
// Scan through table looking
for
zombie children.
havekids
=
0
;
havekids
=
0
;
for
(
i
=
0
;
i
<
NPROC
;
i
++
){
for
(
i
=
0
;
i
<
NPROC
;
i
++
){
p
=
&
proc
[
i
];
p
=
&
proc
[
i
];
...
...
proc.h
浏览文件 @
18432ed5
...
@@ -36,9 +36,9 @@ struct jmpbuf {
...
@@ -36,9 +36,9 @@ struct jmpbuf {
enum
proc_state
{
UNUSED
,
EMBRYO
,
SLEEPING
,
RUNNABLE
,
RUNNING
,
ZOMBIE
};
enum
proc_state
{
UNUSED
,
EMBRYO
,
SLEEPING
,
RUNNABLE
,
RUNNING
,
ZOMBIE
};
struct
proc
{
struct
proc
{
char
*
mem
;
// start of process's physical memory
char
*
mem
;
// start of process's memory (a kernel address)
uint
sz
;
// total size of mem, including kernel stack
uint
sz
;
// user memory size
char
*
kstack
;
// kernel stack
, separate from mem so it doesn't move
char
*
kstack
;
// kernel stack
enum
proc_state
state
;
enum
proc_state
state
;
int
pid
;
int
pid
;
int
ppid
;
int
ppid
;
...
@@ -52,7 +52,6 @@ struct proc{
...
@@ -52,7 +52,6 @@ struct proc{
extern
struct
proc
proc
[];
extern
struct
proc
proc
[];
extern
struct
proc
*
curproc
[
NCPU
];
// can be NULL if no proc running.
extern
struct
proc
*
curproc
[
NCPU
];
// can be NULL if no proc running.
// XXX move curproc into cpu structure?
#define MPSTACK 512
#define MPSTACK 512
...
...
编写
预览
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论