1 #ifndef _I386_SEMAPHORE_H 2 #define _I386_SEMAPHORE_H 4 #include <linux/linkage.h> 7 * SMP- and interrupt-safe semaphores.. 9 * (C) Copyright 1996 Linus Torvalds 11 * Modified 1996-12-23 by Dave Grothe <dave@gcom.com> to fix bugs in 12 * the original code and to make semaphore waits 13 * interruptible so that processes waiting on 14 * semaphores can be killed. 16 * If you would like to see an analysis of this implementation, please 17 * ftp to gcom.com and download the file 18 * /pub/linux/src/semaphore/semaphore-2.0.24.tar.gz. 25 struct wait_queue
* wait
; 28 #define MUTEX ((struct semaphore) { 1, 0, NULL }) 29 #define MUTEX_LOCKED ((struct semaphore) { 0, 0, NULL }) 31 asmlinkage
void__down_failed(void/* special register calling convention */); 32 asmlinkage
int__down_failed_interruptible(void/* params in registers */); 33 asmlinkage
void__up_wakeup(void/* special register calling convention */); 35 externvoid__down(struct semaphore
* sem
); 36 externvoid__up(struct semaphore
* sem
); 39 * This is ugly, but we want the default case to fall through. 40 * "down_failed" is a special asm handler that calls the C 41 * routine that actually waits. See arch/i386/lib/semaphore.S 43 extern inlinevoiddown(struct semaphore
* sem
) 46 "# atomic down operation\n\t" 52 "js "SYMBOL_NAME_STR(__down_failed
) 60 * This version waits in interruptible state so that the waiting 61 * process can be killed. The down_failed_interruptible routine 62 * returns negative for signalled and zero for semaphore acquired. 64 extern inlineintdown_interruptible(struct semaphore
* sem
) 69 "# atomic interruptible down operation\n\t" 75 "js "SYMBOL_NAME_STR(__down_failed_interruptible
)"\n\t" 86 * Note! This is subtle. We jump to wake people up only if 87 * the semaphore was negative (== somebody was waiting on it). 88 * The default case (no contention) will result in NO 89 * jumps for both down() and up(). 91 extern inlinevoidup(struct semaphore
* sem
) 94 "# atomic up operation\n\t" 100 "jle "SYMBOL_NAME_STR(__up_wakeup
)