diff options
author | Keir Fraser <keir.fraser@citrix.com> | 2008-01-17 14:40:55 +0000 |
---|---|---|
committer | Keir Fraser <keir.fraser@citrix.com> | 2008-01-17 14:40:55 +0000 |
commit | 69ca1c28b492eab7bc28491cd5f6b7c4e8fdcb34 (patch) | |
tree | 27f94276437451cc5f45328f165b10d994692344 /extras/mini-os/include/semaphore.h | |
parent | d96277204904407231c1912ac0f30964f8e3dc90 (diff) | |
download | xen-69ca1c28b492eab7bc28491cd5f6b7c4e8fdcb34.tar.gz xen-69ca1c28b492eab7bc28491cd5f6b7c4e8fdcb34.tar.bz2 xen-69ca1c28b492eab7bc28491cd5f6b7c4e8fdcb34.zip |
minios: add trydown
Signed-off-by: Samuel Thibault <samuel.thibault@eu.citrix.com>
Diffstat (limited to 'extras/mini-os/include/semaphore.h')
-rw-r--r-- | extras/mini-os/include/semaphore.h | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/extras/mini-os/include/semaphore.h b/extras/mini-os/include/semaphore.h index 261cd7e5da..19f515a1f1 100644 --- a/extras/mini-os/include/semaphore.h +++ b/extras/mini-os/include/semaphore.h @@ -49,6 +49,19 @@ static inline void init_SEMAPHORE(struct semaphore *sem, int count) #define init_MUTEX(sem) init_SEMAPHORE(sem, 1) +static inline int trydown(struct semaphore *sem) +{ + unsigned long flags; + int ret = 0; + local_irq_save(flags); + if (sem->count > 0) { + ret = 1; + sem->count--; + } + local_irq_restore(flags); + return ret; +} + static void inline down(struct semaphore *sem) { unsigned long flags; |