diff options
| author | shaojinchun <[email protected]> | 2018-11-22 14:40:43 +0800 |
|---|---|---|
| committer | shaojinchun <[email protected]> | 2018-11-22 18:16:47 +0800 |
| commit | fc6bc1ad398d5fa2085320cab6cc33905f5f943d (patch) | |
| tree | a6a24a6e516add6fe47fa5a58f7307ee0cd3f6e8 /components | |
| parent | 8ea5b770117cacea7f17b2b08305f360ed71bca7 (diff) | |
Add smp support to RT-Thread 4.0
Diffstat (limited to 'components')
| -rw-r--r-- | components/finsh/cmd.c | 23 |
1 files changed, 21 insertions, 2 deletions
diff --git a/components/finsh/cmd.c b/components/finsh/cmd.c index 41e8a01f41..0c06303b14 100644 --- a/components/finsh/cmd.c +++ b/components/finsh/cmd.c @@ -25,8 +25,10 @@ * 2012-06-02 lgnq add list_memheap * 2012-10-22 Bernard add MS VC++ patch. * 2016-06-02 armink beautify the list_thread command + * 2018-11-22 Jesven list_thread add smp support */ +#include <rthw.h> #include <rtthread.h> #ifdef RT_USING_FINSH @@ -87,14 +89,26 @@ static long _list_thread(struct rt_list_node *list) maxlen = object_name_maxlen(item_title, list); +#ifdef RT_USING_SMP + rt_kprintf("%-*.s cpu pri status sp stack size max used left tick error\n", maxlen, item_title); object_split(maxlen); + rt_kprintf( " --- --- ------- ---------- ---------- ------ ---------- ---\n"); +#else rt_kprintf("%-*.s pri status sp stack size max used left tick error\n", maxlen, item_title); object_split(maxlen); rt_kprintf( " --- ------- ---------- ---------- ------ ---------- ---\n"); +#endif /*RT_USING_SMP*/ for (node = list->next; node != list; node = node->next) { rt_uint8_t stat; thread = rt_list_entry(node, struct rt_thread, list); - rt_kprintf("%-*.*s %3d ", maxlen, RT_NAME_MAX, thread->name, thread->current_priority); +#ifdef RT_USING_SMP + if (thread->oncpu != RT_CPU_DETACHED) + rt_kprintf("%-*.*s %3d %3d ", maxlen, RT_NAME_MAX, thread->name, thread->oncpu, thread->current_priority); + else + rt_kprintf("%-*.*s N/A %3d ", maxlen, RT_NAME_MAX, thread->name, thread->current_priority); +#else + rt_kprintf("%-*.*s %3d ", maxlen, RT_NAME_MAX, thread->name, thread->current_priority); +#endif /*RT_USING_SMP*/ stat = (thread->stat & RT_THREAD_STAT_MASK); if (stat == RT_THREAD_READY) rt_kprintf(" ready "); else if (stat == RT_THREAD_SUSPEND) rt_kprintf(" suspend"); @@ -130,10 +144,15 @@ static long _list_thread(struct rt_list_node *list) long list_thread(void) { + rt_ubase_t level; struct rt_object_information *info; + long ret; + level = rt_hw_interrupt_disable(); info = rt_object_get_information(RT_Object_Class_Thread); - return _list_thread(&info->object_list); + ret = _list_thread(&info->object_list); + rt_hw_interrupt_enable(level); + return ret; } FINSH_FUNCTION_EXPORT(list_thread, list thread); MSH_CMD_EXPORT(list_thread, list thread); |
