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