Fork us on GitHub Follow us on Facebook Follow us on Twitter

Changeset 5df7928 in mainline


Ignore:
Timestamp:
2010-05-25T21:33:52Z (11 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master
Children:
d7da4284
Parents:
b7398c0
Message:

Add interface for determining the semaphore count.

Location:
kernel/generic
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • kernel/generic/include/synch/semaphore.h

    rb7398c0 r5df7928  
    5656extern int _semaphore_down_timeout(semaphore_t *, uint32_t, unsigned int);
    5757extern void semaphore_up(semaphore_t *);
     58extern int semaphore_count_get(semaphore_t *);
    5859
    5960#endif
  • kernel/generic/src/synch/semaphore.c

    rb7398c0 r5df7928  
    5454{
    5555        waitq_initialize(&sem->wq);
    56        
    57         irq_spinlock_lock(&sem->wq.lock, true);
    58         sem->wq.missed_wakeups = val;
    59         irq_spinlock_unlock(&sem->wq.lock, true);
     56        waitq_count_set(&sem->wq, val);
    6057}
    6158
     
    9289}
    9390
     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 */
     97int semaphore_count_get(semaphore_t *sem)
     98{
     99        return waitq_count_get(&sem->wq);
     100}
     101
    94102/** @}
    95103 */
Note: See TracChangeset for help on using the changeset viewer.