/kernel/trunk/generic/src/console/cmd.c |
---|
52,6 → 52,7 |
#include <main/version.h> |
#include <mm/slab.h> |
#include <proc/scheduler.h> |
#include <proc/thread.h> |
/** Data and methods for 'help' command. */ |
static int cmd_help(cmd_arg_t *argv); |
244,7 → 245,15 |
.argv = NULL |
}; |
static int cmd_threads(cmd_arg_t *argv); |
static cmd_info_t threads_info = { |
.name = "threads", |
.description = "List all threads", |
.func = cmd_threads, |
.argc = 0 |
}; |
static int cmd_sched(cmd_arg_t *argv); |
static cmd_info_t sched_info = { |
.name = "scheduler", |
320,6 → 329,7 |
&slabs_info, |
&symaddr_info, |
&sched_info, |
&threads_info, |
&tlb_info, |
&version_info, |
&zones_info, |
597,6 → 607,7 |
return 1; |
} |
/** Command for listings Thread information |
* |
* @param argv Ignores |
603,6 → 614,17 |
* |
* @return Always 1 |
*/ |
int cmd_threads(cmd_arg_t * argv) { |
thread_print_list(); |
return 1; |
} |
/** Command for listings Thread information |
* |
* @param argv Ignores |
* |
* @return Always 1 |
*/ |
int cmd_sched(cmd_arg_t * argv) { |
sched_print_list(); |
return 1; |
/kernel/trunk/generic/src/proc/thread.c |
---|
51,6 → 51,7 |
#include <arch/faddr.h> |
#include <arch/atomic.h> |
#include <memstr.h> |
#include <print.h> |
char *thread_states[] = {"Invalid", "Running", "Sleeping", "Ready", "Entering", "Exiting"}; /**< Thread states */ |
318,3 → 319,27 |
spinlock_unlock(&THREAD->lock); |
interrupts_restore(ipl); |
} |
/** Print list of threads debug info */ |
void thread_print_list(void) |
{ |
link_t *cur; |
thread_t *t; |
ipl_t ipl; |
/* Messing with thread structures, avoid deadlock */ |
ipl = interrupts_disable(); |
spinlock_lock(&threads_lock); |
for (cur=threads_head.next; cur!=&threads_head; cur=cur->next) { |
t = list_get_instance(cur, thread_t, threads_link); |
printf("Thr: %d(%s) ", t->tid, thread_states[t->state]); |
if (t->cpu) |
printf("cpu%d ", t->cpu->id); |
printf("\n"); |
} |
spinlock_unlock(&threads_lock); |
interrupts_enable(); |
} |