]> Devi Nivas Git - cs3210-lab1.git/commitdiff
Adjust sbrk test for large user address spaces
authorFrans Kaashoek <kaashoek@14.sub-75-194-120.myvzw.com>
Mon, 8 Aug 2011 03:03:48 +0000 (23:03 -0400)
committerFrans Kaashoek <kaashoek@14.sub-75-194-120.myvzw.com>
Mon, 8 Aug 2011 03:03:48 +0000 (23:03 -0400)
All tests pass

usertests.c
vm.c

index 296731ae48f43f6f2eafb19f60cc6ff33d3435bf..0d5d4dc6c515014c3fec8dd0acdd2adf6df17ad1 100644 (file)
@@ -5,6 +5,7 @@
 #include "fcntl.h"
 #include "syscall.h"
 #include "traps.h"
+#include "memlayout.h"
 
 char buf[2048];
 char name[3];
@@ -1247,7 +1248,7 @@ sbrktest(void)
   // can one sbrk() less than a page?
   a = sbrk(0);
   int i;
-  for(i = 0; i < 5000; i++){
+  for(i = 0; i < 5000; i++){ 
     b = sbrk(1);
     if(b != a){
       printf(stdout, "sbrk test failed %d %x %x\n", i, a, b);
@@ -1271,24 +1272,18 @@ sbrktest(void)
     exit();
   wait();
 
-  // can one allocate the full 640K?
+  // can one grow address space to something big?
+#define BIG (100*1024*1024)
   a = sbrk(0);
-  amt = (640 * 1024) - (uint)a;
+  amt = (BIG) - (uint)a;
   p = sbrk(amt);
-  if(p != a){
-    printf(stdout, "sbrk test failed 640K test, p %x a %x\n", p, a);
+  if (p != a) { 
+    printf(stdout, "sbrk test failed to grow big address space; enough phys mem?\n");
     exit();
   }
-  lastaddr = (char*)(640 * 1024 - 1);
+  lastaddr = (char*) (BIG-1);
   *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?
   a = sbrk(0);
   c = sbrk(-4096);
@@ -1315,14 +1310,8 @@ sbrktest(void)
     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?
-  for(a = (char*)(640*1024); a < (char*)2000000; a += 50000){
+  for(a = (char*)(KERNBASE); a < (char*) (KERNBASE+2000000); a += 50000){
     ppid = getpid();
     pid = fork();
     if(pid < 0){
diff --git a/vm.c b/vm.c
index c38893146fc470027372c8876cc4e5ca5546f085..2ca2a9845524d7db488063ddfda17ac2a78ca815 100644 (file)
--- a/vm.c
+++ b/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:
-//   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+1M..KERNBASE+end : mapped to 1M..end
 //   KERNBASE+end..KERBASE+PHYSTOP     : mapped to end..PHYSTOP (free memory)