Changeset e1b6742 in mainline for kernel/generic/src/proc/thread.c


Ignore:
Timestamp:
2010-04-18T12:17:11Z (14 years ago)
Author:
Martin Decky <martin@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
e535eeb
Parents:
bbda5ab
Message:

export threads to user space
the "tasks" command can now print all threads or threads belonging to a task

File:
1 edited

Legend:

Unmodified
Added
Removed
  • kernel/generic/src/proc/thread.c

    rbbda5ab re1b6742  
    8484        "Exiting",
    8585        "Lingering"
    86 };
     86};
     87
     88typedef struct {
     89        thread_id_t thread_id;
     90        thread_t *thread;
     91} thread_iterator_t;
    8792
    8893/** Lock protecting the threads_tree AVL tree.
     
    726731        THREAD->last_cycle = time;
    727732}
     733
     734static bool thread_search_walker(avltree_node_t *node, void *arg)
     735{
     736        thread_t *thread =
     737            (thread_t *) avltree_get_instance(node, thread_t, threads_tree_node);
     738        thread_iterator_t *iterator = (thread_iterator_t *) arg;
     739       
     740        if (thread->tid == iterator->thread_id) {
     741                iterator->thread = thread;
     742                return false;
     743        }
     744       
     745        return true;
     746}
     747
     748/** Find thread structure corresponding to thread ID.
     749 *
     750 * The threads_lock must be already held by the caller of this function and
     751 * interrupts must be disabled.
     752 *
     753 * @param id Thread ID.
     754 *
     755 * @return Thread structure address or NULL if there is no such thread ID.
     756 *
     757 */
     758thread_t *thread_find_by_id(thread_id_t thread_id)
     759{
     760        thread_iterator_t iterator;
     761       
     762        iterator.thread_id = thread_id;
     763        iterator.thread = NULL;
     764       
     765        avltree_walk(&threads_tree, thread_search_walker, (void *) &iterator);
     766       
     767        return iterator.thread;
     768}
     769
    728770
    729771/** Process syscall to create new thread.
Note: See TracChangeset for help on using the changeset viewer.