core/dynamo.c
/* assumes caller can ensure that thread is either suspended or self to
 * avoid races
 */
assumes caller can ensure that thread is either suspended or self to
avoid races
assumes caller can ensure that thread is either suspended or self to avoid races
thread_record_t * 
thread_lookup(thread_id_t tid)
{
    thread_record_t *tr;
    uint hindex;
    ASSERT(mutex_testlock(&thread_initexit_lock) || tid == get_thread_id());
    hindex = HASH_FUNC_BITS(tid, ALL_THREADS_HASH_BITS);
    mutex_lock(&all_threads_lock);
    if (all_threads == NULL) { 
        tr = NULL;
    } else { 
        tr = all_threads[hindex];
    }
    while (tr != NULL) {
        if (tr->id == tid) {
            mutex_unlock(&all_threads_lock);
            return tr;
        }
        tr = tr->next;
    }
    mutex_unlock(&all_threads_lock);
    return NULL;
}
thread_record_t * thread_lookup ( thread_id_t tid ) { thread_record_t * tr ; uint hindex ; ASSERT ( mutex_testlock ( & thread_initexit_lock ) || tid == get_thread_id ( ) ) ; hindex = HASH_FUNC_BITS ( tid , ALL_THREADS_HASH_BITS ) ; mutex_lock ( & all_threads_lock ) ; if ( all_threads == NULL ) { tr = NULL ; } else { tr = all_threads [ hindex ] ; } while ( tr != NULL ) { if ( tr -> id == tid ) { mutex_unlock ( & all_threads_lock ) ; return tr ; } tr = tr -> next ; } mutex_unlock ( & all_threads_lock ) ; return NULL ; }
assumes caller can ensure that thread is either suspended or self to
 avoid races
assumes caller can ensure that thread is either suspended or self to avoid races
/* check that caller is self or has initexit_lock
     * FIXME: no way to tell who has initexit_lock
     */