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