]> Devi Nivas Git - cs3210-lab1.git/commitdiff
comment about sched() saving/restoring cpu->intena
authorRobert Morris <rtm@csail.mit.edu>
Fri, 2 Sep 2016 09:40:54 +0000 (05:40 -0400)
committerRobert Morris <rtm@csail.mit.edu>
Fri, 2 Sep 2016 09:40:54 +0000 (05:40 -0400)
proc.c
spinlock.c

diff --git a/proc.c b/proc.c
index 751d886926185af383b6d521f258de216e84c28a..9e9552936c5698bcd185b02a1580ccfaaab0905d 100644 (file)
--- a/proc.c
+++ b/proc.c
@@ -302,7 +302,12 @@ scheduler(void)
 }
 
 // Enter scheduler.  Must hold only ptable.lock
-// and have changed proc->state.
+// and have changed proc->state. Saves and restores
+// intena because intena is a property of this
+// kernel thread, not this CPU. It should
+// be proc->intena and proc->ncli, but that would
+// break in the few places where a lock is held but
+// there's no process.
 void
 sched(void)
 {
index a5f0b2118b62afd626d8690186fbea7130e25a37..bf863ef104c3399c18ce628b7bae092df429b492 100644 (file)
@@ -102,8 +102,9 @@ pushcli(void)
 
   eflags = readeflags();
   cli();
-  if(cpu->ncli++ == 0)
+  if(cpu->ncli == 0)
     cpu->intena = eflags & FL_IF;
+  cpu->ncli += 1;
 }
 
 void