wdenk | 8dba050 | 2003-03-31 16:34:49 +0000 | [diff] [blame] | 1 | /* |
Wolfgang Denk | d79de1d | 2013-07-08 09:37:19 +0200 | [diff] [blame] | 2 | * SPDX-License-Identifier: GPL-2.0+ |
wdenk | 8dba050 | 2003-03-31 16:34:49 +0000 | [diff] [blame] | 3 | */ |
| 4 | |
| 5 | #include <common.h> |
wdenk | 874ac26 | 2003-07-24 23:38:38 +0000 | [diff] [blame] | 6 | #include <exports.h> |
wdenk | 8dba050 | 2003-03-31 16:34:49 +0000 | [diff] [blame] | 7 | |
| 8 | /* |
| 9 | * Author: Arun Dharankar <ADharankar@ATTBI.Com> |
| 10 | * |
| 11 | * A very simple thread/schedular model: |
| 12 | * - only one master thread, and no parent child relation maintained |
| 13 | * - parent thread cannot be stopped or deleted |
| 14 | * - no permissions or credentials |
| 15 | * - no elaborate safety checks |
| 16 | * - cooperative multi threading |
| 17 | * - Simple round-robin scheduleing with no priorities |
| 18 | * - no metering/statistics collection |
| 19 | * |
| 20 | * Basic idea of implementing this is to allow more than one tests to |
| 21 | * execute "simultaneously". |
| 22 | * |
| 23 | * This may be modified such thread_yield may be called in syscalls, and |
| 24 | * timer interrupts. |
| 25 | */ |
| 26 | |
| 27 | |
| 28 | #define MAX_THREADS 8 |
| 29 | |
| 30 | #define CTX_SIZE 512 |
| 31 | #define STK_SIZE 8*1024 |
| 32 | |
| 33 | #define STATE_EMPTY 0 |
| 34 | #define STATE_RUNNABLE 1 |
| 35 | #define STATE_STOPPED 2 |
| 36 | #define STATE_TERMINATED 2 |
| 37 | |
| 38 | #define MASTER_THREAD 0 |
| 39 | |
| 40 | #define RC_FAILURE (-1) |
| 41 | #define RC_SUCCESS (0) |
| 42 | |
wdenk | b02744a | 2003-04-05 00:53:31 +0000 | [diff] [blame] | 43 | typedef vu_char *jmp_ctx; |
| 44 | unsigned long setctxsp (vu_char *sp); |
| 45 | int ppc_setjmp(jmp_ctx env); |
| 46 | void ppc_longjmp(jmp_ctx env, int val); |
| 47 | #define setjmp ppc_setjmp |
| 48 | #define longjmp ppc_longjmp |
| 49 | |
wdenk | 8dba050 | 2003-03-31 16:34:49 +0000 | [diff] [blame] | 50 | struct lthread { |
| 51 | int state; |
| 52 | int retval; |
| 53 | char stack[STK_SIZE]; |
| 54 | uchar context[CTX_SIZE]; |
| 55 | int (*func) (void *); |
| 56 | void *arg; |
| 57 | }; |
| 58 | static volatile struct lthread lthreads[MAX_THREADS]; |
| 59 | static volatile int current_tid = MASTER_THREAD; |
| 60 | |
| 61 | |
| 62 | static uchar dbg = 0; |
| 63 | |
wdenk | b02744a | 2003-04-05 00:53:31 +0000 | [diff] [blame] | 64 | #define PDEBUG(fmt, args...) { \ |
| 65 | if(dbg != 0) { \ |
wdenk | 874ac26 | 2003-07-24 23:38:38 +0000 | [diff] [blame] | 66 | printf("[%s %d %s]: ",__FILE__,__LINE__,__FUNCTION__);\ |
| 67 | printf(fmt, ##args); \ |
| 68 | printf("\n"); \ |
wdenk | b02744a | 2003-04-05 00:53:31 +0000 | [diff] [blame] | 69 | } \ |
| 70 | } |
wdenk | 8dba050 | 2003-03-31 16:34:49 +0000 | [diff] [blame] | 71 | |
| 72 | static int testthread (void *); |
| 73 | static void sched_init (void); |
| 74 | static int thread_create (int (*func) (void *), void *arg); |
| 75 | static int thread_start (int id); |
| 76 | static void thread_yield (void); |
| 77 | static int thread_delete (int id); |
| 78 | static int thread_join (int *ret); |
wdenk | b02744a | 2003-04-05 00:53:31 +0000 | [diff] [blame] | 79 | |
| 80 | #if 0 /* not used yet */ |
wdenk | 8dba050 | 2003-03-31 16:34:49 +0000 | [diff] [blame] | 81 | static int thread_stop (int id); |
wdenk | b02744a | 2003-04-05 00:53:31 +0000 | [diff] [blame] | 82 | #endif /* not used yet */ |
wdenk | 8dba050 | 2003-03-31 16:34:49 +0000 | [diff] [blame] | 83 | |
| 84 | /* An example of schedular test */ |
| 85 | |
| 86 | #define NUMTHREADS 7 |
wdenk | 874ac26 | 2003-07-24 23:38:38 +0000 | [diff] [blame] | 87 | int sched (int ac, char *av[]) |
wdenk | 8dba050 | 2003-03-31 16:34:49 +0000 | [diff] [blame] | 88 | { |
| 89 | int i, j; |
| 90 | int tid[NUMTHREADS]; |
| 91 | int names[NUMTHREADS]; |
| 92 | |
wdenk | 874ac26 | 2003-07-24 23:38:38 +0000 | [diff] [blame] | 93 | app_startup(av); |
| 94 | |
wdenk | 8dba050 | 2003-03-31 16:34:49 +0000 | [diff] [blame] | 95 | sched_init (); |
| 96 | |
| 97 | for (i = 0; i < NUMTHREADS; i++) { |
| 98 | names[i] = i; |
| 99 | j = thread_create (testthread, (void *) &names[i]); |
| 100 | if (j == RC_FAILURE) |
wdenk | 874ac26 | 2003-07-24 23:38:38 +0000 | [diff] [blame] | 101 | printf ("schedtest: Failed to create thread %d\n", i); |
wdenk | 8dba050 | 2003-03-31 16:34:49 +0000 | [diff] [blame] | 102 | if (j > 0) { |
wdenk | 874ac26 | 2003-07-24 23:38:38 +0000 | [diff] [blame] | 103 | printf ("schedtest: Created thread with id %d, name %d\n", |
wdenk | b02744a | 2003-04-05 00:53:31 +0000 | [diff] [blame] | 104 | j, i); |
wdenk | 8dba050 | 2003-03-31 16:34:49 +0000 | [diff] [blame] | 105 | tid[i] = j; |
| 106 | } |
| 107 | } |
wdenk | 874ac26 | 2003-07-24 23:38:38 +0000 | [diff] [blame] | 108 | printf ("schedtest: Threads created\n"); |
wdenk | 8dba050 | 2003-03-31 16:34:49 +0000 | [diff] [blame] | 109 | |
wdenk | 874ac26 | 2003-07-24 23:38:38 +0000 | [diff] [blame] | 110 | printf ("sched_test: function=0x%08x\n", (unsigned)testthread); |
wdenk | 8dba050 | 2003-03-31 16:34:49 +0000 | [diff] [blame] | 111 | for (i = 0; i < NUMTHREADS; i++) { |
wdenk | 874ac26 | 2003-07-24 23:38:38 +0000 | [diff] [blame] | 112 | printf ("schedtest: Setting thread %d runnable\n", tid[i]); |
wdenk | 8dba050 | 2003-03-31 16:34:49 +0000 | [diff] [blame] | 113 | thread_start (tid[i]); |
| 114 | thread_yield (); |
| 115 | } |
wdenk | 874ac26 | 2003-07-24 23:38:38 +0000 | [diff] [blame] | 116 | printf ("schedtest: Started %d threads\n", NUMTHREADS); |
wdenk | 8dba050 | 2003-03-31 16:34:49 +0000 | [diff] [blame] | 117 | |
| 118 | while (1) { |
wdenk | 874ac26 | 2003-07-24 23:38:38 +0000 | [diff] [blame] | 119 | printf ("schedtest: Waiting for threads to complete\n"); |
| 120 | if (tstc () && getc () == 0x3) { |
| 121 | printf ("schedtest: Aborting threads...\n"); |
wdenk | 8dba050 | 2003-03-31 16:34:49 +0000 | [diff] [blame] | 122 | for (i = 0; i < NUMTHREADS; i++) { |
wdenk | 874ac26 | 2003-07-24 23:38:38 +0000 | [diff] [blame] | 123 | printf ("schedtest: Deleting thread %d\n", tid[i]); |
wdenk | 8dba050 | 2003-03-31 16:34:49 +0000 | [diff] [blame] | 124 | thread_delete (tid[i]); |
| 125 | } |
| 126 | return RC_SUCCESS; |
| 127 | } |
| 128 | j = -1; |
| 129 | i = thread_join (&j); |
| 130 | if (i == RC_FAILURE) { |
wdenk | 874ac26 | 2003-07-24 23:38:38 +0000 | [diff] [blame] | 131 | printf ("schedtest: No threads pending, " |
wdenk | b02744a | 2003-04-05 00:53:31 +0000 | [diff] [blame] | 132 | "exiting schedular test\n"); |
wdenk | 8dba050 | 2003-03-31 16:34:49 +0000 | [diff] [blame] | 133 | return RC_SUCCESS; |
| 134 | } |
wdenk | 874ac26 | 2003-07-24 23:38:38 +0000 | [diff] [blame] | 135 | printf ("schedtest: thread is %d returned %d\n", i, j); |
wdenk | 8dba050 | 2003-03-31 16:34:49 +0000 | [diff] [blame] | 136 | thread_yield (); |
| 137 | } |
| 138 | |
| 139 | return RC_SUCCESS; |
| 140 | } |
| 141 | |
| 142 | static int testthread (void *name) |
| 143 | { |
| 144 | int i; |
| 145 | |
wdenk | 874ac26 | 2003-07-24 23:38:38 +0000 | [diff] [blame] | 146 | printf ("testthread: Begin executing thread, myname %d, &i=0x%08x\n", |
| 147 | *(int *) name, (unsigned)&i); |
wdenk | 8dba050 | 2003-03-31 16:34:49 +0000 | [diff] [blame] | 148 | |
wdenk | 874ac26 | 2003-07-24 23:38:38 +0000 | [diff] [blame] | 149 | printf ("Thread %02d, i=%d\n", *(int *) name, i); |
wdenk | 8dba050 | 2003-03-31 16:34:49 +0000 | [diff] [blame] | 150 | |
| 151 | for (i = 0; i < 0xffff * (*(int *) name + 1); i++) { |
wdenk | 874ac26 | 2003-07-24 23:38:38 +0000 | [diff] [blame] | 152 | if (tstc () && getc () == 0x3) { |
| 153 | printf ("testthread: myname %d terminating.\n", |
wdenk | b02744a | 2003-04-05 00:53:31 +0000 | [diff] [blame] | 154 | *(int *) name); |
wdenk | 8dba050 | 2003-03-31 16:34:49 +0000 | [diff] [blame] | 155 | return *(int *) name + 1; |
| 156 | } |
| 157 | |
| 158 | if (i % 100 == 0) |
| 159 | thread_yield (); |
| 160 | } |
| 161 | |
wdenk | 874ac26 | 2003-07-24 23:38:38 +0000 | [diff] [blame] | 162 | printf ("testthread: returning %d, i=0x%x\n", |
wdenk | b02744a | 2003-04-05 00:53:31 +0000 | [diff] [blame] | 163 | *(int *) name + 1, i); |
wdenk | 8dba050 | 2003-03-31 16:34:49 +0000 | [diff] [blame] | 164 | |
| 165 | return *(int *) name + 1; |
| 166 | } |
| 167 | |
| 168 | |
| 169 | static void sched_init (void) |
| 170 | { |
| 171 | int i; |
| 172 | |
| 173 | for (i = MASTER_THREAD + 1; i < MAX_THREADS; i++) |
| 174 | lthreads[i].state = STATE_EMPTY; |
| 175 | |
| 176 | current_tid = MASTER_THREAD; |
| 177 | lthreads[current_tid].state = STATE_RUNNABLE; |
wdenk | b02744a | 2003-04-05 00:53:31 +0000 | [diff] [blame] | 178 | PDEBUG ("sched_init: master context = 0x%08x", |
wdenk | 874ac26 | 2003-07-24 23:38:38 +0000 | [diff] [blame] | 179 | (unsigned)lthreads[current_tid].context); |
wdenk | 8dba050 | 2003-03-31 16:34:49 +0000 | [diff] [blame] | 180 | return; |
| 181 | } |
| 182 | |
| 183 | static void thread_yield (void) |
| 184 | { |
| 185 | static int i; |
| 186 | |
wdenk | b02744a | 2003-04-05 00:53:31 +0000 | [diff] [blame] | 187 | PDEBUG ("thread_yield: current tid=%d", current_tid); |
wdenk | 8dba050 | 2003-03-31 16:34:49 +0000 | [diff] [blame] | 188 | |
Wolfgang Denk | a1be476 | 2008-05-20 16:00:29 +0200 | [diff] [blame] | 189 | #define SWITCH(new) \ |
wdenk | 8dba050 | 2003-03-31 16:34:49 +0000 | [diff] [blame] | 190 | if(lthreads[new].state == STATE_RUNNABLE) { \ |
wdenk | b02744a | 2003-04-05 00:53:31 +0000 | [diff] [blame] | 191 | PDEBUG("thread_yield: %d match, ctx=0x%08x", \ |
wdenk | 874ac26 | 2003-07-24 23:38:38 +0000 | [diff] [blame] | 192 | new, \ |
| 193 | (unsigned)lthreads[current_tid].context); \ |
wdenk | 8dba050 | 2003-03-31 16:34:49 +0000 | [diff] [blame] | 194 | if(setjmp(lthreads[current_tid].context) == 0) { \ |
| 195 | current_tid = new; \ |
wdenk | b02744a | 2003-04-05 00:53:31 +0000 | [diff] [blame] | 196 | PDEBUG("thread_yield: tid %d returns 0", \ |
Wolfgang Denk | a1be476 | 2008-05-20 16:00:29 +0200 | [diff] [blame] | 197 | new); \ |
wdenk | 8dba050 | 2003-03-31 16:34:49 +0000 | [diff] [blame] | 198 | longjmp(lthreads[new].context, 1); \ |
| 199 | } else { \ |
wdenk | b02744a | 2003-04-05 00:53:31 +0000 | [diff] [blame] | 200 | PDEBUG("thread_yield: tid %d returns 1", \ |
Wolfgang Denk | a1be476 | 2008-05-20 16:00:29 +0200 | [diff] [blame] | 201 | new); \ |
wdenk | 8dba050 | 2003-03-31 16:34:49 +0000 | [diff] [blame] | 202 | return; \ |
| 203 | } \ |
| 204 | } |
| 205 | |
| 206 | for (i = current_tid + 1; i < MAX_THREADS; i++) { |
| 207 | SWITCH (i); |
| 208 | } |
| 209 | |
| 210 | if (current_tid != 0) { |
| 211 | for (i = 0; i <= current_tid; i++) { |
| 212 | SWITCH (i); |
| 213 | } |
| 214 | } |
| 215 | |
wdenk | b02744a | 2003-04-05 00:53:31 +0000 | [diff] [blame] | 216 | PDEBUG ("thread_yield: returning from thread_yield"); |
wdenk | 8dba050 | 2003-03-31 16:34:49 +0000 | [diff] [blame] | 217 | return; |
| 218 | } |
| 219 | |
| 220 | static int thread_create (int (*func) (void *), void *arg) |
| 221 | { |
| 222 | int i; |
| 223 | |
| 224 | for (i = MASTER_THREAD + 1; i < MAX_THREADS; i++) { |
| 225 | if (lthreads[i].state == STATE_EMPTY) { |
| 226 | lthreads[i].state = STATE_STOPPED; |
| 227 | lthreads[i].func = func; |
| 228 | lthreads[i].arg = arg; |
wdenk | b02744a | 2003-04-05 00:53:31 +0000 | [diff] [blame] | 229 | PDEBUG ("thread_create: returns new tid %d", i); |
wdenk | 8dba050 | 2003-03-31 16:34:49 +0000 | [diff] [blame] | 230 | return i; |
| 231 | } |
| 232 | } |
| 233 | |
wdenk | b02744a | 2003-04-05 00:53:31 +0000 | [diff] [blame] | 234 | PDEBUG ("thread_create: returns failure"); |
wdenk | 8dba050 | 2003-03-31 16:34:49 +0000 | [diff] [blame] | 235 | return RC_FAILURE; |
| 236 | } |
| 237 | |
| 238 | static int thread_delete (int id) |
| 239 | { |
| 240 | if (id <= MASTER_THREAD || id > MAX_THREADS) |
| 241 | return RC_FAILURE; |
| 242 | |
| 243 | if (current_tid == id) |
| 244 | return RC_FAILURE; |
| 245 | |
| 246 | lthreads[id].state = STATE_EMPTY; |
| 247 | return RC_SUCCESS; |
| 248 | } |
| 249 | |
| 250 | static void thread_launcher (void) |
| 251 | { |
wdenk | b02744a | 2003-04-05 00:53:31 +0000 | [diff] [blame] | 252 | PDEBUG ("thread_launcher: invoking func=0x%08x", |
wdenk | 874ac26 | 2003-07-24 23:38:38 +0000 | [diff] [blame] | 253 | (unsigned)lthreads[current_tid].func); |
wdenk | 8dba050 | 2003-03-31 16:34:49 +0000 | [diff] [blame] | 254 | |
| 255 | lthreads[current_tid].retval = |
wdenk | b02744a | 2003-04-05 00:53:31 +0000 | [diff] [blame] | 256 | lthreads[current_tid].func (lthreads[current_tid].arg); |
wdenk | 8dba050 | 2003-03-31 16:34:49 +0000 | [diff] [blame] | 257 | |
wdenk | b02744a | 2003-04-05 00:53:31 +0000 | [diff] [blame] | 258 | PDEBUG ("thread_launcher: tid %d terminated", current_tid); |
wdenk | 8dba050 | 2003-03-31 16:34:49 +0000 | [diff] [blame] | 259 | |
| 260 | lthreads[current_tid].state = STATE_TERMINATED; |
| 261 | thread_yield (); |
wdenk | 874ac26 | 2003-07-24 23:38:38 +0000 | [diff] [blame] | 262 | printf ("thread_launcher: should NEVER get here!\n"); |
wdenk | 8dba050 | 2003-03-31 16:34:49 +0000 | [diff] [blame] | 263 | |
| 264 | return; |
| 265 | } |
| 266 | |
| 267 | static int thread_start (int id) |
| 268 | { |
wdenk | b02744a | 2003-04-05 00:53:31 +0000 | [diff] [blame] | 269 | PDEBUG ("thread_start: id=%d", id); |
wdenk | 8dba050 | 2003-03-31 16:34:49 +0000 | [diff] [blame] | 270 | if (id <= MASTER_THREAD || id > MAX_THREADS) { |
| 271 | return RC_FAILURE; |
| 272 | } |
| 273 | |
| 274 | if (lthreads[id].state != STATE_STOPPED) |
| 275 | return RC_FAILURE; |
| 276 | |
| 277 | if (setjmp (lthreads[current_tid].context) == 0) { |
| 278 | lthreads[id].state = STATE_RUNNABLE; |
| 279 | current_tid = id; |
wdenk | 874ac26 | 2003-07-24 23:38:38 +0000 | [diff] [blame] | 280 | PDEBUG ("thread_start: to be stack=0%08x", |
| 281 | (unsigned)lthreads[id].stack); |
Wolfgang Denk | 7fb5266 | 2005-10-13 16:45:02 +0200 | [diff] [blame] | 282 | setctxsp ((vu_char *)<hreads[id].stack[STK_SIZE]); |
wdenk | 8dba050 | 2003-03-31 16:34:49 +0000 | [diff] [blame] | 283 | thread_launcher (); |
| 284 | } |
| 285 | |
wdenk | b02744a | 2003-04-05 00:53:31 +0000 | [diff] [blame] | 286 | PDEBUG ("thread_start: Thread id=%d started, parent returns", id); |
wdenk | 8dba050 | 2003-03-31 16:34:49 +0000 | [diff] [blame] | 287 | |
| 288 | return RC_SUCCESS; |
| 289 | } |
| 290 | |
wdenk | 874ac26 | 2003-07-24 23:38:38 +0000 | [diff] [blame] | 291 | #if 0 /* not used so far */ |
wdenk | 8dba050 | 2003-03-31 16:34:49 +0000 | [diff] [blame] | 292 | static int thread_stop (int id) |
| 293 | { |
| 294 | if (id <= MASTER_THREAD || id >= MAX_THREADS) |
| 295 | return RC_FAILURE; |
| 296 | |
| 297 | if (current_tid == id) |
| 298 | return RC_FAILURE; |
| 299 | |
| 300 | lthreads[id].state = STATE_STOPPED; |
| 301 | return RC_SUCCESS; |
| 302 | } |
wdenk | 874ac26 | 2003-07-24 23:38:38 +0000 | [diff] [blame] | 303 | #endif /* not used so far */ |
wdenk | 8dba050 | 2003-03-31 16:34:49 +0000 | [diff] [blame] | 304 | |
| 305 | static int thread_join (int *ret) |
| 306 | { |
| 307 | int i, j = 0; |
| 308 | |
wdenk | b02744a | 2003-04-05 00:53:31 +0000 | [diff] [blame] | 309 | PDEBUG ("thread_join: *ret = %d", *ret); |
wdenk | 8dba050 | 2003-03-31 16:34:49 +0000 | [diff] [blame] | 310 | |
| 311 | if (!(*ret == -1 || *ret > MASTER_THREAD || *ret < MAX_THREADS)) { |
wdenk | b02744a | 2003-04-05 00:53:31 +0000 | [diff] [blame] | 312 | PDEBUG ("thread_join: invalid tid %d", *ret); |
wdenk | 8dba050 | 2003-03-31 16:34:49 +0000 | [diff] [blame] | 313 | return RC_FAILURE; |
| 314 | } |
| 315 | |
| 316 | if (*ret == -1) { |
wdenk | b02744a | 2003-04-05 00:53:31 +0000 | [diff] [blame] | 317 | PDEBUG ("Checking for tid = -1"); |
wdenk | 8dba050 | 2003-03-31 16:34:49 +0000 | [diff] [blame] | 318 | while (1) { |
wdenk | b02744a | 2003-04-05 00:53:31 +0000 | [diff] [blame] | 319 | /* PDEBUG("thread_join: start while-loopn"); */ |
wdenk | 8dba050 | 2003-03-31 16:34:49 +0000 | [diff] [blame] | 320 | j = 0; |
| 321 | for (i = MASTER_THREAD + 1; i < MAX_THREADS; i++) { |
| 322 | if (lthreads[i].state == STATE_TERMINATED) { |
| 323 | *ret = lthreads[i].retval; |
| 324 | lthreads[i].state = STATE_EMPTY; |
wdenk | b02744a | 2003-04-05 00:53:31 +0000 | [diff] [blame] | 325 | /* PDEBUG("thread_join: returning retval %d of tid %d", |
| 326 | ret, i); */ |
wdenk | 8dba050 | 2003-03-31 16:34:49 +0000 | [diff] [blame] | 327 | return RC_SUCCESS; |
| 328 | } |
| 329 | |
| 330 | if (lthreads[i].state != STATE_EMPTY) { |
wdenk | b02744a | 2003-04-05 00:53:31 +0000 | [diff] [blame] | 331 | PDEBUG ("thread_join: %d used slots tid %d state=%d", |
| 332 | j, i, lthreads[i].state); |
wdenk | 8dba050 | 2003-03-31 16:34:49 +0000 | [diff] [blame] | 333 | j++; |
| 334 | } |
| 335 | } |
| 336 | if (j == 0) { |
wdenk | b02744a | 2003-04-05 00:53:31 +0000 | [diff] [blame] | 337 | PDEBUG ("thread_join: all slots empty!"); |
wdenk | 8dba050 | 2003-03-31 16:34:49 +0000 | [diff] [blame] | 338 | return RC_FAILURE; |
| 339 | } |
wdenk | b02744a | 2003-04-05 00:53:31 +0000 | [diff] [blame] | 340 | /* PDEBUG("thread_join: yielding"); */ |
wdenk | 8dba050 | 2003-03-31 16:34:49 +0000 | [diff] [blame] | 341 | thread_yield (); |
wdenk | b02744a | 2003-04-05 00:53:31 +0000 | [diff] [blame] | 342 | /* PDEBUG("thread_join: back from yield"); */ |
wdenk | 8dba050 | 2003-03-31 16:34:49 +0000 | [diff] [blame] | 343 | } |
| 344 | } |
| 345 | |
| 346 | if (lthreads[*ret].state == STATE_TERMINATED) { |
| 347 | i = *ret; |
| 348 | *ret = lthreads[*ret].retval; |
| 349 | lthreads[*ret].state = STATE_EMPTY; |
wdenk | b02744a | 2003-04-05 00:53:31 +0000 | [diff] [blame] | 350 | PDEBUG ("thread_join: returing %d for tid %d", *ret, i); |
wdenk | 8dba050 | 2003-03-31 16:34:49 +0000 | [diff] [blame] | 351 | return RC_SUCCESS; |
| 352 | } |
| 353 | |
wdenk | b02744a | 2003-04-05 00:53:31 +0000 | [diff] [blame] | 354 | PDEBUG ("thread_join: thread %d is not terminated!", *ret); |
wdenk | 8dba050 | 2003-03-31 16:34:49 +0000 | [diff] [blame] | 355 | return RC_FAILURE; |
| 356 | } |