Rev 3426 | Rev 3597 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 3426 | Rev 3431 | ||
---|---|---|---|
Line 178... | Line 178... | ||
178 | slab_free(fpu_context_slab, t->saved_fpu_context); |
178 | slab_free(fpu_context_slab, t->saved_fpu_context); |
179 | #endif |
179 | #endif |
180 | return -1; |
180 | return -1; |
181 | } |
181 | } |
182 | 182 | ||
- | 183 | #ifdef CONFIG_UDEBUG |
|
183 | mutex_initialize(&t->udebug.lock, MUTEX_PASSIVE); |
184 | mutex_initialize(&t->udebug.lock, MUTEX_PASSIVE); |
- | 185 | #endif |
|
184 | 186 | ||
185 | return 0; |
187 | return 0; |
186 | } |
188 | } |
187 | 189 | ||
188 | /** Destruction of thread_t object */ |
190 | /** Destruction of thread_t object */ |
Line 346... | Line 348... | ||
346 | t->fpu_context_exists = 0; |
348 | t->fpu_context_exists = 0; |
347 | t->fpu_context_engaged = 0; |
349 | t->fpu_context_engaged = 0; |
348 | 350 | ||
349 | avltree_node_initialize(&t->threads_tree_node); |
351 | avltree_node_initialize(&t->threads_tree_node); |
350 | t->threads_tree_node.key = (uintptr_t) t; |
352 | t->threads_tree_node.key = (uintptr_t) t; |
351 | 353 | ||
- | 354 | #ifdef CONFIG_UDEBUG |
|
352 | /* Init debugging stuff */ |
355 | /* Init debugging stuff */ |
353 | udebug_thread_initialize(&t->udebug); |
356 | udebug_thread_initialize(&t->udebug); |
- | 357 | #endif |
|
354 | 358 | ||
355 | /* might depend on previous initialization */ |
359 | /* might depend on previous initialization */ |
356 | thread_create_arch(t); |
360 | thread_create_arch(t); |
357 | 361 | ||
358 | if (!(flags & THREAD_FLAG_NOATTACH)) |
362 | if (!(flags & THREAD_FLAG_NOATTACH)) |
Line 416... | Line 420... | ||
416 | /* |
420 | /* |
417 | * Attach to the specified task. |
421 | * Attach to the specified task. |
418 | */ |
422 | */ |
419 | ipl = interrupts_disable(); |
423 | ipl = interrupts_disable(); |
420 | spinlock_lock(&task->lock); |
424 | spinlock_lock(&task->lock); |
- | 425 | ||
421 | atomic_inc(&task->refcount); |
426 | atomic_inc(&task->refcount); |
- | 427 | ||
422 | /* Must not count kbox thread into lifecount */ |
428 | /* Must not count kbox thread into lifecount */ |
423 | if (t->flags & THREAD_FLAG_USPACE) |
429 | if (t->flags & THREAD_FLAG_USPACE) |
424 | atomic_inc(&task->lifecount); |
430 | atomic_inc(&task->lifecount); |
- | 431 | ||
425 | list_append(&t->th_link, &task->th_head); |
432 | list_append(&t->th_link, &task->th_head); |
426 | spinlock_unlock(&task->lock); |
433 | spinlock_unlock(&task->lock); |
427 | 434 | ||
428 | /* |
435 | /* |
429 | * Register this thread in the system-wide list. |
436 | * Register this thread in the system-wide list. |
Line 443... | Line 450... | ||
443 | void thread_exit(void) |
450 | void thread_exit(void) |
444 | { |
451 | { |
445 | ipl_t ipl; |
452 | ipl_t ipl; |
446 | 453 | ||
447 | if (THREAD->flags & THREAD_FLAG_USPACE) { |
454 | if (THREAD->flags & THREAD_FLAG_USPACE) { |
- | 455 | #ifdef CONFIG_UDEBUG |
|
448 | /* Generate udebug THREAD_E event */ |
456 | /* Generate udebug THREAD_E event */ |
449 | udebug_thread_e_event(); |
457 | udebug_thread_e_event(); |
450 | 458 | #endif |
|
451 | if (atomic_predec(&TASK->lifecount) == 0) { |
459 | if (atomic_predec(&TASK->lifecount) == 0) { |
452 | /* |
460 | /* |
453 | * We are the last userspace thread in the task that |
461 | * We are the last userspace thread in the task that |
454 | * still has not exited. With the exception of the |
462 | * still has not exited. With the exception of the |
455 | * moment the task was created, new userspace threads |
463 | * moment the task was created, new userspace threads |
Line 750... | Line 758... | ||
750 | } |
758 | } |
751 | } |
759 | } |
752 | thread_attach(t, TASK); |
760 | thread_attach(t, TASK); |
753 | thread_ready(t); |
761 | thread_ready(t); |
754 | 762 | ||
- | 763 | #ifdef CONFIG_UDEBUG |
|
755 | /* Generate udebug THREAD_B event */ |
764 | /* Generate udebug THREAD_B event */ |
756 | udebug_thread_b_event(t); |
765 | udebug_thread_b_event(t); |
- | 766 | #endif |
|
757 | 767 | ||
758 | return 0; |
768 | return 0; |
759 | } else |
769 | } else |
760 | free(kernel_uarg); |
770 | free(kernel_uarg); |
761 | 771 |