From cd793d257b94087b4be7cb58624ab545ccfa7f82 Mon Sep 17 00:00:00 2001 From: "bernard.xiong" Date: Wed, 24 Feb 2010 16:06:52 +0000 Subject: [PATCH] display suspend thread when list message queue information. git-svn-id: https://rt-thread.googlecode.com/svn/trunk@445 bbd45198-f89e-11dd-88c7-29a3b14d5316 --- finsh/cmd.c | 58 ++++++++++++++++++++++++++++++----------------------- 1 file changed, 33 insertions(+), 25 deletions(-) diff --git a/finsh/cmd.c b/finsh/cmd.c index 639fd2061..15e9a08ce 100644 --- a/finsh/cmd.c +++ b/finsh/cmd.c @@ -27,25 +27,25 @@ */ #include -#include "finsh.h" - -// Copy from kservice.h because we can not use it out of the kernel. -// Ugly. Should let kservice.h avaliable for applications? +#include "finsh.h" + +// Copy from kservice.h because we can not use it out of the kernel. +// Ugly. Should let kservice.h avaliable for applications? rt_inline int rt_list_isempty(const rt_list_t *l) { return l->next == l; -} - -rt_inline unsigned int rt_list_len(const rt_list_t *l) -{ - unsigned int len = 0; - const rt_list_t *p = l; - while( p->next != l ) - { - p = p->next; - len++; - } - return len; +} + +rt_inline unsigned int rt_list_len(const rt_list_t *l) +{ + unsigned int len = 0; + const rt_list_t *p = l; + while( p->next != l ) + { + p = p->next; + len++; + } + return len; } long hello() @@ -54,7 +54,7 @@ long hello() return 0; } -FINSH_FUNCTION_EXPORT(hello, say hello world) +FINSH_FUNCTION_EXPORT(hello, say hello world); extern void rt_show_version(void); long version() @@ -63,7 +63,7 @@ long version() return 0; } -FINSH_FUNCTION_EXPORT(version, show RT-Thread version information) +FINSH_FUNCTION_EXPORT(version, show RT-Thread version information); #define rt_list_entry(node, type, member) \ ((type *)((char *)(node) - (unsigned long)(&((type *)0)->member))) @@ -101,7 +101,7 @@ int list_thread() } return 0; } -FINSH_FUNCTION_EXPORT(list_thread, list thread) +FINSH_FUNCTION_EXPORT(list_thread, list thread); static void show_wait_queue(struct rt_list_node* list) { @@ -128,7 +128,7 @@ int list_sem() rt_kprintf("-------- --- --------------\n"); for (node = list->next; node != list; node = node->next) { - sem = (struct rt_semaphore*)(rt_list_entry(node, struct rt_object, list)); + sem = (struct rt_semaphore*)(rt_list_entry(node, struct rt_object, list)); if( !rt_list_isempty(&sem->parent.suspend_thread) ) { rt_kprintf("%-8s %03d %d:", sem->parent.parent.name, sem->value, rt_list_len(&sem->parent.suspend_thread) ); @@ -200,7 +200,7 @@ int list_mailbox() rt_kprintf("-------- ---- ---- --------------\n"); for (node = list->next; node != list; node = node->next) { - m = (struct rt_mailbox*)(rt_list_entry(node, struct rt_object, list)); + m = (struct rt_mailbox*)(rt_list_entry(node, struct rt_object, list)); if( !rt_list_isempty(&m->parent.suspend_thread) ) { rt_kprintf("%-8s %04d %04d %d:", m->parent.parent.name, m->entry, m->size, rt_list_len(&m->parent.suspend_thread)); @@ -231,7 +231,16 @@ int list_msgqueue() for (node = list->next; node != list; node = node->next) { m = (struct rt_messagequeue*)(rt_list_entry(node, struct rt_object, list)); - rt_kprintf("%-8s %04d %d\n", m->parent.parent.name, m->entry, rt_list_len(&m->parent.suspend_thread)); + if( !rt_list_isempty(&m->parent.suspend_thread) ) + { + rt_kprintf("%-8s %04d %d:", m->parent.parent.name, m->entry, rt_list_len(&m->parent.suspend_thread)); + show_wait_queue(&(m->parent.suspend_thread)); + rt_kprintf("\n"); + } + else + { + rt_kprintf("%-8s %04d %d\n", m->parent.parent.name, m->entry, rt_list_len(&m->parent.suspend_thread)); + } } return 0; @@ -243,7 +252,6 @@ FINSH_FUNCTION_EXPORT(list_msgqueue, list message queue in system) int list_mempool() { struct rt_mempool *mp; - struct rt_list_node *list, *node; list = &rt_object_container[RT_Object_Class_MemPool].object_list; @@ -398,8 +406,8 @@ void list_prefix(char* prefix) const char* name_ptr; func_cnt = 0; - var_cnt = 0; - name_ptr = RT_NULL; + var_cnt = 0; + name_ptr = RT_NULL; { struct finsh_syscall* index; -- GitLab