Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
X
xv6-public
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
问题
0
问题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
银宸时代
OS Lab Group
奖励实验
xv6-public
提交
8f783790
提交
8f783790
2月 16, 2012
创建
作者:
Nickolai Zeldovich
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
vmap methods
上级
fed708d4
隐藏空白字符变更
内嵌
并排
正在显示
6 个修改的文件
包含
24 行增加
和
26 行删除
+24
-26
exec.cc
exec.cc
+2
-2
kernel.h
kernel.h
+0
-3
proc.cc
proc.cc
+2
-2
sysproc.cc
sysproc.cc
+1
-1
vm.cc
vm.cc
+16
-18
vm.hh
vm.hh
+3
-0
没有找到文件。
exec.cc
浏览文件 @
8f783790
...
@@ -230,7 +230,7 @@ exec(char *path, char **argv)
...
@@ -230,7 +230,7 @@ exec(char *path, char **argv)
myproc
()
->
tf
->
rip
=
elf
.
entry
;
// main
myproc
()
->
tf
->
rip
=
elf
.
entry
;
// main
switchuvm
(
myproc
());
switchuvm
(
myproc
());
vmap_decref
(
oldvmap
);
oldvmap
->
decref
(
);
gc_end_epoch
();
gc_end_epoch
();
prof_end
(
exec_prof
);
prof_end
(
exec_prof
);
...
@@ -239,7 +239,7 @@ exec(char *path, char **argv)
...
@@ -239,7 +239,7 @@ exec(char *path, char **argv)
bad:
bad:
cprintf
(
"exec failed
\n
"
);
cprintf
(
"exec failed
\n
"
);
if
(
vmap
)
if
(
vmap
)
vmap
_decref
(
vmap
);
vmap
->
decref
(
);
if
(
vmn
)
if
(
vmn
)
vmn_free
(
vmn
);
vmn_free
(
vmn
);
gc_end_epoch
();
gc_end_epoch
();
...
...
kernel.h
浏览文件 @
8f783790
...
@@ -259,11 +259,8 @@ void vmn_free(struct vmnode *);
...
@@ -259,11 +259,8 @@ void vmn_free(struct vmnode *);
void
switchuvm
(
struct
proc
*
);
void
switchuvm
(
struct
proc
*
);
void
switchkvm
(
void
);
void
switchkvm
(
void
);
int
pagefault
(
struct
vmap
*
,
uptr
,
u32
);
int
pagefault
(
struct
vmap
*
,
uptr
,
u32
);
void
vmap_decref
(
struct
vmap
*
);
int
vmn_load
(
struct
vmnode
*
,
struct
inode
*
,
u64
,
u64
);
int
vmn_load
(
struct
vmnode
*
,
struct
inode
*
,
u64
,
u64
);
int
vmap_remove
(
struct
vmap
*
,
uptr
,
u64
);
void
updatepages
(
pml4e_t
*
,
void
*
,
void
*
,
int
);
void
updatepages
(
pml4e_t
*
,
void
*
,
void
*
,
int
);
struct
vmap
*
vmap_copy
(
struct
vmap
*
,
int
);
// wq.c
// wq.c
int
wq_trywork
(
void
);
int
wq_trywork
(
void
);
...
...
proc.cc
浏览文件 @
8f783790
...
@@ -571,7 +571,7 @@ fork(int flags)
...
@@ -571,7 +571,7 @@ fork(int flags)
if
(
flags
==
0
)
{
if
(
flags
==
0
)
{
// Copy process state from p.
// Copy process state from p.
if
((
np
->
vmap
=
vmap_copy
(
myproc
()
->
vmap
,
cow
))
==
0
){
if
((
np
->
vmap
=
myproc
()
->
vmap
->
copy
(
cow
))
==
0
){
ksfree
(
slab_stack
,
np
->
kstack
);
ksfree
(
slab_stack
,
np
->
kstack
);
np
->
kstack
=
0
;
np
->
kstack
=
0
;
np
->
state
=
UNUSED
;
np
->
state
=
UNUSED
;
...
@@ -635,7 +635,7 @@ wait(void)
...
@@ -635,7 +635,7 @@ wait(void)
release
(
&
myproc
()
->
lock
);
release
(
&
myproc
()
->
lock
);
ksfree
(
slab_stack
,
p
->
kstack
);
ksfree
(
slab_stack
,
p
->
kstack
);
p
->
kstack
=
0
;
p
->
kstack
=
0
;
vmap_decref
(
p
->
vmap
);
p
->
vmap
->
decref
(
);
p
->
state
=
UNUSED
;
p
->
state
=
UNUSED
;
if
(
!
xnspid
->
remove
(
p
->
pid
,
&
p
))
if
(
!
xnspid
->
remove
(
p
->
pid
,
&
p
))
panic
(
"wait: ns_remove"
);
panic
(
"wait: ns_remove"
);
...
...
sysproc.cc
浏览文件 @
8f783790
...
@@ -132,7 +132,7 @@ sys_unmap(void)
...
@@ -132,7 +132,7 @@ sys_unmap(void)
return
-
1
;
return
-
1
;
if
(
argint64
(
1
,
&
len
)
<
0
)
if
(
argint64
(
1
,
&
len
)
<
0
)
return
-
1
;
return
-
1
;
if
(
vmap_remove
(
myproc
()
->
vmap
,
PGROUNDDOWN
(
addr
),
PGROUNDUP
(
len
))
<
0
)
if
(
myproc
()
->
vmap
->
remove
(
PGROUNDDOWN
(
addr
),
PGROUNDUP
(
len
))
<
0
)
return
-
1
;
return
-
1
;
updatepages
(
myproc
()
->
vmap
->
pml4
,
updatepages
(
myproc
()
->
vmap
->
pml4
,
...
...
vm.cc
浏览文件 @
8f783790
...
@@ -82,10 +82,10 @@ vmn_allocpg(u64 npg)
...
@@ -82,10 +82,10 @@ vmn_allocpg(u64 npg)
}
}
void
void
vmap
_decref
(
struct
vmap
*
m
)
vmap
::
decref
(
)
{
{
if
(
--
m
->
ref
==
0
)
if
(
--
ref
==
0
)
delete
m
;
delete
this
;
}
}
vmap
::
vmap
()
vmap
::
vmap
()
...
@@ -377,15 +377,15 @@ vmap::insert(vmnode *n, uptr va_start)
...
@@ -377,15 +377,15 @@ vmap::insert(vmnode *n, uptr va_start)
return
0
;
return
0
;
}
}
struct
vmap
*
vmap
*
vmap
_copy
(
struct
vmap
*
m
,
int
share
)
vmap
::
copy
(
int
share
)
{
{
struct
vmap
*
nm
=
vmap_alloc
();
struct
vmap
*
nm
=
vmap_alloc
();
if
(
nm
==
0
)
if
(
nm
==
0
)
return
0
;
return
0
;
scoped_acquire
sa
(
&
m
->
lock
);
scoped_acquire
sa
(
&
lock
);
for
(
range
*
r
:
m
->
cr
)
{
for
(
range
*
r
:
cr
)
{
struct
vma
*
e
=
(
struct
vma
*
)
r
->
value
;
struct
vma
*
e
=
(
struct
vma
*
)
r
->
value
;
struct
vma
*
ne
=
new
vma
();
struct
vma
*
ne
=
new
vma
();
if
(
ne
==
0
)
if
(
ne
==
0
)
...
@@ -396,16 +396,16 @@ vmap_copy(struct vmap *m, int share)
...
@@ -396,16 +396,16 @@ vmap_copy(struct vmap *m, int share)
if
(
share
)
{
if
(
share
)
{
ne
->
n
=
e
->
n
;
ne
->
n
=
e
->
n
;
ne
->
va_type
=
COW
;
ne
->
va_type
=
COW
;
acquire
(
&
e
->
lock
);
scoped_acquire
sae
(
&
e
->
lock
);
e
->
va_type
=
COW
;
e
->
va_type
=
COW
;
updatepages
(
m
->
pml4
,
(
void
*
)
(
e
->
va_start
),
(
void
*
)
(
e
->
va_end
),
PTE_COW
);
updatepages
(
pml4
,
(
void
*
)
(
e
->
va_start
),
(
void
*
)
(
e
->
va_end
),
PTE_COW
);
release
(
&
e
->
lock
);
}
else
{
}
else
{
ne
->
n
=
vmn_copy
(
e
->
n
);
ne
->
n
=
vmn_copy
(
e
->
n
);
ne
->
va_type
=
e
->
va_type
;
ne
->
va_type
=
e
->
va_type
;
}
}
if
(
ne
->
n
==
0
)
if
(
ne
->
n
==
0
)
goto
err
;
goto
err
;
ne
->
n
->
ref
++
;
ne
->
n
->
ref
++
;
...
@@ -413,7 +413,7 @@ vmap_copy(struct vmap *m, int share)
...
@@ -413,7 +413,7 @@ vmap_copy(struct vmap *m, int share)
}
}
if
(
share
)
if
(
share
)
lcr3
(
v2p
(
m
->
pml4
));
// Reload hardware page table
lcr3
(
v2p
(
pml4
));
// Reload hardware page table
return
nm
;
return
nm
;
...
@@ -423,21 +423,19 @@ vmap_copy(struct vmap *m, int share)
...
@@ -423,21 +423,19 @@ vmap_copy(struct vmap *m, int share)
}
}
int
int
vmap
_remove
(
struct
vmap
*
m
,
uptr
va_start
,
u64
len
)
vmap
::
remove
(
uptr
va_start
,
uptr
len
)
{
{
acquire
(
&
m
->
lock
);
scoped_acquire
sa
(
&
lock
);
uptr
va_end
=
va_start
+
len
;
uptr
va_end
=
va_start
+
len
;
struct
range
*
r
=
m
->
cr
.
search
(
va_start
,
len
);
struct
range
*
r
=
cr
.
search
(
va_start
,
len
);
if
(
r
==
0
)
if
(
r
==
0
)
panic
(
"no vma?"
);
panic
(
"no vma?"
);
struct
vma
*
e
=
(
struct
vma
*
)
r
->
value
;
struct
vma
*
e
=
(
struct
vma
*
)
r
->
value
;
if
(
e
->
va_start
!=
va_start
||
e
->
va_end
!=
va_end
)
{
if
(
e
->
va_start
!=
va_start
||
e
->
va_end
!=
va_end
)
{
cprintf
(
"vmap_remove: partial unmap unsupported
\n
"
);
cprintf
(
"vmap_remove: partial unmap unsupported
\n
"
);
release
(
&
m
->
lock
);
return
-
1
;
return
-
1
;
}
}
m
->
cr
.
del
(
va_start
,
len
);
cr
.
del
(
va_start
,
len
);
gc_delayed
(
e
);
gc_delayed
(
e
);
release
(
&
m
->
lock
);
return
0
;
return
0
;
}
}
vm.hh
浏览文件 @
8f783790
...
@@ -50,6 +50,9 @@ struct vmap {
...
@@ -50,6 +50,9 @@ struct vmap {
vmap
();
vmap
();
~
vmap
();
~
vmap
();
void
decref
();
vmap
*
copy
(
int
share
);
vma
*
lookup
(
uptr
start
,
uptr
len
);
vma
*
lookup
(
uptr
start
,
uptr
len
);
int
insert
(
vmnode
*
n
,
uptr
va_start
);
int
insert
(
vmnode
*
n
,
uptr
va_start
);
int
remove
(
uptr
start
,
uptr
len
);
};
};
编写
预览
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论