Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • kernel/generic/src/synch/mutex.c

    rd7da4284 ra3900cc  
    3333/**
    3434 * @file
    35  * @brief Mutexes.
     35 * @brief       Mutexes.
    3636 */
    37 
     37 
    3838#include <synch/mutex.h>
    3939#include <synch/semaphore.h>
     
    4444/** Initialize mutex.
    4545 *
    46  * @param mtx  Mutex.
    47  * @param type Type of the mutex.
     46 * @param mtx           Mutex.
     47 * @param type          Type of the mutex.
    4848 */
    4949void mutex_initialize(mutex_t *mtx, mutex_type_t type)
     
    5353}
    5454
    55 /** Find out whether the mutex is currently locked.
    56  *
    57  * @param mtx           Mutex.
    58  * @return              True if the mutex is locked, false otherwise.
    59  */
    60 bool mutex_locked(mutex_t *mtx)
    61 {
    62         return semaphore_count_get(&mtx->sem) <= 0;
    63 }
    64 
    6555/** Acquire mutex.
    6656 *
    6757 * Timeout mode and non-blocking mode can be requested.
    6858 *
    69  * @param mtx   Mutex.
    70  * @param usec  Timeout in microseconds.
    71  * @param flags Specify mode of operation.
     59 * @param mtx           Mutex.
     60 * @param usec          Timeout in microseconds.
     61 * @param flags         Specify mode of operation.
    7262 *
    7363 * For exact description of possible combinations of
    7464 * usec and flags, see comment for waitq_sleep_timeout().
    7565 *
    76  * @return See comment for waitq_sleep_timeout().
    77  *
     66 * @return              See comment for waitq_sleep_timeout().
    7867 */
    79 int _mutex_lock_timeout(mutex_t *mtx, uint32_t usec, unsigned int flags)
     68int _mutex_lock_timeout(mutex_t *mtx, uint32_t usec, int flags)
    8069{
    8170        int rc;
    8271
    83         if ((mtx->type == MUTEX_PASSIVE) && (THREAD)) {
     72        if (mtx->type == MUTEX_PASSIVE && THREAD) {
    8473                rc = _semaphore_down_timeout(&mtx->sem, usec, flags);
    8574        } else {
    86                 ASSERT((mtx->type == MUTEX_ACTIVE) || (!THREAD));
     75                ASSERT(mtx->type == MUTEX_ACTIVE || !THREAD);
    8776                ASSERT(usec == SYNCH_NO_TIMEOUT);
    8877                ASSERT(!(flags & SYNCH_FLAGS_INTERRUPTIBLE));
    89                
    9078                do {
    9179                        rc = semaphore_trydown(&mtx->sem);
     
    9987/** Release mutex.
    10088 *
    101  * @param mtx Mutex.
     89 * @param mtx           Mutex.
    10290 */
    10391void mutex_unlock(mutex_t *mtx)
Note: See TracChangeset for help on using the changeset viewer.