Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
X
xv6-public
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
问题
0
问题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
银宸时代
OS Lab Group
奖励实验
xv6-public
提交
4cca7d25
提交
4cca7d25
5月 16, 2011
创建
作者:
Frans Kaashoek
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
copy-on-write and copy-on-demand
passes forktest on 1+2 cpu, but ...
上级
372d4c19
隐藏空白字符变更
内嵌
并排
正在显示
3 个修改的文件
包含
26 行增加
和
14 行删除
+26
-14
exec.c
exec.c
+1
-3
proc.c
proc.c
+3
-0
vm.c
vm.c
+22
-11
没有找到文件。
exec.c
浏览文件 @
4cca7d25
...
...
@@ -21,9 +21,7 @@ exec(char *path, char **argv)
pde_t
*
pgdir
=
0
,
*
oldpgdir
;
struct
vmap
*
vmap
=
0
,
*
oldvmap
;
struct
vmnode
*
vmn
=
0
;
int
odp
=
0
;
cprintf
(
"exec: %s
\n
"
,
path
);
int
odp
=
1
;
if
((
ip
=
namei
(
path
))
==
0
)
return
-
1
;
...
...
proc.c
浏览文件 @
4cca7d25
...
...
@@ -205,6 +205,8 @@ fork(int flags)
struct
proc
*
np
;
uint
cow
=
1
;
// cprintf("%d: fork\n", proc->pid);
// Allocate process.
if
((
np
=
allocproc
())
==
0
)
return
-
1
;
...
...
@@ -249,6 +251,7 @@ fork(int flags)
acquire
(
&
proc
->
lock
);
SLIST_INSERT_HEAD
(
&
proc
->
childq
,
np
,
child_next
);
release
(
&
proc
->
lock
);
// cprintf("%d: fork done (pid %d)\n", proc->pid, pid);
return
pid
;
}
...
...
vm.c
浏览文件 @
4cca7d25
...
...
@@ -246,6 +246,8 @@ vmn_alloc(uint npg, uint type)
if
(
npg
>
sizeof
(
n
->
page
)
/
sizeof
(
n
->
page
[
0
]))
{
panic
(
"vmnode too big
\n
"
);
}
for
(
uint
i
=
0
;
i
<
sizeof
(
n
->
page
)
/
sizeof
(
n
->
page
[
0
]);
i
++
)
n
->
page
[
i
]
=
0
;
n
->
npages
=
npg
;
n
->
ref
=
0
;
n
->
ip
=
0
;
...
...
@@ -288,7 +290,8 @@ vmn_free(struct vmnode *n)
}
}
if
(
n
->
ip
)
panic
(
"vmn_free: drop inode ref"
);
iput
(
n
->
ip
);
n
->
ip
=
0
;
n
->
alloc
=
0
;
}
...
...
@@ -302,10 +305,21 @@ vmn_decref(struct vmnode *n)
struct
vmnode
*
vmn_copy
(
struct
vmnode
*
n
)
{
struct
vmnode
*
c
=
vmn_alloc
pg
(
n
->
npages
);
struct
vmnode
*
c
=
vmn_alloc
(
n
->
npages
,
n
->
type
);
if
(
c
!=
0
)
{
for
(
uint
i
=
0
;
i
<
n
->
npages
;
i
++
)
{
memmove
(
c
->
page
[
i
],
n
->
page
[
i
],
PGSIZE
);
c
->
type
=
n
->
type
;
if
(
n
->
type
==
ONDEMAND
)
{
c
->
ip
=
idup
(
n
->
ip
);
c
->
offset
=
n
->
offset
;
c
->
sz
=
c
->
sz
;
}
if
(
n
->
page
[
0
])
{
// If the first page is present, all of them are present
if
(
vmn_doallocpg
(
c
)
<
0
)
{
panic
(
"vmn_copy
\n
"
);
}
for
(
uint
i
=
0
;
i
<
n
->
npages
;
i
++
)
{
memmove
(
c
->
page
[
i
],
n
->
page
[
i
],
PGSIZE
);
}
}
}
return
c
;
...
...
@@ -554,12 +568,12 @@ pagefault(pde_t *pgdir, struct vmap *vmap, uint va, uint err)
if
(
m
==
0
)
return
-
1
;
//
cprintf("%d: pf addr=0x%x err 0x%x\n", proc->pid, va, err);
// cprintf("%d: pf addr=0x%x err 0x%x\n", proc->pid, va, err);
// cprintf("%d: pf vma type = %d refcnt %d vmn type %d pte=0x%x\n", proc->pid, m->va_type, m->n->ref, m->n->type, *pte);
uint
npg
=
(
PGROUNDDOWN
(
va
)
-
m
->
va_start
)
/
PGSIZE
;
if
(
m
->
n
&&
m
->
n
->
ip
&&
*
pte
==
0x0
)
{
//cprintf("ODP\n");
if
(
m
->
n
&&
m
->
n
->
ip
&&
*
pte
==
0x0
&&
m
->
n
->
page
[
npg
]
==
0
)
{
//
cprintf("ODP\n");
if
(
vmn_doallocpg
(
m
->
n
)
<
0
)
{
panic
(
"pagefault: couldn't allocate pages"
);
}
...
...
@@ -571,7 +585,7 @@ pagefault(pde_t *pgdir, struct vmap *vmap, uint va, uint err)
pte
=
walkpgdir
(
pgdir
,
(
const
void
*
)
va
,
0
);
if
(
pte
==
0x0
)
panic
(
"pagefault: not paged in???"
);
cprintf
(
"ODP done
\n
"
);
//
cprintf("ODP done\n");
}
if
(
m
->
va_type
==
COW
&&
(
err
&
FEC_WR
))
{
...
...
@@ -606,6 +620,3 @@ pagefault(pde_t *pgdir, struct vmap *vmap, uint va, uint err)
release
(
&
m
->
lock
);
return
1
;
}
编写
预览
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论