Changes in kernel/generic/src/synch/mutex.c [a3900cc:d7da4284] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/generic/src/synch/mutex.c
ra3900cc rd7da4284 33 33 /** 34 34 * @file 35 * @brief 35 * @brief Mutexes. 36 36 */ 37 37 38 38 #include <synch/mutex.h> 39 39 #include <synch/semaphore.h> … … 44 44 /** Initialize mutex. 45 45 * 46 * @param mtx 47 * @param type 46 * @param mtx Mutex. 47 * @param type Type of the mutex. 48 48 */ 49 49 void mutex_initialize(mutex_t *mtx, mutex_type_t type) … … 53 53 } 54 54 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 55 65 /** Acquire mutex. 56 66 * 57 67 * Timeout mode and non-blocking mode can be requested. 58 68 * 59 * @param mtx 60 * @param usec 61 * @param flags 69 * @param mtx Mutex. 70 * @param usec Timeout in microseconds. 71 * @param flags Specify mode of operation. 62 72 * 63 73 * For exact description of possible combinations of 64 74 * usec and flags, see comment for waitq_sleep_timeout(). 65 75 * 66 * @return See comment for waitq_sleep_timeout(). 76 * @return See comment for waitq_sleep_timeout(). 77 * 67 78 */ 68 int _mutex_lock_timeout(mutex_t *mtx, uint32_t usec, int flags)79 int _mutex_lock_timeout(mutex_t *mtx, uint32_t usec, unsigned int flags) 69 80 { 70 81 int rc; 71 82 72 if ( mtx->type == MUTEX_PASSIVE && THREAD) {83 if ((mtx->type == MUTEX_PASSIVE) && (THREAD)) { 73 84 rc = _semaphore_down_timeout(&mtx->sem, usec, flags); 74 85 } else { 75 ASSERT( mtx->type == MUTEX_ACTIVE || !THREAD);86 ASSERT((mtx->type == MUTEX_ACTIVE) || (!THREAD)); 76 87 ASSERT(usec == SYNCH_NO_TIMEOUT); 77 88 ASSERT(!(flags & SYNCH_FLAGS_INTERRUPTIBLE)); 89 78 90 do { 79 91 rc = semaphore_trydown(&mtx->sem); … … 87 99 /** Release mutex. 88 100 * 89 * @param mtx 101 * @param mtx Mutex. 90 102 */ 91 103 void mutex_unlock(mutex_t *mtx)
Note:
See TracChangeset
for help on using the changeset viewer.