Rev 1060 | Rev 1066 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
| Rev 1060 | Rev 1062 | ||
|---|---|---|---|
| Line 246... | Line 246... | ||
| 246 | * |
246 | * |
| 247 | * @param func Thread's implementing function. |
247 | * @param func Thread's implementing function. |
| 248 | * @param arg Thread's implementing function argument. |
248 | * @param arg Thread's implementing function argument. |
| 249 | * @param task Task to which the thread belongs. |
249 | * @param task Task to which the thread belongs. |
| 250 | * @param flags Thread flags. |
250 | * @param flags Thread flags. |
| - | 251 | * @param name Symbolic name. |
|
| 251 | * |
252 | * |
| 252 | * @return New thread's structure on success, NULL on failure. |
253 | * @return New thread's structure on success, NULL on failure. |
| 253 | * |
254 | * |
| 254 | */ |
255 | */ |
| 255 | thread_t *thread_create(void (* func)(void *), void *arg, task_t *task, int flags) |
256 | thread_t *thread_create(void (* func)(void *), void *arg, task_t *task, int flags, char *name) |
| 256 | { |
257 | { |
| 257 | thread_t *t; |
258 | thread_t *t; |
| 258 | ipl_t ipl; |
259 | ipl_t ipl; |
| 259 | 260 | ||
| 260 | t = (thread_t *) slab_alloc(thread_slab, 0); |
261 | t = (thread_t *) slab_alloc(thread_slab, 0); |
| Line 277... | Line 278... | ||
| 277 | 278 | ||
| 278 | ipl = interrupts_disable(); |
279 | ipl = interrupts_disable(); |
| 279 | t->saved_context.ipl = interrupts_read(); |
280 | t->saved_context.ipl = interrupts_read(); |
| 280 | interrupts_restore(ipl); |
281 | interrupts_restore(ipl); |
| 281 | 282 | ||
| - | 283 | t->name = name; |
|
| 282 | t->thread_code = func; |
284 | t->thread_code = func; |
| 283 | t->thread_arg = arg; |
285 | t->thread_arg = arg; |
| 284 | t->ticks = -1; |
286 | t->ticks = -1; |
| 285 | t->priority = -1; /* start in rq[0] */ |
287 | t->priority = -1; /* start in rq[0] */ |
| 286 | t->cpu = NULL; |
288 | t->cpu = NULL; |
| Line 407... | Line 409... | ||
| 407 | ipl = interrupts_disable(); |
409 | ipl = interrupts_disable(); |
| 408 | spinlock_lock(&threads_lock); |
410 | spinlock_lock(&threads_lock); |
| 409 | 411 | ||
| 410 | for (cur=threads_head.next; cur!=&threads_head; cur=cur->next) { |
412 | for (cur=threads_head.next; cur!=&threads_head; cur=cur->next) { |
| 411 | t = list_get_instance(cur, thread_t, threads_link); |
413 | t = list_get_instance(cur, thread_t, threads_link); |
| 412 | printf("Thr: %d(%s) ", t->tid, thread_states[t->state]); |
414 | printf("%s: address=%P, tid=%d, state=%s, task=%P, code=%P, stack=%P, cpu=", |
| - | 415 | t->name, t, t->tid, thread_states[t->state], t->task, t->thread_code, t->kstack); |
|
| 413 | if (t->cpu) |
416 | if (t->cpu) |
| 414 | printf("cpu%d ", t->cpu->id); |
417 | printf("cpu%d ", t->cpu->id); |
| - | 418 | else |
|
| - | 419 | printf("none"); |
|
| 415 | printf("\n"); |
420 | printf("\n"); |
| 416 | } |
421 | } |
| 417 | 422 | ||
| 418 | spinlock_unlock(&threads_lock); |
423 | spinlock_unlock(&threads_lock); |
| 419 | interrupts_restore(ipl); |
424 | interrupts_restore(ipl); |