Rev 1167 | Rev 1407 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 1167 | Rev 1392 | ||
---|---|---|---|
Line 31... | Line 31... | ||
31 | #include <stdlib.h> |
31 | #include <stdlib.h> |
32 | #include <arch/faddr.h> |
32 | #include <arch/faddr.h> |
33 | #include <kernel/proc/uarg.h> |
33 | #include <kernel/proc/uarg.h> |
34 | #include <psthread.h> |
34 | #include <psthread.h> |
35 | #include <string.h> |
35 | #include <string.h> |
- | 36 | #include <async.h> |
|
36 | 37 | ||
37 | #include <stdio.h> |
38 | #include <stdio.h> |
38 | 39 | ||
39 | 40 | ||
40 | #ifndef THREAD_INITIAL_STACK_PAGES_NO |
41 | #ifndef THREAD_INITIAL_STACK_PAGES_NO |
Line 78... | Line 79... | ||
78 | * to call the thread's implementing function and perform cleanup |
79 | * to call the thread's implementing function and perform cleanup |
79 | * and exit when thread returns back. Do not call this function |
80 | * and exit when thread returns back. Do not call this function |
80 | * directly. |
81 | * directly. |
81 | * |
82 | * |
82 | * @param uarg Pointer to userspace argument structure. |
83 | * @param uarg Pointer to userspace argument structure. |
- | 84 | * |
|
- | 85 | * TODO: Thread stack pages memory leak |
|
83 | */ |
86 | */ |
84 | void __thread_main(uspace_arg_t *uarg) |
87 | void __thread_main(uspace_arg_t *uarg) |
85 | { |
88 | { |
86 | tcb_t *tcb; |
89 | psthread_data_t *pt; |
87 | /* This should initialize the area according to TLS specicification */ |
- | |
- | 90 | ||
88 | tcb = __make_tls(); |
91 | pt = psthread_setup(); |
89 | __tcb_set(tcb); |
92 | __tcb_set(pt->tcb); |
- | 93 | ||
90 | psthread_setup(tcb); |
94 | async_create_manager(); |
91 | 95 | ||
92 | uarg->uspace_thread_function(uarg->uspace_thread_arg); |
96 | uarg->uspace_thread_function(uarg->uspace_thread_arg); |
93 | free(uarg->uspace_stack); |
97 | free(uarg->uspace_stack); |
94 | free(uarg); |
98 | free(uarg); |
95 | 99 | ||
96 | psthread_teardown(tcb->pst_data); |
100 | async_destroy_manager(); |
97 | __free_tls(tcb); |
101 | psthread_teardown(pt); |
98 | 102 | ||
99 | thread_exit(0); |
103 | thread_exit(0); |
100 | } |
104 | } |
101 | 105 | ||
102 | /** Create userspace thread. |
106 | /** Create userspace thread. |