summaryrefslogtreecommitdiff
path: root/proc.c
diff options
context:
space:
mode:
authorrtm <rtm>2006-07-12 11:15:38 +0000
committerrtm <rtm>2006-07-12 11:15:38 +0000
commit8148b6ee535b85e97f3b5f3a850b70fdfbbcaf2d (patch)
treeea279d5ca141449bb8f363594c57d7e8fc142db0 /proc.c
parent664324745e2257289f7a61e43892ce6e8b8ed9b7 (diff)
downloadxv6-labs-8148b6ee535b85e97f3b5f3a850b70fdfbbcaf2d.tar.gz
xv6-labs-8148b6ee535b85e97f3b5f3a850b70fdfbbcaf2d.tar.bz2
xv6-labs-8148b6ee535b85e97f3b5f3a850b70fdfbbcaf2d.zip
i think my cmpxchg use was wrong in acquire
nesting cli/sti: release shouldn't always enable interrupts separate setup of lapic from starting of other cpus, so cpu() works earlier flag to disable locking in console output make locks work even when curproc==0 (still crashes in clock interrupt)
Diffstat (limited to 'proc.c')
-rw-r--r--proc.c25
1 files changed, 23 insertions, 2 deletions
diff --git a/proc.c b/proc.c
index 4c2586d..53469a1 100644
--- a/proc.c
+++ b/proc.c
@@ -148,6 +148,7 @@ scheduler(void)
if(i < NPROC){
np->state = RUNNING;
+ release(&proc_table_lock);
break;
}
@@ -157,8 +158,6 @@ 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.
@@ -252,3 +251,25 @@ proc_exit()
// switch into scheduler
swtch(ZOMBIE);
}
+
+// disable interrupts
+void
+cli(void)
+{
+ cpus[cpu()].clis += 1;
+ if(cpus[cpu()].clis == 1)
+ __asm __volatile("cli");
+}
+
+// enable interrupts
+void
+sti(void)
+{
+ if(cpus[cpu()].clis < 1){
+ cprintf("cpu %d clis %d\n", cpu(), cpus[cpu()].clis);
+ panic("sti");
+ }
+ cpus[cpu()].clis -= 1;
+ if(cpus[cpu()].clis < 1)
+ __asm __volatile("sti");
+}