summaryrefslogtreecommitdiff
path: root/proc.c
diff options
context:
space:
mode:
authorrsc <rsc>2007-09-27 21:25:37 +0000
committerrsc <rsc>2007-09-27 21:25:37 +0000
commitab08960f6402f5c7cbb7b6e81694a60b6abed4c8 (patch)
tree156a197126bdfb99bb5081b7fe78ee3e8528aa5b /proc.c
parentf97f0d2b3d3afbad3ef154b047f1b0408fd7288b (diff)
downloadxv6-labs-ab08960f6402f5c7cbb7b6e81694a60b6abed4c8.tar.gz
xv6-labs-ab08960f6402f5c7cbb7b6e81694a60b6abed4c8.tar.bz2
xv6-labs-ab08960f6402f5c7cbb7b6e81694a60b6abed4c8.zip
Final word on the locking fiasco?
Change pushcli / popcli so that they can never turn on interrupts unexpectedly. That is, if interrupts are on, then pushcli(); popcli(); turns them off and back on, but if they are off to begin with, then pushcli(); popcli(); is a no-op. I think our fundamental mistake was having a primitive (release and then popcli nee spllo) that could turn interrupts on at unexpected moments instead of being explicit about when we want to start allowing interrupts. With the new semantics, all the manual fiddling of ncli to force interrupts off in certain sections goes away. In return, we must explicitly mark the places where we want to enable interrupts unconditionally, by calling sti(). There is only one: inside the scheduler loop.
Diffstat (limited to 'proc.c')
-rw-r--r--proc.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/proc.c b/proc.c
index b009892..808a15e 100644
--- a/proc.c
+++ b/proc.c
@@ -179,7 +179,6 @@ userinit(void)
}
// Return currently running process.
-// XXX comment better
struct proc*
curproc(void)
{
@@ -206,11 +205,13 @@ scheduler(void)
struct cpu *c;
int i;
+ c = &cpus[cpu()];
for(;;){
+ // Enable interrupts on this processor.
+ sti();
+
// Loop over process table looking for process to run.
acquire(&proc_table_lock);
-
- c = &cpus[cpu()];
for(i = 0; i < NPROC; i++){
p = &proc[i];
if(p->state != RUNNABLE)
@@ -229,8 +230,8 @@ scheduler(void)
c->curproc = 0;
setupsegs(0);
}
-
release(&proc_table_lock);
+
}
}