patch-2.1.86 linux/include/asm-i386/semaphore.h

Next file: linux/include/asm-i386/signal.h
Previous file: linux/include/asm-i386/elf.h
Back to the patch index
Back to the overall index

diff -u --recursive --new-file v2.1.85/linux/include/asm-i386/semaphore.h linux/include/asm-i386/semaphore.h
@@ -21,6 +21,7 @@
 
 #include <asm/system.h>
 #include <asm/atomic.h>
+#include <asm/spinlock.h>
 
 struct semaphore {
 	atomic_t count;
@@ -38,6 +39,8 @@
 extern void __down(struct semaphore * sem);
 extern void __up(struct semaphore * sem);
 
+extern spinlock_t semaphore_wake_lock;
+
 #define sema_init(sem, val)	atomic_set(&((sem)->count), (val))
 
 /*
@@ -55,10 +58,9 @@
 {
 	unsigned long flags;
 
-	save_flags(flags);
-	cli();
+	spin_lock_irqsave(&semaphore_wake_lock, flags);
 	sem->waking++;
-	restore_flags(flags);
+	spin_unlock_irqrestore(&semaphore_wake_lock, flags);
 }
 
 static inline int waking_non_zero(struct semaphore *sem)
@@ -66,13 +68,12 @@
 	unsigned long flags;
 	int ret = 0;
 
-	save_flags(flags);
-	cli();
+	spin_lock_irqsave(&semaphore_wake_lock, flags);
 	if (sem->waking > 0) {
 		sem->waking--;
 		ret = 1;
 	}
-	restore_flags(flags);
+	spin_unlock_irqrestore(&semaphore_wake_lock, flags);
 	return ret;
 }
 

FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen, slshen@lbl.gov