Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
X
xv6-public
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
问题
0
问题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
银宸时代
OS Lab Group
奖励实验
xv6-public
提交
dd645ef1
提交
dd645ef1
8月 31, 2010
创建
作者:
Austin Clements
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Cleanup if allocuvm fails to alloc. Add a test.
上级
5048762c
隐藏空白字符变更
内嵌
并排
正在显示
3 个修改的文件
包含
40 行增加
和
3 行删除
+40
-3
README
README
+2
-2
usertests.c
usertests.c
+36
-0
vm.c
vm.c
+2
-1
没有找到文件。
README
浏览文件 @
dd645ef1
...
...
@@ -20,8 +20,8 @@ The following people made contributions:
Cliff Frey (MP)
Xiao Yu (MP)
In addition, we are grateful for the patches
submitted by Greg Price,
Yandong Mao, and Hitoshi Mitake.
In addition, we are grateful for the patches
contributed by Greg
Price,
Yandong Mao, and Hitoshi Mitake.
The code in the files that constitute xv6 is
Copyright 2006-2007 Frans Kaashoek, Robert Morris, and Russ Cox.
...
...
usertests.c
浏览文件 @
dd645ef1
...
...
@@ -324,6 +324,7 @@ mem(void)
void
*
m1
,
*
m2
;
int
pid
,
ppid
;
printf
(
1
,
"mem test
\n
"
);
ppid
=
getpid
();
if
((
pid
=
fork
())
==
0
){
m1
=
0
;
...
...
@@ -1332,6 +1333,41 @@ sbrktest(void)
wait
();
}
// if we run the system out of memory, does it clean up the last
// failed allocation?
sbrk
(
-
(
sbrk
(
0
)
-
oldbrk
));
int
pids
[
32
];
int
fds
[
2
];
if
(
pipe
(
fds
)
!=
0
){
printf
(
1
,
"pipe() failed
\n
"
);
exit
();
}
for
(
i
=
0
;
i
<
sizeof
(
pids
)
/
sizeof
(
pids
[
0
]);
i
++
){
if
((
pids
[
i
]
=
fork
())
==
0
)
{
// allocate the full 640K
sbrk
((
640
*
1024
)
-
(
uint
)
sbrk
(
0
));
write
(
fds
[
1
],
"x"
,
1
);
// sit around until killed
while
(
1
)
sleep
(
1000
);
}
char
scratch
;
if
(
pids
[
i
]
!=
-
1
)
read
(
fds
[
0
],
&
scratch
,
1
);
}
// if those failed allocations freed up the pages they did allocate,
// we'll be able to allocate here
c
=
sbrk
(
4096
);
for
(
i
=
0
;
i
<
sizeof
(
pids
)
/
sizeof
(
pids
[
0
]);
i
++
){
if
(
pids
[
i
]
==
-
1
)
continue
;
kill
(
pids
[
i
]);
wait
();
}
if
(
c
==
(
char
*
)
0xffffffff
)
{
printf
(
stdout
,
"failed sbrk leaked memory
\n
"
);
exit
();
}
if
(
sbrk
(
0
)
>
oldbrk
)
sbrk
(
-
(
sbrk
(
0
)
-
oldbrk
));
...
...
vm.c
浏览文件 @
dd645ef1
...
...
@@ -195,7 +195,8 @@ allocuvm(pde_t *pgdir, char *addr, uint sz)
if
(
pte
==
0
||
(
*
pte
&
PTE_P
)
==
0
){
char
*
mem
=
kalloc
();
if
(
mem
==
0
){
// XXX clean up?
cprintf
(
"allocuvm out of memory
\n
"
);
deallocuvm
(
pgdir
,
addr
,
sz
);
return
0
;
}
memset
(
mem
,
0
,
PGSIZE
);
...
...
编写
预览
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论