68,7 → 68,6 |
#include <syscall/copy.h> |
#include <errno.h> |
#include <console/klog.h> |
#include <tdebug/tdebug.h> |
|
|
/** Thread states */ |
342,14 → 341,10 |
|
avltree_node_initialize(&t->threads_tree_node); |
t->threads_tree_node.key = (uintptr_t) t; |
// t->threads_tree_node.key = (avltree_key_t) t->tid; |
|
/* might depend on previous initialization */ |
thread_create_arch(t); |
thread_create_arch(t); |
|
/* init tdebug stuff */ |
tdebug_thread_init(t); |
|
if (!(flags & THREAD_FLAG_NOATTACH)) |
thread_attach(t, task); |
|
447,7 → 442,6 |
if (THREAD->flags & THREAD_FLAG_USPACE) { |
ipc_cleanup(); |
futex_cleanup(); |
tdebug_cleanup(); |
klog_printf("Cleanup of task %llu completed.", |
TASK->taskid); |
} |
755,56 → 749,6 |
return 0; |
} |
|
struct fbiw { |
thread_id_t tid; |
thread_t *t; |
}; |
|
static bool find_by_id_walker(avltree_node_t *node, void *arg) |
{ |
thread_t *t = avltree_get_instance(node, thread_t, threads_tree_node); |
struct fbiw *s = (struct fbiw *)arg; |
|
if (t->tid == s->tid) { |
/* found it! */ |
s->t = t; |
return false; |
} |
|
return true; /* continue */ |
} |
|
/** Find thread structure corresponding to thread ID. |
* |
* The threads_lock must be already held by the caller of this function |
* and interrupts must be disabled. |
* |
* @param id Thread ID. |
* |
* @return Thread structure address or NULL if there is no such thread ID. |
*/ |
thread_t *thread_find_by_id(thread_id_t id) |
{ |
struct fbiw s; |
|
s.t = NULL; |
s.tid = id; |
|
avltree_walk(&threads_tree, find_by_id_walker, &s); |
|
return s.t; |
/* |
// ANO, takhle krasne by to fungovalo, kdyby threads_tree |
// nepouzival jako klic pointer na vlakno misto tid |
avltree_node_t *node; |
|
node = avltree_search(&threads_tree, (avltree_key_t) id); |
|
if (node) |
return avltree_get_instance(node, thread_t, threads_tree_node); |
return NULL;*/ |
} |
|
/** Syscall for getting TID. |
* |
* @param uspace_thread_id Userspace address of 8-byte buffer where to store |