cvs add spinlock.h

fix race in schedule()
This commit is contained in:
rtm 2006-07-12 09:10:25 +00:00
parent 4e8f237be8
commit 664324745e
4 changed files with 17 additions and 3 deletions

7
Notes
View file

@ -126,3 +126,10 @@ in general, the table locks protect both free-ness and
why can't i get a lock in console code? why can't i get a lock in console code?
always triple fault always triple fault
lock code shouldn't call cprintf... 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()

3
proc.c
View file

@ -148,7 +148,6 @@ scheduler(void)
if(i < NPROC){ if(i < NPROC){
np->state = RUNNING; np->state = RUNNING;
release(&proc_table_lock);
break; break;
} }
@ -159,6 +158,8 @@ scheduler(void)
cpus[cpu()].lastproc = np; cpus[cpu()].lastproc = np;
curproc[cpu()] = np; curproc[cpu()] = np;
release(&proc_table_lock);
// h/w sets busy bit in TSS descriptor sometimes, and faults // h/w sets busy bit in TSS descriptor sometimes, and faults
// if it's set in LTR. so clear tss descriptor busy bit. // if it's set in LTR. so clear tss descriptor busy bit.
np->gdt[SEG_TSS].sd_type = STS_T32A; np->gdt[SEG_TSS].sd_type = STS_T32A;

6
spinlock.h Normal file
View file

@ -0,0 +1,6 @@
struct spinlock {
unsigned int locked;
struct proc *p;
int count;
unsigned locker_pc;
};

View file

@ -93,8 +93,8 @@ preempt()
main() main()
{ {
puts("usertests starting\n"); puts("usertests starting\n");
pipe1(); //pipe1();
//preempt(); preempt();
while(1) while(1)
; ;