From 4b2152cc2d46865f3e4be011698b7a49bca794b8 Mon Sep 17 00:00:00 2001 From: Robert Morris Date: Thu, 1 Sep 2016 17:21:37 -0400 Subject: [PATCH 1/2] curproc -> proc in a comment --- vm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vm.c b/vm.c index c8b8d35..d9aaa7e 100644 --- a/vm.c +++ b/vm.c @@ -27,7 +27,7 @@ seginit(void) c->gdt[SEG_UCODE] = SEG(STA_X|STA_R, 0, 0xffffffff, DPL_USER); c->gdt[SEG_UDATA] = SEG(STA_W, 0, 0xffffffff, DPL_USER); - // Map cpu and curproc -- these are private per cpu. + // Map cpu and proc -- these are private per cpu. c->gdt[SEG_KCPU] = SEG(STA_W, &c->cpu, 8, 0); lgdt(c->gdt, sizeof(c->gdt)); From bc8221a59c083811ee2d8c49c0342ea59caa6d51 Mon Sep 17 00:00:00 2001 From: Robert Morris Date: Fri, 2 Sep 2016 05:40:54 -0400 Subject: [PATCH 2/2] comment about sched() saving/restoring cpu->intena --- proc.c | 7 ++++++- spinlock.c | 3 ++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/proc.c b/proc.c index 751d886..9e95529 100644 --- 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) { diff --git a/spinlock.c b/spinlock.c index a5f0b21..bf863ef 100644 --- a/spinlock.c +++ b/spinlock.c @@ -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