Changes in kernel/generic/src/synch/semaphore.c [5df7928:df4ed85] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/generic/src/synch/semaphore.c
r5df7928 rdf4ed85 33 33 /** 34 34 * @file 35 * @brief 35 * @brief Semaphores. 36 36 */ 37 37 … … 47 47 * Initialize semaphore. 48 48 * 49 * @param s emSemaphore.49 * @param s Semaphore. 50 50 * @param val Maximal number of threads allowed to enter critical section. 51 *52 51 */ 53 void semaphore_initialize(semaphore_t *s em, int val)52 void semaphore_initialize(semaphore_t *s, int val) 54 53 { 55 waitq_initialize(&sem->wq); 56 waitq_count_set(&sem->wq, val); 54 ipl_t ipl; 55 56 waitq_initialize(&s->wq); 57 58 ipl = interrupts_disable(); 59 60 spinlock_lock(&s->wq.lock); 61 s->wq.missed_wakeups = val; 62 spinlock_unlock(&s->wq.lock); 63 64 interrupts_restore(ipl); 57 65 } 58 66 … … 62 70 * Conditional mode and mode with timeout can be requested. 63 71 * 64 * @param s emSemaphore.65 * @param usec 72 * @param s Semaphore. 73 * @param usec Timeout in microseconds. 66 74 * @param flags Select mode of operation. 67 75 * … … 70 78 * 71 79 * @return See comment for waitq_sleep_timeout(). 72 *73 80 */ 74 int _semaphore_down_timeout(semaphore_t *s em, uint32_t usec, unsignedint flags)81 int _semaphore_down_timeout(semaphore_t *s, uint32_t usec, int flags) 75 82 { 76 return waitq_sleep_timeout(&s em->wq, usec, flags);83 return waitq_sleep_timeout(&s->wq, usec, flags); 77 84 } 78 85 … … 82 89 * 83 90 * @param s Semaphore. 84 *85 91 */ 86 void semaphore_up(semaphore_t *s em)92 void semaphore_up(semaphore_t *s) 87 93 { 88 waitq_wakeup(&sem->wq, WAKEUP_FIRST); 89 } 90 91 /** Get the semaphore counter value. 92 * 93 * @param sem Semaphore. 94 * @return The number of threads that can down the semaphore 95 * without blocking. 96 */ 97 int semaphore_count_get(semaphore_t *sem) 98 { 99 return waitq_count_get(&sem->wq); 94 waitq_wakeup(&s->wq, WAKEUP_FIRST); 100 95 } 101 96
Note:
See TracChangeset
for help on using the changeset viewer.