]> Devi Nivas Git - cs3210-lab0.git/commitdiff
exec questions
authorRobert Morris <rtm@csail.mit.edu>
Sun, 19 Sep 2010 11:18:42 +0000 (07:18 -0400)
committerRobert Morris <rtm@csail.mit.edu>
Sun, 19 Sep 2010 11:18:42 +0000 (07:18 -0400)
exec.c
kalloc.c

diff --git a/exec.c b/exec.c
index 222f64c069c2a6efd6b0737efceb364635939bfd..a6de18fe20225cb7166a618e42c9f66d6dc2f0b8 100644 (file)
--- a/exec.c
+++ b/exec.c
@@ -48,6 +48,9 @@ exec(char *path, char **argv)
   }
   iunlockput(ip);
 
+  // XXX rtm: what about the BSS? shouldn't there be some
+  // bzero()ing here?
+
   // Allocate and initialize stack at sz
   sz = spbottom = PGROUNDUP(sz);
   if(!(sz = allocuvm(pgdir, sz, sz + PGSIZE)))
@@ -62,6 +65,9 @@ exec(char *path, char **argv)
   sp = sz;
   argp = sz - arglen - 4*(argc+1);
 
+  // XXX rtm: does the following code work if the
+  // arguments &c do not fit in one page?
+
   // Copy argv strings and pointers to stack.
   *(uint*)(mem+argp-spbottom + 4*argc) = 0;  // argv[argc]
   for(i=argc-1; i>=0; i--){
index 5f690f55399b3e82458d4dd5fe3d9a2ed0226e99..72ce58aa45decf49e97989e1b6b30181a60dd8b5 100644 (file)
--- a/kalloc.c
+++ b/kalloc.c
@@ -17,12 +17,12 @@ struct {
   struct run *freelist;
 } kmem;
 
+extern char end[]; // first address after kernel loaded from ELF file
+
 // Initialize free list of physical pages.
 void
 kinit(void)
 {
-  extern char end[];
-
   initlock(&kmem.lock, "kmem");
   char *p = (char*)PGROUNDUP((uint)end);
   for( ; p + PGSIZE - 1 < (char*) PHYSTOP; p += PGSIZE)
@@ -39,7 +39,7 @@ kfree(char *v)
 {
   struct run *r;
 
-  if(((uint) v) % PGSIZE || (uint)v < 1024*1024 || (uint)v >= PHYSTOP) 
+  if(((uint) v) % PGSIZE || v < end || (uint)v >= PHYSTOP) 
     panic("kfree");
 
   // Fill with junk to catch dangling refs.