Skip to content
Snippets Groups Projects
Commit f7cea12b authored by kaashoek's avatar kaashoek
Browse files

disable interrupts when holding kernel lock

parent bd303ed0
No related branches found
No related tags found
No related merge requests found
......@@ -41,6 +41,7 @@ void lapic_init(int);
void lapic_timerinit(void);
void lapic_timerintr(void);
void lapic_enableintr(void);
void lapic_disableintr(void);
// spinlock.c
extern uint32_t kernel_lock;
......
......@@ -183,6 +183,12 @@ lapic_enableintr(void)
lapic_write(LAPIC_TPR, 0);
}
void
lapic_disableintr(void)
{
lapic_write(LAPIC_TPR, 0xFF);
}
int
cpu(void)
{
......
......@@ -14,6 +14,8 @@ acquire_spinlock(uint32_t* lock)
if (*lock == cpu_id)
return;
lapic_disableintr();
while ( cmpxchg(LOCK_FREE, cpu_id, lock) != cpu_id ) { ; }
// cprintf ("acquired: %d\n", cpu_id);
}
......@@ -26,6 +28,7 @@ release_spinlock(uint32_t* lock)
if (*lock != cpu_id)
panic("release_spinlock: releasing a lock that i don't own\n");
*lock = LOCK_FREE;
lapic_enableintr();
}
void
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment