debuggers.hg
changeset 16772:a26aee4a1522
minios: add trydown
Signed-off-by: Samuel Thibault <samuel.thibault@eu.citrix.com>
Signed-off-by: Samuel Thibault <samuel.thibault@eu.citrix.com>
author | Keir Fraser <keir.fraser@citrix.com> |
---|---|
date | Thu Jan 17 14:40:55 2008 +0000 (2008-01-17) |
parents | 10101bc8181f |
children | 1101ca828ad9 |
files | extras/mini-os/include/semaphore.h |
line diff
1.1 --- a/extras/mini-os/include/semaphore.h Thu Jan 17 14:40:23 2008 +0000 1.2 +++ b/extras/mini-os/include/semaphore.h Thu Jan 17 14:40:55 2008 +0000 1.3 @@ -49,6 +49,19 @@ static inline void init_SEMAPHORE(struct 1.4 1.5 #define init_MUTEX(sem) init_SEMAPHORE(sem, 1) 1.6 1.7 +static inline int trydown(struct semaphore *sem) 1.8 +{ 1.9 + unsigned long flags; 1.10 + int ret = 0; 1.11 + local_irq_save(flags); 1.12 + if (sem->count > 0) { 1.13 + ret = 1; 1.14 + sem->count--; 1.15 + } 1.16 + local_irq_restore(flags); 1.17 + return ret; 1.18 +} 1.19 + 1.20 static void inline down(struct semaphore *sem) 1.21 { 1.22 unsigned long flags;