Changes in kernel/generic/src/proc/thread.c [96b02eb9:ae0300b5] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/generic/src/proc/thread.c
r96b02eb9 rae0300b5 239 239 * Switch thread to the ready state. 240 240 * 241 * @param t Thread to make ready.241 * @param thread Thread to make ready. 242 242 * 243 243 */ … … 246 246 irq_spinlock_lock(&thread->lock, true); 247 247 248 ASSERT( !(thread->state == Ready));248 ASSERT(thread->state != Ready); 249 249 250 250 int i = (thread->priority < RQ_COUNT - 1) … … 350 350 351 351 #ifdef CONFIG_UDEBUG 352 /* Init debugging stuff */ 352 /* Initialize debugging stuff */ 353 thread->btrace = false; 353 354 udebug_thread_initialize(&thread->udebug); 354 355 #endif … … 535 536 /** Detach thread. 536 537 * 537 * Mark the thread as detached , if the thread is already in the Lingering538 * state, deallocate its resources.538 * Mark the thread as detached. If the thread is already 539 * in the Lingering state, deallocate its resources. 539 540 * 540 541 * @param thread Thread to be detached. … … 590 591 order_suffix(thread->kcycles, &kcycles, &ksuffix); 591 592 593 char *name; 594 if (str_cmp(thread->name, "uinit") == 0) 595 name = thread->task->name; 596 else 597 name = thread->name; 598 592 599 #ifdef __32_BITS__ 593 600 if (*additional) 594 printf("%-8" PRIu64 "%10p %9" PRIu64 "%c %9" PRIu64 "%c ",595 thread->tid, thread-> kstack, ucycles, usuffix,596 kcycles, ksuffix);601 printf("%-8" PRIu64 " %10p %10p %9" PRIu64 "%c %9" PRIu64 "%c ", 602 thread->tid, thread->thread_code, thread->kstack, 603 ucycles, usuffix, kcycles, ksuffix); 597 604 else 598 printf("%-8" PRIu64 " %-14s %10p %-8s %10p %-5" PRIu32 " %10p\n",599 thread->tid, thread->name, thread, thread_states[thread->state],600 thread->task, thread->task->context , thread->thread_code);605 printf("%-8" PRIu64 " %-14s %10p %-8s %10p %-5" PRIu32 "\n", 606 thread->tid, name, thread, thread_states[thread->state], 607 thread->task, thread->task->context); 601 608 #endif 602 609 603 610 #ifdef __64_BITS__ 604 611 if (*additional) 605 printf("%-8" PRIu64 " %18p %18p\n"612 printf("%-8" PRIu64 " %18p %18p\n" 606 613 " %9" PRIu64 "%c %9" PRIu64 "%c ", 607 614 thread->tid, thread->thread_code, thread->kstack, 608 615 ucycles, usuffix, kcycles, ksuffix); 609 616 else 610 printf("%-8" PRIu64 " %-14s %18p %-8s %18p %-5" PRIu32 "\n",611 thread->tid, thread->name, thread, thread_states[thread->state],617 printf("%-8" PRIu64 " %-14s %18p %-8s %18p %-5" PRIu32 "\n", 618 thread->tid, name, thread, thread_states[thread->state], 612 619 thread->task, thread->task->context); 613 620 #endif … … 647 654 #ifdef __32_BITS__ 648 655 if (additional) 649 printf("[id ] [ stack ] [ucycles ] [kcycles ] [cpu]"650 " [ waitqueue]\n");656 printf("[id ] [code ] [stack ] [ucycles ] [kcycles ]" 657 " [cpu] [waitqueue]\n"); 651 658 else 652 659 printf("[id ] [name ] [address ] [state ] [task ]" 653 " [ctx] [code ]\n");660 " [ctx]\n"); 654 661 #endif 655 662 … … 740 747 ASSERT(interrupts_disabled()); 741 748 ASSERT(irq_spinlock_locked(&threads_lock)); 742 749 743 750 thread_iterator_t iterator; 744 751 … … 751 758 } 752 759 760 #ifdef CONFIG_UDEBUG 761 762 void thread_stack_trace(thread_id_t thread_id) 763 { 764 irq_spinlock_lock(&threads_lock, true); 765 766 thread_t *thread = thread_find_by_id(thread_id); 767 if (thread == NULL) { 768 printf("No such thread.\n"); 769 irq_spinlock_unlock(&threads_lock, true); 770 return; 771 } 772 773 irq_spinlock_lock(&thread->lock, false); 774 775 /* 776 * Schedule a stack trace to be printed 777 * just before the thread is scheduled next. 778 * 779 * If the thread is sleeping then try to interrupt 780 * the sleep. Any request for printing an uspace stack 781 * trace from within the kernel should be always 782 * considered a last resort debugging means, therefore 783 * forcing the thread's sleep to be interrupted 784 * is probably justifiable. 785 */ 786 787 bool sleeping = false; 788 istate_t *istate = thread->udebug.uspace_state; 789 if (istate != NULL) { 790 printf("Scheduling thread stack trace.\n"); 791 thread->btrace = true; 792 if (thread->state == Sleeping) 793 sleeping = true; 794 } else 795 printf("Thread interrupt state not available.\n"); 796 797 irq_spinlock_unlock(&thread->lock, false); 798 799 if (sleeping) 800 waitq_interrupt_sleep(thread); 801 802 irq_spinlock_unlock(&threads_lock, true); 803 } 804 805 #endif /* CONFIG_UDEBUG */ 753 806 754 807 /** Process syscall to create new thread. … … 793 846 * has already been created. We need to undo its 794 847 * creation now. 795 *796 848 */ 797 849 … … 815 867 * THREAD_B events for threads that already existed 816 868 * and could be detected with THREAD_READ before. 817 *818 869 */ 819 870 udebug_thread_b_event_attach(thread, TASK);
Note:
See TracChangeset
for help on using the changeset viewer.