Changeset 4687fcd4 in mainline for kernel/generic/src/proc/thread.c


Ignore:
Timestamp:
2011-01-29T10:19:04Z (13 years ago)
Author:
Jan Vesely <jano.vesely@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
72e19f50
Parents:
67a1b78 (diff), a09128c (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Changes from devel, break stuff.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • kernel/generic/src/proc/thread.c

    r67a1b78 r4687fcd4  
    239239 * Switch thread to the ready state.
    240240 *
    241  * @param t Thread to make ready.
     241 * @param thread Thread to make ready.
    242242 *
    243243 */
     
    246246        irq_spinlock_lock(&thread->lock, true);
    247247       
    248         ASSERT(!(thread->state == Ready));
     248        ASSERT(thread->state != Ready);
    249249       
    250250        int i = (thread->priority < RQ_COUNT - 1)
     
    350350       
    351351#ifdef CONFIG_UDEBUG
    352         /* Init debugging stuff */
     352        /* Initialize debugging stuff */
     353        thread->btrace = false;
    353354        udebug_thread_initialize(&thread->udebug);
    354355#endif
     
    535536/** Detach thread.
    536537 *
    537  * Mark the thread as detached, if the thread is already in the Lingering
    538  * state, deallocate its resources.
     538 * Mark the thread as detached. If the thread is already
     539 * in the Lingering state, deallocate its resources.
    539540 *
    540541 * @param thread Thread to be detached.
     
    590591        order_suffix(thread->kcycles, &kcycles, &ksuffix);
    591592       
     593        char *name;
     594        if (str_cmp(thread->name, "uinit") == 0)
     595                name = thread->task->name;
     596        else
     597                name = thread->name;
     598       
    592599#ifdef __32_BITS__
    593600        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);
    597604        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);
    601608#endif
    602609       
    603610#ifdef __64_BITS__
    604611        if (*additional)
    605                 printf("%-8" PRIu64" %18p %18p\n"
     612                printf("%-8" PRIu64 " %18p %18p\n"
    606613                    "         %9" PRIu64 "%c %9" PRIu64 "%c ",
    607614                    thread->tid, thread->thread_code, thread->kstack,
    608615                    ucycles, usuffix, kcycles, ksuffix);
    609616        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],
    612619                    thread->task, thread->task->context);
    613620#endif
     
    647654#ifdef __32_BITS__
    648655        if (additional)
    649                 printf("[id    ] [stack   ] [ucycles ] [kcycles ] [cpu]"
    650                     " [waitqueue]\n");
     656                printf("[id    ] [code    ] [stack   ] [ucycles ] [kcycles ]"
     657                    " [cpu] [waitqueue]\n");
    651658        else
    652659                printf("[id    ] [name        ] [address ] [state ] [task    ]"
    653                     " [ctx] [code    ]\n");
     660                    " [ctx]\n");
    654661#endif
    655662       
     
    740747        ASSERT(interrupts_disabled());
    741748        ASSERT(irq_spinlock_locked(&threads_lock));
    742 
     749       
    743750        thread_iterator_t iterator;
    744751       
     
    751758}
    752759
     760#ifdef CONFIG_UDEBUG
     761
     762void 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 */
    753806
    754807/** Process syscall to create new thread.
     
    793846                                 * has already been created. We need to undo its
    794847                                 * creation now.
    795                                  *
    796848                                 */
    797849                               
     
    815867                 * THREAD_B events for threads that already existed
    816868                 * and could be detected with THREAD_READ before.
    817                  *
    818869                 */
    819870                udebug_thread_b_event_attach(thread, TASK);
Note: See TracChangeset for help on using the changeset viewer.