Rev 1129 | Rev 1392 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 1129 | Rev 1155 | ||
---|---|---|---|
Line 32... | Line 32... | ||
32 | #include <unistd.h> |
32 | #include <unistd.h> |
33 | #include <thread.h> |
33 | #include <thread.h> |
34 | #include <stdio.h> |
34 | #include <stdio.h> |
35 | #include <kernel/arch/faddr.h> |
35 | #include <kernel/arch/faddr.h> |
36 | 36 | ||
- | 37 | ||
- | 38 | #ifndef PSTHREAD_INITIAL_STACK_PAGES_NO |
|
- | 39 | #define PSTHREAD_INITIAL_STACK_PAGES_NO 1 |
|
- | 40 | #endif |
|
- | 41 | ||
37 | static LIST_INITIALIZE(ready_list); |
42 | static LIST_INITIALIZE(ready_list); |
38 | 43 | ||
39 | static void psthread_exit(void) __attribute__ ((noinline)); |
44 | static void psthread_exit(void) __attribute__ ((noinline)); |
40 | static void psthread_main(void); |
45 | static void psthread_main(void); |
41 | 46 | ||
Line 163... | Line 168... | ||
163 | pt = psthread_setup(tcb); |
168 | pt = psthread_setup(tcb); |
164 | if (!pt) { |
169 | if (!pt) { |
165 | __free_tls(tcb); |
170 | __free_tls(tcb); |
166 | return 0; |
171 | return 0; |
167 | } |
172 | } |
168 | pt->stack = (char *) malloc(getpagesize()); |
173 | pt->stack = (char *) malloc(PSTHREAD_INITIAL_STACK_PAGES_NO*getpagesize()); |
169 | 174 | ||
170 | if (!pt->stack) { |
175 | if (!pt->stack) { |
171 | __free_tls(tcb); |
176 | __free_tls(tcb); |
172 | psthread_teardown(pt); |
177 | psthread_teardown(pt); |
173 | return 0; |
178 | return 0; |
Line 177... | Line 182... | ||
177 | pt->func = func; |
182 | pt->func = func; |
178 | pt->finished = 0; |
183 | pt->finished = 0; |
179 | pt->waiter = NULL; |
184 | pt->waiter = NULL; |
180 | 185 | ||
181 | context_save(&pt->ctx); |
186 | context_save(&pt->ctx); |
182 | context_set(&pt->ctx, FADDR(psthread_main), pt->stack, getpagesize(), |
187 | context_set(&pt->ctx, FADDR(psthread_main), pt->stack, PSTHREAD_INITIAL_STACK_PAGES_NO*getpagesize(), |
183 | tcb); |
188 | tcb); |
184 | 189 | ||
185 | list_append(&pt->link, &ready_list); |
190 | list_append(&pt->link, &ready_list); |
186 | 191 | ||
187 | return (pstid_t )pt; |
192 | return (pstid_t )pt; |