summaryrefslogtreecommitdiff
path: root/kernel
diff options
context:
space:
mode:
authorRobert Morris <[email protected]>2022-10-17 04:07:24 -0400
committerRobert Morris <[email protected]>2022-10-17 04:07:24 -0400
commit4a88273db5df00c5d3397ad5bcef50eb68f4bef8 (patch)
treec5489f8ed0627fa26f56a5cbd7c3df175b034350 /kernel
parentf376ad7f1f80bddfb754b21811d17959c45d43a4 (diff)
downloadxv6-labs-4a88273db5df00c5d3397ad5bcef50eb68f4bef8.tar.gz
xv6-labs-4a88273db5df00c5d3397ad5bcef50eb68f4bef8.tar.bz2
xv6-labs-4a88273db5df00c5d3397ad5bcef50eb68f4bef8.zip
oops. scheduler() inherits the interrupt status of the
most recent process to run, so it must explicitly turn them on again. It would be better if cpu->intena were really thread->intena.
Diffstat (limited to 'kernel')
-rw-r--r--kernel/proc.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/kernel/proc.c b/kernel/proc.c
index bc4b274..809d112 100644
--- a/kernel/proc.c
+++ b/kernel/proc.c
@@ -447,12 +447,12 @@ scheduler(void)
struct proc *p;
struct cpu *c = mycpu();
- // Interrupts are disabled at first, but they must be
- // enabled in order for the shell to get input.
- intr_on();
-
c->proc = 0;
for(;;){
+ // The most recent process to run may have had interrupts
+ // turned off; turn them on to avoid deadlock.
+ intr_on();
+
for(p = proc; p < &proc[NPROC]; p++) {
acquire(&p->lock);
if(p->state == RUNNABLE) {