]> Devi Nivas Git - cs3210-lab1.git/commitdiff
cvs add spinlock.h
authorrtm <rtm>
Wed, 12 Jul 2006 09:10:25 +0000 (09:10 +0000)
committerrtm <rtm>
Wed, 12 Jul 2006 09:10:25 +0000 (09:10 +0000)
fix race in schedule()

Notes
proc.c
spinlock.h [new file with mode: 0644]
usertests.c

diff --git a/Notes b/Notes
index 16f65421bd168d4763bc45bebf3e76e0a0bcbdc9..b99bfe4ee54673adb9af6808f0cddb5de3bd2dc5 100644 (file)
--- a/Notes
+++ b/Notes
@@ -126,3 +126,10 @@ in general, the table locks protect both free-ness and
 why can't i get a lock in console code?
   always triple fault
 lock code shouldn't call cprintf...
+ide_init doesn't work now?
+and IOAPIC: read from unsupported address
+  when running pre-empt user test
+  so maybe something wrong with clock interrupts
+  no! if one cpu holds lock w/ curproc0=,
+    then another cpu can take it, it looks like
+    a recursive acquire()
diff --git a/proc.c b/proc.c
index 07a88d8aecff6092406cef28ddc350038121c22d..4c2586d3b5a307f0425d9d9b80312d62990048d6 100644 (file)
--- a/proc.c
+++ b/proc.c
@@ -148,7 +148,6 @@ scheduler(void)
 
     if(i < NPROC){
       np->state = RUNNING;
-      release(&proc_table_lock);
       break;
     }
     
@@ -159,6 +158,8 @@ scheduler(void)
   cpus[cpu()].lastproc = np;
   curproc[cpu()] = np;
   
+  release(&proc_table_lock);
+
   // h/w sets busy bit in TSS descriptor sometimes, and faults
   // if it's set in LTR. so clear tss descriptor busy bit.
   np->gdt[SEG_TSS].sd_type = STS_T32A;
diff --git a/spinlock.h b/spinlock.h
new file mode 100644 (file)
index 0000000..ee0a26c
--- /dev/null
@@ -0,0 +1,6 @@
+struct spinlock {
+  unsigned int locked;
+  struct proc *p;
+  int count;
+  unsigned locker_pc;
+};
index 2f688ca98d82e1894f29f8700d01cc973699a40e..fa1b2100a7f4b0ee293b01ec8ba5fbff067a81fd 100644 (file)
@@ -93,8 +93,8 @@ preempt()
 main()
 {
   puts("usertests starting\n");
-  pipe1();
-  //preempt();
+  //pipe1();
+  preempt();
 
   while(1)
     ;