Ignore:
File:
1 edited

Legend:

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

    rd7da4284 r08a19ba  
    3333/**
    3434 * @file
    35  * @brief Mutexes.
     35 * @brief       Mutexes.
    3636 */
    37 
     37 
    3838#include <synch/mutex.h>
    3939#include <synch/semaphore.h>
    4040#include <synch/synch.h>
    4141#include <debug.h>
    42 #include <arch.h>
    4342
    4443/** Initialize mutex.
    4544 *
    46  * @param mtx  Mutex.
    47  * @param type Type of the mutex.
     45 * @param mtx           Mutex.
     46 * @param type          Type of the mutex.
    4847 */
    4948void mutex_initialize(mutex_t *mtx, mutex_type_t type)
     
    5352}
    5453
    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 
    6554/** Acquire mutex.
    6655 *
    6756 * Timeout mode and non-blocking mode can be requested.
    6857 *
    69  * @param mtx   Mutex.
    70  * @param usec  Timeout in microseconds.
    71  * @param flags Specify mode of operation.
     58 * @param mtx           Mutex.
     59 * @param usec          Timeout in microseconds.
     60 * @param flags         Specify mode of operation.
    7261 *
    7362 * For exact description of possible combinations of
    7463 * usec and flags, see comment for waitq_sleep_timeout().
    7564 *
    76  * @return See comment for waitq_sleep_timeout().
    77  *
     65 * @return              See comment for waitq_sleep_timeout().
    7866 */
    79 int _mutex_lock_timeout(mutex_t *mtx, uint32_t usec, unsigned int flags)
     67int _mutex_lock_timeout(mutex_t *mtx, uint32_t usec, int flags)
    8068{
    8169        int rc;
    8270
    83         if ((mtx->type == MUTEX_PASSIVE) && (THREAD)) {
     71        if (mtx->type == MUTEX_PASSIVE) {
    8472                rc = _semaphore_down_timeout(&mtx->sem, usec, flags);
    8573        } else {
    86                 ASSERT((mtx->type == MUTEX_ACTIVE) || (!THREAD));
     74                ASSERT(mtx->type == MUTEX_ACTIVE);
    8775                ASSERT(usec == SYNCH_NO_TIMEOUT);
    8876                ASSERT(!(flags & SYNCH_FLAGS_INTERRUPTIBLE));
    89                
    9077                do {
    9178                        rc = semaphore_trydown(&mtx->sem);
     
    9986/** Release mutex.
    10087 *
    101  * @param mtx Mutex.
     88 * @param mtx           Mutex.
    10289 */
    10390void mutex_unlock(mutex_t *mtx)
Note: See TracChangeset for help on using the changeset viewer.