summaryrefslogtreecommitdiff
path: root/spinlock.c
diff options
context:
space:
mode:
authorkaashoek <kaashoek>2006-07-06 21:47:22 +0000
committerkaashoek <kaashoek>2006-07-06 21:47:22 +0000
commit7837c71b32fc716101a859302e0349061416bd6e (patch)
tree57ec72178b980a3cd794b2f93bd021e08004368f /spinlock.c
parentb22d898297a2496ba4cfd31d445769fbebc0a46d (diff)
downloadxv6-labs-7837c71b32fc716101a859302e0349061416bd6e.tar.gz
xv6-labs-7837c71b32fc716101a859302e0349061416bd6e.tar.bz2
xv6-labs-7837c71b32fc716101a859302e0349061416bd6e.zip
disable all interrupts when acquiring lock
user program that makes a blocking system call
Diffstat (limited to 'spinlock.c')
-rw-r--r--spinlock.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/spinlock.c b/spinlock.c
index 5cbe062..2d64044 100644
--- a/spinlock.c
+++ b/spinlock.c
@@ -1,6 +1,7 @@
#include "types.h"
#include "defs.h"
#include "x86.h"
+#include "mmu.h"
#define LOCK_FREE -1
@@ -15,7 +16,7 @@ acquire_spinlock(uint32_t* lock)
if (*lock == cpu_id)
return;
- lapic_disableintr();
+ write_eflags(read_eflags() & ~FL_IF);
while ( cmpxchg(LOCK_FREE, cpu_id, lock) != cpu_id ) { ; }
// cprintf ("acquired: %d\n", cpu_id);
}
@@ -28,7 +29,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();
+ write_eflags(read_eflags() | FL_IF);
}
void