Rev 2216 | Rev 2469 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 2216 | Rev 2436 | ||
---|---|---|---|
Line 75... | Line 75... | ||
75 | */ |
75 | */ |
76 | memcpy(data, &_tdata_start, &_tdata_end - &_tdata_start); |
76 | memcpy(data, &_tdata_start, &_tdata_end - &_tdata_start); |
77 | /* |
77 | /* |
78 | * Zero out the thread local uninitialized data. |
78 | * Zero out the thread local uninitialized data. |
79 | */ |
79 | */ |
80 | memset(data + (&_tbss_start - &_tdata_start), 0, &_tbss_end - |
80 | memset(data + (&_tbss_start - &_tdata_start), 0, |
81 | &_tbss_start); |
81 | &_tbss_end - &_tbss_start); |
82 | 82 | ||
83 | return tcb; |
83 | return tcb; |
84 | } |
84 | } |
85 | 85 | ||
86 | void __free_tls(tcb_t *tcb) |
86 | void __free_tls(tcb_t *tcb) |
Line 126... | Line 126... | ||
126 | * @param name Symbolic name of the thread. |
126 | * @param name Symbolic name of the thread. |
127 | * @param tid Thread ID of the newly created thread. |
127 | * @param tid Thread ID of the newly created thread. |
128 | * |
128 | * |
129 | * @return Zero on success or a code from @ref errno.h on failure. |
129 | * @return Zero on success or a code from @ref errno.h on failure. |
130 | */ |
130 | */ |
131 | int thread_create(void (* function)(void *), void *arg, char *name, thread_id_t *tid) |
131 | int thread_create(void (* function)(void *), void *arg, char *name, |
- | 132 | thread_id_t *tid) |
|
132 | { |
133 | { |
133 | char *stack; |
134 | char *stack; |
134 | uspace_arg_t *uarg; |
135 | uspace_arg_t *uarg; |
- | 136 | int rc; |
|
135 | 137 | ||
136 | stack = (char *) malloc(getpagesize() * THREAD_INITIAL_STACK_PAGES_NO); |
138 | stack = (char *) malloc(getpagesize() * THREAD_INITIAL_STACK_PAGES_NO); |
137 | if (!stack) |
139 | if (!stack) |
138 | return -1; |
140 | return -1; |
139 | 141 | ||
Line 147... | Line 149... | ||
147 | uarg->uspace_stack = (void *) stack; |
149 | uarg->uspace_stack = (void *) stack; |
148 | uarg->uspace_thread_function = function; |
150 | uarg->uspace_thread_function = function; |
149 | uarg->uspace_thread_arg = arg; |
151 | uarg->uspace_thread_arg = arg; |
150 | uarg->uspace_uarg = uarg; |
152 | uarg->uspace_uarg = uarg; |
151 | 153 | ||
152 | return __SYSCALL3(SYS_THREAD_CREATE, (sysarg_t) uarg, (sysarg_t) name, (sysarg_t) tid); |
154 | rc = __SYSCALL3(SYS_THREAD_CREATE, (sysarg_t) uarg, (sysarg_t) name, |
- | 155 | (sysarg_t) tid); |
|
- | 156 | ||
- | 157 | if (!rc) { |
|
- | 158 | /* |
|
- | 159 | * Failed to create a new thread. |
|
- | 160 | * Free up the allocated structures. |
|
- | 161 | */ |
|
- | 162 | free(uarg); |
|
- | 163 | free(stack); |
|
- | 164 | } |
|
- | 165 | ||
- | 166 | return rc; |
|
153 | } |
167 | } |
154 | 168 | ||
155 | /** Terminate current thread. |
169 | /** Terminate current thread. |
156 | * |
170 | * |
157 | * @param status Exit status. Currently not used. |
171 | * @param status Exit status. Currently not used. |