Rev 2712 | Rev 2799 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
| Rev 2712 | Rev 2787 | ||
|---|---|---|---|
| Line 66... | Line 66... | ||
| 66 | #include <debug.h> |
66 | #include <debug.h> |
| 67 | #include <main/uinit.h> |
67 | #include <main/uinit.h> |
| 68 | #include <syscall/copy.h> |
68 | #include <syscall/copy.h> |
| 69 | #include <errno.h> |
69 | #include <errno.h> |
| 70 | #include <console/klog.h> |
70 | #include <console/klog.h> |
| - | 71 | #include <tdebug/tdebug.h> |
|
| 71 | 72 | ||
| 72 | 73 | ||
| 73 | /** Thread states */ |
74 | /** Thread states */ |
| 74 | char *thread_states[] = { |
75 | char *thread_states[] = { |
| 75 | "Invalid", |
76 | "Invalid", |
| Line 339... | Line 340... | ||
| 339 | t->fpu_context_exists = 0; |
340 | t->fpu_context_exists = 0; |
| 340 | t->fpu_context_engaged = 0; |
341 | t->fpu_context_engaged = 0; |
| 341 | 342 | ||
| 342 | avltree_node_initialize(&t->threads_tree_node); |
343 | avltree_node_initialize(&t->threads_tree_node); |
| 343 | t->threads_tree_node.key = (uintptr_t) t; |
344 | t->threads_tree_node.key = (uintptr_t) t; |
| - | 345 | // t->threads_tree_node.key = (avltree_key_t) t->tid; |
|
| 344 | 346 | ||
| 345 | /* might depend on previous initialization */ |
347 | /* might depend on previous initialization */ |
| 346 | thread_create_arch(t); |
348 | thread_create_arch(t); |
| - | 349 | ||
| - | 350 | /* init tdebug stuff */ |
|
| - | 351 | tdebug_thread_init(t); |
|
| 347 | 352 | ||
| 348 | if (!(flags & THREAD_FLAG_NOATTACH)) |
353 | if (!(flags & THREAD_FLAG_NOATTACH)) |
| 349 | thread_attach(t, task); |
354 | thread_attach(t, task); |
| 350 | 355 | ||
| 351 | return t; |
356 | return t; |
| Line 440... | Line 445... | ||
| 440 | * We are safe to perform cleanup. |
445 | * We are safe to perform cleanup. |
| 441 | */ |
446 | */ |
| 442 | if (THREAD->flags & THREAD_FLAG_USPACE) { |
447 | if (THREAD->flags & THREAD_FLAG_USPACE) { |
| 443 | ipc_cleanup(); |
448 | ipc_cleanup(); |
| 444 | futex_cleanup(); |
449 | futex_cleanup(); |
| - | 450 | tdebug_cleanup(); |
|
| 445 | klog_printf("Cleanup of task %llu completed.", |
451 | klog_printf("Cleanup of task %llu completed.", |
| 446 | TASK->taskid); |
452 | TASK->taskid); |
| 447 | } |
453 | } |
| 448 | } |
454 | } |
| 449 | 455 | ||
| Line 747... | Line 753... | ||
| 747 | thread_exit(); |
753 | thread_exit(); |
| 748 | /* Unreachable */ |
754 | /* Unreachable */ |
| 749 | return 0; |
755 | return 0; |
| 750 | } |
756 | } |
| 751 | 757 | ||
| - | 758 | struct fbiw { |
|
| - | 759 | thread_id_t tid; |
|
| - | 760 | thread_t *t; |
|
| - | 761 | }; |
|
| - | 762 | ||
| - | 763 | static bool find_by_id_walker(avltree_node_t *node, void *arg) |
|
| - | 764 | { |
|
| - | 765 | thread_t *t = avltree_get_instance(node, thread_t, threads_tree_node); |
|
| - | 766 | struct fbiw *s = (struct fbiw *)arg; |
|
| - | 767 | ||
| - | 768 | if (t->tid == s->tid) { |
|
| - | 769 | /* found it! */ |
|
| - | 770 | s->t = t; |
|
| - | 771 | return false; |
|
| - | 772 | } |
|
| - | 773 | ||
| - | 774 | return true; /* continue */ |
|
| - | 775 | } |
|
| - | 776 | ||
| - | 777 | /** Find thread structure corresponding to thread ID. |
|
| - | 778 | * |
|
| - | 779 | * The threads_lock must be already held by the caller of this function |
|
| - | 780 | * and interrupts must be disabled. |
|
| - | 781 | * |
|
| - | 782 | * @param id Thread ID. |
|
| - | 783 | * |
|
| - | 784 | * @return Thread structure address or NULL if there is no such thread ID. |
|
| - | 785 | */ |
|
| - | 786 | thread_t *thread_find_by_id(thread_id_t id) |
|
| - | 787 | { |
|
| - | 788 | struct fbiw s; |
|
| - | 789 | ||
| - | 790 | s.t = NULL; |
|
| - | 791 | s.tid = id; |
|
| - | 792 | ||
| - | 793 | avltree_walk(&threads_tree, find_by_id_walker, &s); |
|
| - | 794 | ||
| - | 795 | return s.t; |
|
| - | 796 | /* |
|
| - | 797 | // ANO, takhle krasne by to fungovalo, kdyby threads_tree |
|
| - | 798 | // nepouzival jako klic pointer na vlakno misto tid |
|
| - | 799 | avltree_node_t *node; |
|
| - | 800 | |
|
| - | 801 | node = avltree_search(&threads_tree, (avltree_key_t) id); |
|
| - | 802 | ||
| - | 803 | if (node) |
|
| - | 804 | return avltree_get_instance(node, thread_t, threads_tree_node); |
|
| - | 805 | return NULL;*/ |
|
| - | 806 | } |
|
| - | 807 | ||
| 752 | /** Syscall for getting TID. |
808 | /** Syscall for getting TID. |
| 753 | * |
809 | * |
| 754 | * @param uspace_thread_id Userspace address of 8-byte buffer where to store |
810 | * @param uspace_thread_id Userspace address of 8-byte buffer where to store |
| 755 | * current thread ID. |
811 | * current thread ID. |
| 756 | * |
812 | * |