Skip to contentSkip to conversation

Add init_SEMAPHORE

PATCH New Samuel Thibault 1 participant 1 message Nov 23, 2007

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Add init_SEMAPHORE

Add init_SEMAPHORE() to dynamically initialize semaphores.

extras/mini-os/include/semaphore.h +4 -2
diff -r f2711b7eae95 -r 36bf1e737b87 extras/mini-os/include/semaphore.h
@@ -41,11 +41,13 @@
 
 #define DECLARE_MUTEX_LOCKED(name) __DECLARE_SEMAPHORE_GENERIC(name,0)
 
-static inline void init_MUTEX(struct semaphore *sem)
+static inline void init_SEMAPHORE(struct semaphore *sem, int count)
 {
-  sem->count = 1;
+  sem->count = count;
   init_waitqueue_head(&sem->wait);
 }
 
+#define init_MUTEX(sem) init_SEMAPHORE(sem, 1)
+
 static void inline down(struct semaphore *sem)
 {