handle another out-of-memory in fork(). the policy here is not consistent,
since other calls (e.g. exec()) panic on out of memory.
This commit is contained in:
parent
bc51626aab
commit
8dc71a257d
|
@ -161,6 +161,8 @@ proc_pagetable(struct proc *p)
|
||||||
|
|
||||||
// An empty page table.
|
// An empty page table.
|
||||||
pagetable = uvmcreate();
|
pagetable = uvmcreate();
|
||||||
|
if(pagetable == 0)
|
||||||
|
return 0;
|
||||||
|
|
||||||
// map the trampoline code (for system call return)
|
// map the trampoline code (for system call return)
|
||||||
// at the highest user virtual address.
|
// at the highest user virtual address.
|
||||||
|
|
|
@ -195,13 +195,14 @@ uvmunmap(pagetable_t pagetable, uint64 va, uint64 npages, int do_free)
|
||||||
}
|
}
|
||||||
|
|
||||||
// create an empty user page table.
|
// create an empty user page table.
|
||||||
|
// returns 0 if out of memory.
|
||||||
pagetable_t
|
pagetable_t
|
||||||
uvmcreate()
|
uvmcreate()
|
||||||
{
|
{
|
||||||
pagetable_t pagetable;
|
pagetable_t pagetable;
|
||||||
pagetable = (pagetable_t) kalloc();
|
pagetable = (pagetable_t) kalloc();
|
||||||
if(pagetable == 0)
|
if(pagetable == 0)
|
||||||
panic("uvmcreate: out of memory");
|
return 0;
|
||||||
memset(pagetable, 0, PGSIZE);
|
memset(pagetable, 0, PGSIZE);
|
||||||
return pagetable;
|
return pagetable;
|
||||||
}
|
}
|
||||||
|
|
|
@ -2507,6 +2507,8 @@ main(int argc, char *argv[])
|
||||||
|
|
||||||
if(argc == 2 && strcmp(argv[1], "-c") == 0){
|
if(argc == 2 && strcmp(argv[1], "-c") == 0){
|
||||||
continuous = 1;
|
continuous = 1;
|
||||||
|
} else if(argc == 2 && strcmp(argv[1], "-C") == 0){
|
||||||
|
continuous = 2;
|
||||||
} else if(argc == 2 && argv[1][0] != '-'){
|
} else if(argc == 2 && argv[1][0] != '-'){
|
||||||
justone = argv[1];
|
justone = argv[1];
|
||||||
} else if(argc > 1){
|
} else if(argc > 1){
|
||||||
|
@ -2589,12 +2591,14 @@ main(int argc, char *argv[])
|
||||||
}
|
}
|
||||||
if(fail){
|
if(fail){
|
||||||
printf("SOME TESTS FAILED\n");
|
printf("SOME TESTS FAILED\n");
|
||||||
exit(1);
|
if(continuous != 2)
|
||||||
|
exit(1);
|
||||||
}
|
}
|
||||||
int free1 = countfree();
|
int free1 = countfree();
|
||||||
if(free1 < free0){
|
if(free1 < free0){
|
||||||
printf("FAILED -- lost some free pages\n");
|
printf("FAILED -- lost some free pages\n");
|
||||||
exit(1);
|
if(continuous != 2)
|
||||||
|
exit(1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue