Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
CSEP551
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Krishna Vinnakota
CSEP551
Commits
dd645ef1
Commit
dd645ef1
authored
14 years ago
by
Austin Clements
Browse files
Options
Downloads
Patches
Plain Diff
Cleanup if allocuvm fails to alloc. Add a test.
parent
5048762c
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
README
+2
-2
2 additions, 2 deletions
README
usertests.c
+36
-0
36 additions, 0 deletions
usertests.c
vm.c
+2
-1
2 additions, 1 deletion
vm.c
with
40 additions
and
3 deletions
README
+
2
−
2
View file @
dd645ef1
...
...
@@ -20,8 +20,8 @@ The following people made contributions:
Cliff Frey (MP)
Xiao Yu (MP)
In addition, we are grateful for the patches
submit
ted by Greg
Price,
Yandong Mao, and Hitoshi Mitake.
In addition, we are grateful for the patches
contribu
ted 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.
...
...
This diff is collapsed.
Click to expand it.
usertests.c
+
36
−
0
View file @
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
));
...
...
This diff is collapsed.
Click to expand it.
vm.c
+
2
−
1
View file @
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
);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment