xv6

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README | LICENSE

commit f7cea12b38a86e9b37fa5bc635310d3f85e5f8db
parent bd303ed06096395778c80558e013b64bb47b9e9c
Author: kaashoek <kaashoek>
Date:   Wed, 28 Jun 2006 16:44:41 +0000

disable interrupts when holding kernel lock

Diffstat:
Mdefs.h | 1+
Mmp.c | 6++++++
Mspinlock.c | 3+++
3 files changed, 10 insertions(+), 0 deletions(-)

diff --git a/defs.h b/defs.h @@ -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; diff --git a/mp.c b/mp.c @@ -183,6 +183,12 @@ lapic_enableintr(void) lapic_write(LAPIC_TPR, 0); } +void +lapic_disableintr(void) +{ + lapic_write(LAPIC_TPR, 0xFF); +} + int cpu(void) { diff --git a/spinlock.c b/spinlock.c @@ -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