aboutsummaryrefslogtreecommitdiffstats
path: root/extras/mini-os/include/semaphore.h
diff options
context:
space:
mode:
authorKeir Fraser <keir.fraser@citrix.com>2008-01-17 14:40:55 +0000
committerKeir Fraser <keir.fraser@citrix.com>2008-01-17 14:40:55 +0000
commit69ca1c28b492eab7bc28491cd5f6b7c4e8fdcb34 (patch)
tree27f94276437451cc5f45328f165b10d994692344 /extras/mini-os/include/semaphore.h
parentd96277204904407231c1912ac0f30964f8e3dc90 (diff)
downloadxen-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.h13
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;