]> Devi Nivas Git - cs3210-lab0.git/commitdiff
some comment changes
authorkaashoek <kaashoek>
Fri, 8 Sep 2006 14:36:44 +0000 (14:36 +0000)
committerkaashoek <kaashoek>
Fri, 8 Sep 2006 14:36:44 +0000 (14:36 +0000)
bootasm.S
buf.h
fs.c
init.c
kalloc.c
main.c
spinlock.c

index 9f03c4dc7a03907c9611ac21cf9603fb6c31a9d4..aa462b98a0ccf376a5ad6fef5385f474f0552ee9 100644 (file)
--- a/bootasm.S
+++ b/bootasm.S
@@ -5,7 +5,7 @@
 .set CR0_PE_ON,0x1              # protected mode enable flag
 
 #########################################################################
-# ENTRY POINT
+# ENTRY POINT for the bootstrap processor
 #   This code should be stored in the first sector of the hard disk.
 #   After the BIOS initializes the hardware on startup or system reset,
 #   it loads this code at physical address 0x7c00 - 0x7d00 (512 bytes).
diff --git a/buf.h b/buf.h
index a2a3ec121c5ccceb1b6f3147466202a31da751ef..ccf7f8bc3bbe148f5786fa61ebf34b1f3c50e657 100644 (file)
--- a/buf.h
+++ b/buf.h
@@ -6,5 +6,5 @@ struct buf {
   struct buf *next;
   uchar data[512];
 };
-#define B_BUSY 0x1
-#define B_VALID 0x2
+#define B_BUSY 0x1  // buffer is locked by some process
+#define B_VALID 0x2 // buffer contains the data of the sector
diff --git a/fs.c b/fs.c
index 3ba08582d0bf399b6d16af199d125860415143b7..3f0a71df99433cb53f954239bc071646aa3c0c03 100644 (file)
--- a/fs.c
+++ b/fs.c
@@ -160,7 +160,7 @@ iget(uint dev, uint inum)
   return nip;
 }
 
-// Copy ip->d, which has changed, to disk.
+// Copy inode in memory, which has changed, to disk.
 // Caller must have locked ip.
 void
 iupdate(struct inode *ip)
diff --git a/init.c b/init.c
index ff6feafb8523b4540e060720c494b06a00892e3a..909ee8034b43ab3aa07097542a89d85d563c2e34 100644 (file)
--- a/init.c
+++ b/init.c
@@ -17,8 +17,8 @@ main(void)
     mknod("console", T_DEV, 1, 1);
     open("console", O_RDWR);
   }
-  dup(0);
-  dup(0);
+  dup(0);  // stdout
+  dup(0);  // stderr
 
   for(;;){
     pid = fork();
index 7d3ca0c5a6e514f9a4f1b4d3731e4e2fedf111e7..bfa920773270020a9db5f7c593c15765a832a8e9 100644 (file)
--- a/kalloc.c
+++ b/kalloc.c
@@ -35,7 +35,7 @@ kinit(void)
   initlock(&kalloc_lock, "kalloc");
   start = (char*) &end;
   start = (char*) (((uint)start + PAGE) & ~(PAGE-1));
-  mem = 256; // assume 256 pages of RAM
+  mem = 256; // assume computer has 256 pages of RAM
   cprintf("mem = %d\n", mem * PAGE);
   kfree(start, mem * PAGE);
 }
diff --git a/main.c b/main.c
index c18fc0820ac3a420f83ce3f2503d9589e68b1234..cd893d5ba1cdd142ff48fb1894c535f268bb4ca6 100644 (file)
--- a/main.c
+++ b/main.c
@@ -15,7 +15,7 @@ extern uchar _binary__init_start[], _binary__init_size[];
 
 void process0();
 
-// CPU 0 starts running C code here.
+// Bootstrap processor starts running C code here.
 // This is called main0 not main so that it can have
 // a void return type.  Gcc can't handle functions named
 // main that don't return int.  Really.
@@ -28,7 +28,7 @@ main0(void)
   // clear BSS
   memset(edata, 0, end - edata);
 
-  // switch to cpu0's cpu stack
+  // switch to bootstrap processor's stack
   asm volatile("movl %0, %%esp" : : "r" (cpus[0].mpstack + MPSTACK - 32));
   asm volatile("movl %0, %%ebp" : : "r" (cpus[0].mpstack + MPSTACK));
 
index 2e604b76fad2c56ec8d666f04388e3d6fa0d83ed..f81463223d5d338902c8a3dcad88b122f391db06 100644 (file)
@@ -51,10 +51,9 @@ acquire(struct spinlock *lock)
   while(cmpxchg(0, 1, &lock->locked) == 1)
     ;
 
-  // Now that lock is acquired, make sure 
-  // we wait for all pending writes from other
-  // processors.
-  cpuid(0, 0, 0, 0, 0);  // memory barrier
+  // Serialize instructions: now that lock is acquired, make sure 
+  // we wait for all pending writes from other processors.
+  cpuid(0, 0, 0, 0, 0);  // memory barrier (see Ch 7 of IA-32 manual, vol 3)
   
   // Record info about lock acquisition for debugging.
   // The +10 is only so that we can tell the difference
@@ -74,9 +73,9 @@ release(struct spinlock *lock)
   lock->pcs[0] = 0;
   lock->cpu = 0xffffffff;
   
-  // Before unlocking the lock, make sure to flush
-  // any pending memory writes from this processor.
-  cpuid(0, 0, 0, 0, 0);  // memory barrier
+  // Serialize instructions: before unlocking the lock, make sure
+  // to flush any pending memory writes from this processor.
+  cpuid(0, 0, 0, 0, 0);  // memory barrier (see Ch 7 of IA-32 manual, vol 3)
 
   lock->locked = 0;
   if(--cpus[cpu()].nlock == 0)