Skip to content

Commit

Permalink
cvs add spinlock.h
Browse files Browse the repository at this point in the history
fix race in schedule()
  • Loading branch information
rtm committed Jul 12, 2006
1 parent 4e8f237 commit 6643247
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 3 deletions.
7 changes: 7 additions & 0 deletions Notes
Original file line number Diff line number Diff line change
Expand Up @@ -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()
3 changes: 2 additions & 1 deletion proc.c
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,6 @@ scheduler(void)

if(i < NPROC){
np->state = RUNNING;
release(&proc_table_lock);
break;
}

Expand All @@ -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;
Expand Down
6 changes: 6 additions & 0 deletions spinlock.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
struct spinlock {
unsigned int locked;
struct proc *p;
int count;
unsigned locker_pc;
};
4 changes: 2 additions & 2 deletions usertests.c
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,8 @@ preempt()
main()
{
puts("usertests starting\n");
pipe1();
//preempt();
//pipe1();
preempt();

while(1)
;
Expand Down

0 comments on commit 6643247

Please sign in to comment.