Adjust sbrk test for large user address spaces
All tests pass
This commit is contained in:
parent
67d4254d15
commit
6479766334
2 changed files with 10 additions and 21 deletions
29
usertests.c
29
usertests.c
|
@ -5,6 +5,7 @@
|
||||||
#include "fcntl.h"
|
#include "fcntl.h"
|
||||||
#include "syscall.h"
|
#include "syscall.h"
|
||||||
#include "traps.h"
|
#include "traps.h"
|
||||||
|
#include "memlayout.h"
|
||||||
|
|
||||||
char buf[2048];
|
char buf[2048];
|
||||||
char name[3];
|
char name[3];
|
||||||
|
@ -1247,7 +1248,7 @@ sbrktest(void)
|
||||||
// can one sbrk() less than a page?
|
// can one sbrk() less than a page?
|
||||||
a = sbrk(0);
|
a = sbrk(0);
|
||||||
int i;
|
int i;
|
||||||
for(i = 0; i < 5000; i++){
|
for(i = 0; i < 5000; i++){
|
||||||
b = sbrk(1);
|
b = sbrk(1);
|
||||||
if(b != a){
|
if(b != a){
|
||||||
printf(stdout, "sbrk test failed %d %x %x\n", i, a, b);
|
printf(stdout, "sbrk test failed %d %x %x\n", i, a, b);
|
||||||
|
@ -1271,24 +1272,18 @@ sbrktest(void)
|
||||||
exit();
|
exit();
|
||||||
wait();
|
wait();
|
||||||
|
|
||||||
// can one allocate the full 640K?
|
// can one grow address space to something big?
|
||||||
|
#define BIG (100*1024*1024)
|
||||||
a = sbrk(0);
|
a = sbrk(0);
|
||||||
amt = (640 * 1024) - (uint)a;
|
amt = (BIG) - (uint)a;
|
||||||
p = sbrk(amt);
|
p = sbrk(amt);
|
||||||
if(p != a){
|
if (p != a) {
|
||||||
printf(stdout, "sbrk test failed 640K test, p %x a %x\n", p, a);
|
printf(stdout, "sbrk test failed to grow big address space; enough phys mem?\n");
|
||||||
exit();
|
exit();
|
||||||
}
|
}
|
||||||
lastaddr = (char*)(640 * 1024 - 1);
|
lastaddr = (char*) (BIG-1);
|
||||||
*lastaddr = 99;
|
*lastaddr = 99;
|
||||||
|
|
||||||
// is one forbidden from allocating more than 640K?
|
|
||||||
c = sbrk(4096);
|
|
||||||
if(c != (char*)0xffffffff){
|
|
||||||
printf(stdout, "sbrk allocated more than 640K, c %x\n", c);
|
|
||||||
exit();
|
|
||||||
}
|
|
||||||
|
|
||||||
// can one de-allocate?
|
// can one de-allocate?
|
||||||
a = sbrk(0);
|
a = sbrk(0);
|
||||||
c = sbrk(-4096);
|
c = sbrk(-4096);
|
||||||
|
@ -1315,14 +1310,8 @@ sbrktest(void)
|
||||||
exit();
|
exit();
|
||||||
}
|
}
|
||||||
|
|
||||||
c = sbrk(4096);
|
|
||||||
if(c != (char*)0xffffffff){
|
|
||||||
printf(stdout, "sbrk was able to re-allocate beyond 640K, c %x\n", c);
|
|
||||||
exit();
|
|
||||||
}
|
|
||||||
|
|
||||||
// can we read the kernel's memory?
|
// can we read the kernel's memory?
|
||||||
for(a = (char*)(640*1024); a < (char*)2000000; a += 50000){
|
for(a = (char*)(KERNBASE); a < (char*) (KERNBASE+2000000); a += 50000){
|
||||||
ppid = getpid();
|
ppid = getpid();
|
||||||
pid = fork();
|
pid = fork();
|
||||||
if(pid < 0){
|
if(pid < 0){
|
||||||
|
|
2
vm.c
2
vm.c
|
@ -158,7 +158,7 @@ mappages(pde_t *pgdir, void *la, uint size, uint pa, int perm)
|
||||||
//
|
//
|
||||||
//
|
//
|
||||||
// setupkvm() and exec() set up every page table like this:
|
// setupkvm() and exec() set up every page table like this:
|
||||||
// 0..KERNBASE : user memory (text, data, stack, heap), mapped to some phys mem
|
// 0..USERTOP : user memory (text, data, stack, heap), mapped to some phys mem
|
||||||
// KERNBASE+640K..KERNBASE+1M: mapped to 640K..1M
|
// KERNBASE+640K..KERNBASE+1M: mapped to 640K..1M
|
||||||
// KERNBASE+1M..KERNBASE+end : mapped to 1M..end
|
// KERNBASE+1M..KERNBASE+end : mapped to 1M..end
|
||||||
// KERNBASE+end..KERBASE+PHYSTOP : mapped to end..PHYSTOP (free memory)
|
// KERNBASE+end..KERBASE+PHYSTOP : mapped to end..PHYSTOP (free memory)
|
||||||
|
|
Loading…
Reference in a new issue