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