From 664324745e2257289f7a61e43892ce6e8b8ed9b7 Mon Sep 17 00:00:00 2001 From: rtm Date: Wed, 12 Jul 2006 09:10:25 +0000 Subject: [PATCH] cvs add spinlock.h fix race in schedule() --- Notes | 7 +++++++ proc.c | 3 ++- spinlock.h | 6 ++++++ usertests.c | 4 ++-- 4 files changed, 17 insertions(+), 3 deletions(-) create mode 100644 spinlock.h diff --git a/Notes b/Notes index 16f6542..b99bfe4 100644 --- a/Notes +++ b/Notes @@ -126,3 +126,10 @@ in general, the table locks protect both free-ness and why can't i get a lock in console code? always triple fault lock code shouldn't call cprintf... +ide_init doesn't work now? +and IOAPIC: read from unsupported address + when running pre-empt user test + so maybe something wrong with clock interrupts + no! if one cpu holds lock w/ curproc0=, + then another cpu can take it, it looks like + a recursive acquire() diff --git a/proc.c b/proc.c index 07a88d8..4c2586d 100644 --- a/proc.c +++ b/proc.c @@ -148,7 +148,6 @@ scheduler(void) if(i < NPROC){ np->state = RUNNING; - release(&proc_table_lock); break; } @@ -159,6 +158,8 @@ 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. np->gdt[SEG_TSS].sd_type = STS_T32A; diff --git a/spinlock.h b/spinlock.h new file mode 100644 index 0000000..ee0a26c --- /dev/null +++ b/spinlock.h @@ -0,0 +1,6 @@ +struct spinlock { + unsigned int locked; + struct proc *p; + int count; + unsigned locker_pc; +}; diff --git a/usertests.c b/usertests.c index 2f688ca..fa1b210 100644 --- a/usertests.c +++ b/usertests.c @@ -93,8 +93,8 @@ preempt() main() { puts("usertests starting\n"); - pipe1(); - //preempt(); + //pipe1(); + preempt(); while(1) ;