/trunk/kernel/generic/src/synch/rwlock.c |
---|
220,12 → 220,14 |
*/ |
case ESYNCH_OK_BLOCKED: |
/* |
* We were woken with rwl->readers_in already incremented. |
* Note that this arrangement avoids race condition between |
* two concurrent readers. (Race is avoided if 'exclusive' is |
* locked at the same time as 'readers_in' is incremented. |
* Same time means both events happen atomically when |
* rwl->lock is held.) |
* We were woken with rwl->readers_in already |
* incremented. |
* |
* Note that this arrangement avoids race condition |
* between two concurrent readers. (Race is avoided if |
* 'exclusive' is locked at the same time as |
* 'readers_in' is incremented. Same time means both |
* events happen atomically when rwl->lock is held.) |
*/ |
interrupts_restore(ipl); |
break; |
323,7 → 325,8 |
spinlock_lock(&rwl->exclusive.sem.wq.lock); |
if (!list_empty(&rwl->exclusive.sem.wq.head)) |
t = list_get_instance(rwl->exclusive.sem.wq.head.next, thread_t, wq_link); |
t = list_get_instance(rwl->exclusive.sem.wq.head.next, thread_t, |
wq_link); |
do { |
if (t) { |
spinlock_lock(&t->lock); |
343,7 → 346,8 |
if (type == RWLOCK_READER) { |
/* |
* Waking up a reader. |
* We are responsible for incrementing rwl->readers_in for it. |
* We are responsible for incrementing rwl->readers_in |
* for it. |
*/ |
rwl->readers_in++; |
} |
360,7 → 364,8 |
t = NULL; |
if (!list_empty(&rwl->exclusive.sem.wq.head)) { |
t = list_get_instance(rwl->exclusive.sem.wq.head.next, thread_t, wq_link); |
t = list_get_instance(rwl->exclusive.sem.wq.head.next, |
thread_t, wq_link); |
if (t) { |
spinlock_lock(&t->lock); |
if (t->rwlock_holder_type != RWLOCK_READER) |
/trunk/kernel/generic/src/synch/spinlock.c |
---|
107,8 → 107,9 |
continue; |
#endif |
if (i++ > DEADLOCK_THRESHOLD) { |
printf("cpu%d: looping on spinlock %.*p:%s, caller=%.*p", |
CPU->id, sizeof(uintptr_t) * 2, sl, sl->name, sizeof(uintptr_t) * 2, CALLER); |
printf("cpu%d: looping on spinlock %.*p:%s, " |
"caller=%.*p", CPU->id, sizeof(uintptr_t) * 2, sl, |
sl->name, sizeof(uintptr_t) * 2, CALLER); |
symbol = get_symtab_entry(CALLER); |
if (symbol) |
printf("(%s)", symbol); |
/trunk/kernel/generic/src/synch/waitq.c |
---|
186,7 → 186,7 |
* |
* The sleep can be interrupted only if the |
* SYNCH_FLAGS_INTERRUPTIBLE bit is specified in flags. |
* |
* If usec is greater than zero, regardless of the value of the |
* SYNCH_FLAGS_NON_BLOCKING bit in flags, the call will not return until either |
* timeout, interruption or wakeup comes. |
/trunk/kernel/generic/src/synch/futex.c |
---|
102,11 → 102,12 |
/** Sleep in futex wait queue. |
* |
* @param uaddr Userspace address of the futex counter. |
* @param usec If non-zero, number of microseconds this thread is willing to sleep. |
* @param usec If non-zero, number of microseconds this thread is willing to |
* sleep. |
* @param flags Select mode of operation. |
* |
* @return One of ESYNCH_TIMEOUT, ESYNCH_OK_ATOMIC and ESYNCH_OK_BLOCKED. See synch.h. |
* If there is no physical mapping for uaddr ENOENT is returned. |
* @return One of ESYNCH_TIMEOUT, ESYNCH_OK_ATOMIC and ESYNCH_OK_BLOCKED. See |
* synch.h. If there is no physical mapping for uaddr ENOENT is returned. |
*/ |
unative_t sys_futex_sleep_timeout(uintptr_t uaddr, uint32_t usec, int flags) |
{ |
134,7 → 135,8 |
futex = futex_find(paddr); |
return (unative_t) waitq_sleep_timeout(&futex->wq, usec, flags | SYNCH_FLAGS_INTERRUPTIBLE); |
return (unative_t) waitq_sleep_timeout(&futex->wq, usec, flags | |
SYNCH_FLAGS_INTERRUPTIBLE); |
} |
/** Wakeup one thread waiting in futex wait queue. |
242,7 → 244,8 |
* current task's B+tree of known futexes. |
*/ |
futex->refcount++; |
btree_insert(&TASK->futexes, paddr, futex, leaf); |
btree_insert(&TASK->futexes, paddr, futex, |
leaf); |
} |
mutex_unlock(&TASK->futexes_lock); |
271,7 → 274,8 |
/** Compute hash index into futex hash table. |
* |
* @param key Address where the key (i.e. physical address of futex counter) is stored. |
* @param key Address where the key (i.e. physical address of futex counter) is |
* stored. |
* |
* @return Index into futex hash table. |
*/ |
282,7 → 286,8 |
/** Compare futex hash table item with a key. |
* |
* @param key Address where the key (i.e. physical address of futex counter) is stored. |
* @param key Address where the key (i.e. physical address of futex counter) is |
* stored. |
* |
* @return True if the item matches the key. False otherwise. |
*/ |
316,7 → 321,8 |
rwlock_write_lock(&futex_ht_lock); |
mutex_lock(&TASK->futexes_lock); |
for (cur = TASK->futexes.leaf_head.next; cur != &TASK->futexes.leaf_head; cur = cur->next) { |
for (cur = TASK->futexes.leaf_head.next; |
cur != &TASK->futexes.leaf_head; cur = cur->next) { |
btree_node_t *node; |
int i; |