Changeset 55ab0f1 in mainline


Ignore:
Timestamp:
2006-02-04T18:15:13Z (19 years ago)
Author:
Ondrej Palkovsky <ondrap@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
04225a7
Parents:
428aabf
Message:

added thread list to kconsole.

Location:
generic
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • generic/include/proc/thread.h

    r428aabf r55ab0f1  
    134134
    135135extern void thread_register_call_me(void (* call_me)(void *), void *call_me_with);
     136extern void thread_print_list(void);
    136137
    137138#endif
  • generic/src/console/cmd.c

    r428aabf r55ab0f1  
    5353#include <mm/slab.h>
    5454#include <proc/scheduler.h>
     55#include <proc/thread.h>
    5556
    5657/** Data and methods for 'help' command. */
     
    245246};
    246247
     248static int cmd_threads(cmd_arg_t *argv);
     249static cmd_info_t threads_info = {
     250        .name = "threads",
     251        .description = "List all threads",
     252        .func = cmd_threads,
     253        .argc = 0
     254};
     255
    247256
    248257static int cmd_sched(cmd_arg_t *argv);
     
    321330        &symaddr_info,
    322331        &sched_info,
     332        &threads_info,
    323333        &tlb_info,
    324334        &version_info,
     
    598608}
    599609
     610
     611/** Command for listings Thread information
     612 *
     613 * @param argv Ignores
     614 *
     615 * @return Always 1
     616 */
     617int cmd_threads(cmd_arg_t * argv) {
     618        thread_print_list();
     619        return 1;
     620}
     621
    600622/** Command for listings Thread information
    601623 *
  • generic/src/proc/thread.c

    r428aabf r55ab0f1  
    5252#include <arch/atomic.h>
    5353#include <memstr.h>
     54#include <print.h>
    5455
    5556char *thread_states[] = {"Invalid", "Running", "Sleeping", "Ready", "Entering", "Exiting"}; /**< Thread states */
     
    319320        interrupts_restore(ipl);
    320321}
     322
     323/** Print list of threads debug info */
     324void thread_print_list(void)
     325{
     326        link_t *cur;
     327        thread_t *t;
     328        ipl_t ipl;
     329       
     330        /* Messing with thread structures, avoid deadlock */
     331        ipl = interrupts_disable();
     332        spinlock_lock(&threads_lock);
     333
     334        for (cur=threads_head.next; cur!=&threads_head; cur=cur->next) {
     335                t = list_get_instance(cur, thread_t, threads_link);
     336                printf("Thr: %d(%s) ", t->tid, thread_states[t->state]);
     337                if (t->cpu)
     338                        printf("cpu%d ", t->cpu->id);
     339               
     340                printf("\n");
     341        }
     342
     343        spinlock_unlock(&threads_lock);
     344        interrupts_enable();
     345}
Note: See TracChangeset for help on using the changeset viewer.