]> hydra-www.ietfng.org Git - xv6-public/commitdiff
A few small cosmetic changes
authorNathaniel Wesley Filardo <nwf@cs.jhu.edu>
Tue, 27 Oct 2015 00:42:02 +0000 (20:42 -0400)
committerPeter H. Froehlich <peter.hans.froehlich@gmail.com>
Tue, 3 Nov 2015 22:57:29 +0000 (17:57 -0500)
Comments, fixing a panic() message, and making trap.c a little more debugger
friendly (now possible to breakpoint specifically on a trap-induced exit,
rather than the syscall)

proc.h
trap.c
vm.c

diff --git a/proc.h b/proc.h
index 3b9c3ac242a71701a4a06346262599bccefb56d8..ac91b715d4ba19cf7ed1c2f1f495f7cc2de76a77 100644 (file)
--- a/proc.h
+++ b/proc.h
@@ -27,6 +27,14 @@ extern int ncpu;
 // holding those two variables in the local cpu's struct cpu.
 // This is similar to how thread-local variables are implemented
 // in thread libraries such as Linux pthreads.
+//
+// One must be very careful with cpu as we might migrate; that is, in
+// general, it is only safe to access this variable and *do* anything with
+// it while local preemption is disabled.
+//
+// proc is *observably constant* from a particular proc's perspective, on
+// the other hand (the scheduler always restores its value) and so is in
+// general safe to access without holding any locks.
 extern struct cpu *cpu asm("%gs:0");       // &cpus[cpunum()]
 extern struct proc *proc asm("%gs:4");     // cpus[cpunum()].proc
 
diff --git a/trap.c b/trap.c
index 6118f816e2448895b8a710dc65de5c88e59bae80..043c9e4f54aaf3ef63af3421b55fc7067b4160b5 100644 (file)
--- a/trap.c
+++ b/trap.c
@@ -32,6 +32,13 @@ idtinit(void)
 }
 
 //PAGEBREAK: 41
+// This is here so you can break on it in gdb
+static void
+trap_exit()
+{
+  sti();
+  exit();
+}
 void
 trap(struct trapframe *tf)
 {
@@ -97,7 +104,7 @@ trap(struct trapframe *tf)
   // (If it is still executing in the kernel, let it keep running
   // until it gets to the regular system call return.)
   if(proc && proc->killed && (tf->cs&3) == DPL_USER)
-    exit();
+    trap_exit();
 
   // Force process to give up CPU on clock tick.
   // If interrupts were on while locks held, would need to check nlock.
@@ -106,5 +113,5 @@ trap(struct trapframe *tf)
 
   // Check if the process has been killed since we yielded
   if(proc && proc->killed && (tf->cs&3) == DPL_USER)
-    exit();
+    trap_exit();
 }
diff --git a/vm.c b/vm.c
index b340696b44ccc1cb8ffcae93a98ac2dd6f1f67fb..a58ef214a6b1dd9169b557f49c9834eb32305114 100644 (file)
--- a/vm.c
+++ b/vm.c
@@ -267,7 +267,7 @@ deallocuvm(pde_t *pgdir, uint oldsz, uint newsz)
     else if((*pte & PTE_P) != 0){
       pa = PTE_ADDR(*pte);
       if(pa == 0)
-        panic("kfree");
+        panic("deallocuvm");
       char *v = P2V(pa);
       kfree(v);
       *pte = 0;