Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
X
xv6-public
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
问题
0
问题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
银宸时代
OS Lab Group
奖励实验
xv6-public
提交
a39561c0
提交
a39561c0
5月 08, 2011
创建
作者:
Nickolai Zeldovich
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
get rid of allocuvm/deallocuvm
上级
b5b59d7f
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
3 行增加
和
58 行删除
+3
-58
defs.h
defs.h
+0
-2
vm.c
vm.c
+3
-56
没有找到文件。
defs.h
浏览文件 @
a39561c0
...
...
@@ -166,8 +166,6 @@ void vmap_free(struct vmap *);
int
vmap_insert
(
struct
vmap
*
,
struct
vmnode
*
n
,
uint
);
struct
vma
*
vmap_lookup
(
struct
vmap
*
,
uint
);
struct
vmap
*
vmap_copy
(
struct
vmap
*
);
int
allocuvm
(
pde_t
*
,
uint
,
uint
);
int
deallocuvm
(
pde_t
*
,
uint
,
uint
);
void
freevm
(
pde_t
*
);
void
switchuvm
(
struct
proc
*
);
void
switchkvm
(
void
);
...
...
vm.c
浏览文件 @
a39561c0
...
...
@@ -228,8 +228,10 @@ vmn_allocpg(uint npg)
void
vmn_free
(
struct
vmnode
*
n
)
{
for
(
uint
i
=
0
;
i
<
n
->
npages
;
i
++
)
for
(
uint
i
=
0
;
i
<
n
->
npages
;
i
++
)
{
kfree
((
char
*
)
n
->
page
[
i
]);
n
->
page
[
i
]
=
0
;
}
n
->
alloc
=
0
;
}
...
...
@@ -360,60 +362,6 @@ vmn_load(struct vmnode *vmn, struct inode *ip, uint offset, uint sz)
return
0
;
}
// Allocate page tables and physical memory to grow process from oldsz to
// newsz, which need not be page aligned. Returns new size or 0 on error.
int
allocuvm
(
pde_t
*
pgdir
,
uint
oldsz
,
uint
newsz
)
{
char
*
mem
;
uint
a
;
if
(
newsz
>
USERTOP
)
return
0
;
if
(
newsz
<
oldsz
)
return
oldsz
;
a
=
PGROUNDUP
(
oldsz
);
for
(;
a
<
newsz
;
a
+=
PGSIZE
){
mem
=
kalloc
();
if
(
mem
==
0
){
cprintf
(
"allocuvm out of memory
\n
"
);
deallocuvm
(
pgdir
,
newsz
,
oldsz
);
return
0
;
}
memset
(
mem
,
0
,
PGSIZE
);
mappages
(
pgdir
,
(
char
*
)
a
,
PGSIZE
,
PADDR
(
mem
),
PTE_W
|
PTE_U
);
}
return
newsz
;
}
// Deallocate user pages to bring the process size from oldsz to
// newsz. oldsz and newsz need not be page-aligned, nor does newsz
// need to be less than oldsz. oldsz can be larger than the actual
// process size. Returns the new process size.
int
deallocuvm
(
pde_t
*
pgdir
,
uint
oldsz
,
uint
newsz
)
{
pte_t
*
pte
;
uint
a
,
pa
;
if
(
newsz
>=
oldsz
)
return
oldsz
;
a
=
PGROUNDUP
(
newsz
);
for
(;
a
<
oldsz
;
a
+=
PGSIZE
){
pte
=
walkpgdir
(
pgdir
,
(
char
*
)
a
,
0
);
if
(
pte
&&
(
*
pte
&
PTE_P
)
!=
0
){
pa
=
PTE_ADDR
(
*
pte
);
if
(
pa
==
0
)
panic
(
"kfree"
);
kfree
((
char
*
)
pa
);
// assuming pa==va
*
pte
=
0
;
}
}
return
newsz
;
}
// Free a page table and all the physical memory pages
// in the user part.
void
...
...
@@ -423,7 +371,6 @@ freevm(pde_t *pgdir)
if
(
pgdir
==
0
)
panic
(
"freevm: no pgdir"
);
deallocuvm
(
pgdir
,
USERTOP
,
0
);
for
(
i
=
0
;
i
<
NPDENTRIES
;
i
++
){
if
(
pgdir
[
i
]
&
PTE_P
)
kfree
((
char
*
)
PTE_ADDR
(
pgdir
[
i
]));
...
...
编写
预览
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论