Changeset 08a19ba in mainline
- Timestamp:
- 2008-06-23T18:44:48Z (16 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 1a1744e
- Parents:
- deaf8d5
- Location:
- kernel
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/genarch/src/mm/as_ht.c
rdeaf8d5 r08a19ba 73 73 if (flags & FLAG_AS_KERNEL) { 74 74 hash_table_create(&page_ht, PAGE_HT_ENTRIES, 2, &ht_operations); 75 mutex_initialize(&page_ht_lock );75 mutex_initialize(&page_ht_lock, MUTEX_PASSIVE); 76 76 } 77 77 return NULL; -
kernel/generic/include/synch/mutex.h
rdeaf8d5 r08a19ba 40 40 #include <synch/synch.h> 41 41 42 typedef enum { 43 MUTEX_PASSIVE, 44 MUTEX_ACTIVE 45 } mutex_type_t; 46 42 47 typedef struct { 48 mutex_type_t type; 43 49 semaphore_t sem; 44 50 } mutex_t; 45 51 46 #define mutex_lock(mtx) 52 #define mutex_lock(mtx) \ 47 53 _mutex_lock_timeout((mtx), SYNCH_NO_TIMEOUT, SYNCH_FLAGS_NONE) 48 #define mutex_trylock(mtx) 54 #define mutex_trylock(mtx) \ 49 55 _mutex_lock_timeout((mtx), SYNCH_NO_TIMEOUT, SYNCH_FLAGS_NON_BLOCKING) 50 #define mutex_lock_timeout(mtx, usec) 56 #define mutex_lock_timeout(mtx, usec) \ 51 57 _mutex_lock_timeout((mtx), (usec), SYNCH_FLAGS_NON_BLOCKING) 52 58 53 extern void mutex_initialize(mutex_t * mtx);54 extern int _mutex_lock_timeout(mutex_t * mtx, uint32_t usec, int flags);55 extern void mutex_unlock(mutex_t * mtx);59 extern void mutex_initialize(mutex_t *, mutex_type_t); 60 extern int _mutex_lock_timeout(mutex_t *, uint32_t, int); 61 extern void mutex_unlock(mutex_t *); 56 62 57 63 #endif -
kernel/generic/src/ipc/ipc.c
rdeaf8d5 r08a19ba 162 162 void ipc_phone_init(phone_t *phone) 163 163 { 164 mutex_initialize(&phone->lock );164 mutex_initialize(&phone->lock, MUTEX_PASSIVE); 165 165 phone->callee = NULL; 166 166 phone->state = IPC_PHONE_FREE; -
kernel/generic/src/mm/as.c
rdeaf8d5 r08a19ba 127 127 128 128 link_initialize(&as->inactive_as_with_asid_link); 129 mutex_initialize(&as->lock );129 mutex_initialize(&as->lock, MUTEX_PASSIVE); 130 130 131 131 rc = as_constructor_arch(as, flags); … … 169 169 as = [as_t new]; 170 170 link_initialize(&as->inactive_as_with_asid_link); 171 mutex_initialize(&as->lock );171 mutex_initialize(&as->lock, MUTEX_PASSIVE); 172 172 (void) as_constructor_arch(as, flags); 173 173 #else … … 313 313 a = (as_area_t *) malloc(sizeof(as_area_t), 0); 314 314 315 mutex_initialize(&a->lock );315 mutex_initialize(&a->lock, MUTEX_PASSIVE); 316 316 317 317 a->as = as; … … 695 695 if (!sh_info) { 696 696 sh_info = (share_info_t *) malloc(sizeof(share_info_t), 0); 697 mutex_initialize(&sh_info->lock );697 mutex_initialize(&sh_info->lock, MUTEX_PASSIVE); 698 698 sh_info->refcount = 2; 699 699 btree_create(&sh_info->pagemap); -
kernel/generic/src/proc/task.c
rdeaf8d5 r08a19ba 181 181 atomic_set(&ta->active_calls, 0); 182 182 183 mutex_initialize(&ta->futexes_lock );183 mutex_initialize(&ta->futexes_lock, MUTEX_PASSIVE); 184 184 btree_create(&ta->futexes); 185 185 -
kernel/generic/src/synch/condvar.c
rdeaf8d5 r08a19ba 44 44 /** Initialize condition variable. 45 45 * 46 * @param cv 46 * @param cv Condition variable. 47 47 */ 48 48 void condvar_initialize(condvar_t *cv) … … 51 51 } 52 52 53 /** 54 * Signal the condition has become true 55 * to the first waiting thread by waking it up. 53 /** Signal the condition has become true to the first waiting thread by waking 54 * it up. 56 55 * 57 * @param cv 56 * @param cv Condition variable. 58 57 */ 59 58 void condvar_signal(condvar_t *cv) … … 62 61 } 63 62 64 /** 65 * Signal the condition has become true 66 * to all waiting threads by waking them up. 63 /** Signal the condition has become true to all waiting threads by waking 64 * them up. 67 65 * 68 * @param cv 66 * @param cv Condition variable. 69 67 */ 70 68 void condvar_broadcast(condvar_t *cv) … … 75 73 /** Wait for the condition becoming true. 76 74 * 77 * @param cv 78 * @param mtx 79 * @param usec 80 * @param flags 75 * @param cv Condition variable. 76 * @param mtx Mutex. 77 * @param usec Timeout value in microseconds. 78 * @param flags Select mode of operation. 81 79 * 82 * For exact description of meaning of possible combinations 83 * of usec and flags, see comment for waitq_sleep_timeout().84 * Note that when SYNCH_FLAGS_NON_BLOCKING is specified here,85 * ESYNCH_WOULD_BLOCK is alwaysreturned.80 * For exact description of meaning of possible combinations of usec and flags, 81 * see comment for waitq_sleep_timeout(). Note that when 82 * SYNCH_FLAGS_NON_BLOCKING is specified here, ESYNCH_WOULD_BLOCK is always 83 * returned. 86 84 * 87 * @return 85 * @return See comment for waitq_sleep_timeout(). 88 86 */ 89 87 int _condvar_wait_timeout(condvar_t *cv, mutex_t *mtx, uint32_t usec, int flags) -
kernel/generic/src/synch/mutex.c
rdeaf8d5 r08a19ba 39 39 #include <synch/semaphore.h> 40 40 #include <synch/synch.h> 41 #include <debug.h> 41 42 42 /** Initialize mutex 43 /** Initialize mutex. 43 44 * 44 * Initialize mutex. 45 * 46 * @param mtx Mutex. 45 * @param mtx Mutex. 46 * @param type Type of the mutex. 47 47 */ 48 void mutex_initialize(mutex_t *mtx )48 void mutex_initialize(mutex_t *mtx, mutex_type_t type) 49 49 { 50 mtx->type = type; 50 51 semaphore_initialize(&mtx->sem, 1); 51 52 } 52 53 53 /** Acquire mutex 54 /** Acquire mutex. 54 55 * 55 * Acquire mutex.56 56 * Timeout mode and non-blocking mode can be requested. 57 57 * 58 * @param mtx 59 * @param usec 60 * @param flags 58 * @param mtx Mutex. 59 * @param usec Timeout in microseconds. 60 * @param flags Specify mode of operation. 61 61 * 62 62 * For exact description of possible combinations of 63 63 * usec and flags, see comment for waitq_sleep_timeout(). 64 64 * 65 * @return 65 * @return See comment for waitq_sleep_timeout(). 66 66 */ 67 67 int _mutex_lock_timeout(mutex_t *mtx, uint32_t usec, int flags) 68 68 { 69 return _semaphore_down_timeout(&mtx->sem, usec, flags); 69 int rc; 70 71 if (mtx->type == MUTEX_PASSIVE) { 72 rc = _semaphore_down_timeout(&mtx->sem, usec, flags); 73 } else { 74 ASSERT(mtx->type == MUTEX_ACTIVE); 75 ASSERT(usec == SYNCH_NO_TIMEOUT); 76 ASSERT(!(flags & SYNCH_FLAGS_INTERRUPTIBLE)); 77 do { 78 rc = semaphore_trydown(&mtx->sem); 79 } while (SYNCH_FAILED(rc) && 80 !(flags & SYNCH_FLAGS_NON_BLOCKING)); 81 } 82 83 return rc; 70 84 } 71 85 72 /** Release mutex 86 /** Release mutex. 73 87 * 74 * Release mutex. 75 * 76 * @param mtx Mutex. 88 * @param mtx Mutex. 77 89 */ 78 90 void mutex_unlock(mutex_t *mtx) -
kernel/generic/src/synch/rwlock.c
rdeaf8d5 r08a19ba 83 83 void rwlock_initialize(rwlock_t *rwl) { 84 84 spinlock_initialize(&rwl->lock, "rwlock_t"); 85 mutex_initialize(&rwl->exclusive );85 mutex_initialize(&rwl->exclusive, MUTEX_PASSIVE); 86 86 rwl->readers_in = 0; 87 87 } -
kernel/test/mm/slab2.c
rdeaf8d5 r08a19ba 217 217 218 218 condvar_initialize(&thread_starter); 219 mutex_initialize(&starter_mutex );219 mutex_initialize(&starter_mutex, MUTEX_PASSIVE); 220 220 221 221 thr_cache = slab_cache_create("thread_cache", size, 0, NULL, NULL, 0);
Note:
See TracChangeset
for help on using the changeset viewer.