From 93f3cb30e48d5de341bda09fa806120e2bc3f3ad Mon Sep 17 00:00:00 2001 From: Shicheng Chu <1468559561@qq.com> Date: Tue, 4 Apr 2023 21:06:27 +0800 Subject: [PATCH] =?UTF-8?q?[kernel]=20=E5=B0=86rt=5Fthread=E7=BB=93?= =?UTF-8?q?=E6=9E=84=E4=BD=93=E6=94=B9=E4=B8=BA=E6=98=BE=E5=BC=8F=E7=BB=A7?= =?UTF-8?q?=E6=89=BFrt=5Fobject=20(#7131)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- bsp/allwinner_tina/libcpu/trap.c | 6 ++-- bsp/bluetrum/ab32vg1-ab-prougen/board/board.c | 2 +- bsp/dm365/platform/trap.c | 6 ++-- bsp/raspberry-pico/libcpu/cpuport.c | 4 +-- bsp/simulator/drivers/module_win32.c | 8 ++--- bsp/taihu/applications/application.c | 8 ++--- bsp/w60x/drivers/board.c | 2 +- components/finsh/cmd.c | 12 +++---- components/libc/compilers/common/cstdlib.c | 2 +- components/libc/posix/libdl/dlmodule.c | 10 +++--- components/lwp/arch/x86/i386/lwp_arch.c | 4 +-- components/lwp/lwp.c | 2 +- components/lwp/lwp_pid.c | 8 ++--- components/lwp/lwp_syscall.c | 8 ++--- components/net/lwip/port/sys_arch.c | 2 +- components/utilities/ulog/syslog/syslog.c | 2 +- components/utilities/ulog/ulog.c | 2 +- components/vbus/watermark_queue.c | 2 +- include/rtdef.h | 19 +--------- libcpu/aarch64/common/trap.c | 4 +-- libcpu/arm/AT91SAM7X/trap.c | 2 +- libcpu/arm/am335x/trap.c | 6 ++-- libcpu/arm/arm926/trap.c | 6 ++-- libcpu/arm/cortex-m0/cpuport.c | 2 +- libcpu/arm/cortex-m23/cpuport.c | 2 +- libcpu/arm/cortex-m3/cpuport.c | 2 +- libcpu/arm/cortex-m33/cpuport.c | 2 +- libcpu/arm/cortex-m4/cpuport.c | 2 +- libcpu/arm/cortex-m7/cpuport.c | 2 +- libcpu/arm/cortex-r4/trap.c | 2 +- libcpu/arm/lpc24xx/trap.c | 10 +++--- libcpu/arm/s3c24x0/trap.c | 6 ++-- libcpu/arm/sep4020/trap.c | 6 ++-- libcpu/risc-v/k210/interrupt.c | 2 +- libcpu/risc-v/t-head/c906/backtrace.c | 2 +- libcpu/risc-v/t-head/c906/trap.c | 4 +-- libcpu/risc-v/virt64/backtrace.c | 2 +- libcpu/risc-v/virt64/trap.c | 4 +-- libcpu/rx/cpuport.c | 2 +- libcpu/sim/posix/cpu_port.c | 4 +-- libcpu/sim/win32/cpu_port.c | 2 +- libcpu/unicore32/sep6200/trap.c | 6 ++-- src/idle.c | 2 +- src/ipc.c | 36 +++++++++---------- src/mem.c | 2 +- src/memheap.c | 2 +- src/scheduler_mp.c | 14 ++++---- src/scheduler_up.c | 14 ++++---- src/thread.c | 10 +++--- 49 files changed, 126 insertions(+), 145 deletions(-) diff --git a/bsp/allwinner_tina/libcpu/trap.c b/bsp/allwinner_tina/libcpu/trap.c index 2017f33759..69fdc7c5f5 100644 --- a/bsp/allwinner_tina/libcpu/trap.c +++ b/bsp/allwinner_tina/libcpu/trap.c @@ -87,7 +87,7 @@ void rt_hw_trap_udef(struct rt_hw_register *regs) rt_hw_show_register(regs); rt_kprintf("undefined instruction\n"); - rt_kprintf("thread - %s stack:\n", rt_current_thread->name); + rt_kprintf("thread - %s stack:\n", rt_current_thread->parent.name); #if defined(RT_USING_FINSH) && defined(MSH_USING_BUILT_IN_COMMANDS) list_thread(); @@ -139,7 +139,7 @@ void rt_hw_trap_pabt(struct rt_hw_register *regs) rt_hw_show_register(regs); rt_kprintf("prefetch abort\n"); - rt_kprintf("thread - %s stack:\n", RT_NAME_MAX, rt_current_thread->name); + rt_kprintf("thread - %s stack:\n", RT_NAME_MAX, rt_current_thread->parent.name); #if defined(RT_USING_FINSH) && defined(MSH_USING_BUILT_IN_COMMANDS) list_thread(); @@ -167,7 +167,7 @@ void rt_hw_trap_dabt(struct rt_hw_register *regs) rt_hw_show_register(regs); rt_kprintf("data abort\n"); - rt_kprintf("thread - %s stack:\n", RT_NAME_MAX, rt_current_thread->name); + rt_kprintf("thread - %s stack:\n", RT_NAME_MAX, rt_current_thread->parent.name); #if defined(RT_USING_FINSH) && defined(MSH_USING_BUILT_IN_COMMANDS) list_thread(); diff --git a/bsp/bluetrum/ab32vg1-ab-prougen/board/board.c b/bsp/bluetrum/ab32vg1-ab-prougen/board/board.c index 7d7a1dcd5b..3b886ccda0 100644 --- a/bsp/bluetrum/ab32vg1-ab-prougen/board/board.c +++ b/bsp/bluetrum/ab32vg1-ab-prougen/board/board.c @@ -281,7 +281,7 @@ void exception_isr(void) #if defined(RT_USING_CONSOLE) && defined(RT_USING_DEVICE) rt_console_set_device(RT_NULL); - rt_kprintf(stack_info, rt_thread_self()->sp, rt_thread_self()->name); + rt_kprintf(stack_info, rt_thread_self()->sp, rt_thread_self()->parent.name); #endif while (1); diff --git a/bsp/dm365/platform/trap.c b/bsp/dm365/platform/trap.c index 68b834b9d8..b57198c0d6 100644 --- a/bsp/dm365/platform/trap.c +++ b/bsp/dm365/platform/trap.c @@ -54,7 +54,7 @@ void rt_hw_trap_udef(struct rt_hw_register *regs) rt_hw_show_register(regs); rt_kprintf("undefined instruction\n"); - rt_kprintf("thread - %s stack:\n", rt_current_thread->name); + rt_kprintf("thread - %s stack:\n", rt_current_thread->parent.name); #if defined(RT_USING_FINSH) && defined(MSH_USING_BUILT_IN_COMMANDS) list_thread(); @@ -92,7 +92,7 @@ void rt_hw_trap_pabt(struct rt_hw_register *regs) rt_hw_show_register(regs); rt_kprintf("prefetch abort\n"); - rt_kprintf("thread - %s stack:\n", rt_current_thread->name); + rt_kprintf("thread - %s stack:\n", rt_current_thread->parent.name); #if defined(RT_USING_FINSH) && defined(MSH_USING_BUILT_IN_COMMANDS) list_thread(); @@ -128,7 +128,7 @@ void rt_hw_trap_dabt(struct rt_hw_register *regs) rt_hw_show_register(regs); rt_kprintf("data abort\n"); - rt_kprintf("thread - %s stack:\n", rt_current_thread->name); + rt_kprintf("thread - %s stack:\n", rt_current_thread->parent.name); #if defined(RT_USING_FINSH) && defined(MSH_USING_BUILT_IN_COMMANDS) list_thread(); diff --git a/bsp/raspberry-pico/libcpu/cpuport.c b/bsp/raspberry-pico/libcpu/cpuport.c index 6e0da147f6..93cc35189a 100644 --- a/bsp/raspberry-pico/libcpu/cpuport.c +++ b/bsp/raspberry-pico/libcpu/cpuport.c @@ -253,9 +253,9 @@ void rt_hw_hard_fault_exception(struct exception_stack_frame *contex) #ifdef RT_USING_SMP rt_thread_t rt_current_thread = rt_thread_self(); - rt_kprintf("hard fault on cpu : %d on thread: %s\n", rt_current_thread->oncpu, rt_current_thread->name); + rt_kprintf("hard fault on cpu : %d on thread: %s\n", rt_current_thread->oncpu, rt_current_thread->parent.name); #else - rt_kprintf("hard fault on thread: %s\n", rt_current_thread->name); + rt_kprintf("hard fault on thread: %s\n", rt_current_thread->parent.name); #endif #if defined(RT_USING_FINSH) && defined(MSH_USING_BUILT_IN_COMMANDS) list_thread(); diff --git a/bsp/simulator/drivers/module_win32.c b/bsp/simulator/drivers/module_win32.c index 0f07576964..590aad39bd 100644 --- a/bsp/simulator/drivers/module_win32.c +++ b/bsp/simulator/drivers/module_win32.c @@ -143,7 +143,7 @@ rt_module_t rt_module_self(void) return RT_NULL; /* return current module */ - return (rt_module_t)tid->module_id; + return (rt_module_t)tid->parent.module_id; } RTM_EXPORT(rt_module_self); @@ -319,7 +319,7 @@ rt_module_t rt_module_open(const char *path) module->module_entry)); /* set module id */ - module->module_thread->module_id = (void *)module; + module->module_thread->parent.module_id = (void *)module; module->parent.flag = RT_MODULE_FLAG_WITHENTRY; /* startup module thread */ @@ -520,11 +520,11 @@ rt_module_t rt_module_exec_cmd(const char *path, const char* cmd_line, int line_ 2048, RT_THREAD_PRIORITY_MAX - 2, 10); /* set module id */ - module->module_thread->module_id = (void *)module; + module->module_thread->parent.module_id = (void *)module; module->parent.flag = RT_MODULE_FLAG_WITHENTRY; /* startup module thread */ - rt_thread_startup(module->module_thread); + rt_thread_startup(module->parent.module_thread); } else { diff --git a/bsp/taihu/applications/application.c b/bsp/taihu/applications/application.c index a6c1c93502..aa2f2429ad 100644 --- a/bsp/taihu/applications/application.c +++ b/bsp/taihu/applications/application.c @@ -26,9 +26,9 @@ static void thread1_entry(void* parameter) while (1) { rt_sem_release(&sem2); - rt_kprintf("thread1..: %s\n", rt_thread_self()->name); + rt_kprintf("thread1..: %s\n", rt_thread_self()->parent.name); rt_sem_take(&sem1, RT_WAITING_FOREVER); - rt_kprintf("get semaphore: %s!\n", rt_thread_self()->name); + rt_kprintf("thread1..: %s\n", rt_thread_self()->parent.name); } } @@ -37,7 +37,7 @@ static void thread2_entry(void* parameter) while (1) { rt_sem_take(&sem2, RT_WAITING_FOREVER); - rt_kprintf("thread2--->: %s\n", rt_thread_self()->name); + rt_kprintf("thread2--->: %s\n", rt_thread_self()->parent.name); rt_sem_release(&sem1); } } @@ -73,7 +73,7 @@ static void thread1_entry(void* parameter) rt_uint32_t count = 0; while (1) { - rt_kprintf("%s: count = %d\n", rt_thread_self()->name, count ++); + rt_kprintf("%s: count = %d\n", rt_thread_self()->parent.name, count ++); rt_thread_delay(10); } diff --git a/bsp/w60x/drivers/board.c b/bsp/w60x/drivers/board.c index 02a7b2586a..6ba8996da2 100644 --- a/bsp/w60x/drivers/board.c +++ b/bsp/w60x/drivers/board.c @@ -143,7 +143,7 @@ static void _thread_inited_hook(rt_thread_t thread) if ((stk_start + stack_size) >= TASK_STACK_USING_MEM_UPPER_RANGE) { rt_kprintf("thread[%s] stack only between 0x%08x and 0x%08x, please use rt_create_thread()!!\n", - thread->name, TASK_STACK_USING_MEM_LOWER_RANGE, TASK_STACK_USING_MEM_UPPER_RANGE); + thread->parent.name, TASK_STACK_USING_MEM_LOWER_RANGE, TASK_STACK_USING_MEM_UPPER_RANGE); } RT_ASSERT((stk_start + stack_size) < TASK_STACK_USING_MEM_UPPER_RANGE); } diff --git a/components/finsh/cmd.c b/components/finsh/cmd.c index 57b033cc57..a9a673101e 100644 --- a/components/finsh/cmd.c +++ b/components/finsh/cmd.c @@ -204,12 +204,12 @@ long list_thread(void) #ifdef RT_USING_SMP if (thread->oncpu != RT_CPU_DETACHED) - rt_kprintf("%-*.*s %3d %3d %4d ", maxlen, RT_NAME_MAX, thread->name, thread->oncpu, thread->bind_cpu, thread->current_priority); + rt_kprintf("%-*.*s %3d %3d %4d ", maxlen, RT_NAME_MAX, thread->parent.name, thread->oncpu, thread->bind_cpu, thread->current_priority); else - rt_kprintf("%-*.*s N/A %3d %4d ", maxlen, RT_NAME_MAX, thread->name, thread->bind_cpu, thread->current_priority); + rt_kprintf("%-*.*s N/A %3d %4d ", maxlen, RT_NAME_MAX, thread->parent.name, thread->bind_cpu, thread->current_priority); #else - rt_kprintf("%-*.*s %3d ", maxlen, RT_NAME_MAX, thread->name, thread->current_priority); + rt_kprintf("%-*.*s %3d ", maxlen, RT_NAME_MAX, thread->parent.name, thread->current_priority); #endif /*RT_USING_SMP*/ stat = (thread->stat & RT_THREAD_STAT_MASK); if (stat == RT_THREAD_READY) rt_kprintf(" ready "); @@ -256,7 +256,7 @@ static void show_wait_queue(struct rt_list_node *list) for (node = list->next; node != list; node = node->next) { thread = rt_list_entry(node, struct rt_thread, tlist); - rt_kprintf("%.*s", RT_NAME_MAX, thread->name); + rt_kprintf("%.*s", RT_NAME_MAX, thread->parent.name); if (node->next != list) rt_kprintf("/"); @@ -439,7 +439,7 @@ long list_mutex(void) maxlen, RT_NAME_MAX, m->parent.parent.name, RT_NAME_MAX, - m->owner->name, + m->owner->parent.name, m->hold, m->priority, rt_list_len(&m->parent.suspend_thread)); @@ -452,7 +452,7 @@ long list_mutex(void) maxlen, RT_NAME_MAX, m->parent.parent.name, RT_NAME_MAX, - m->owner->name, + m->owner->parent.name, m->hold, m->priority, rt_list_len(&m->parent.suspend_thread)); diff --git a/components/libc/compilers/common/cstdlib.c b/components/libc/compilers/common/cstdlib.c index 4a978a106c..64bfbb10e0 100644 --- a/components/libc/compilers/common/cstdlib.c +++ b/components/libc/compilers/common/cstdlib.c @@ -20,7 +20,7 @@ void __rt_libc_exit(int status) if (self != RT_NULL) { - LOG_W("thread:%s exit:%d!", self->name, status); + LOG_W("thread:%s exit:%d!", self->parent.name, status); #ifdef RT_USING_PTHREADS if(self->pthread_data != RT_NULL) { diff --git a/components/libc/posix/libdl/dlmodule.c b/components/libc/posix/libdl/dlmodule.c index 723c8b7b73..eebc5be0f9 100644 --- a/components/libc/posix/libdl/dlmodule.c +++ b/components/libc/posix/libdl/dlmodule.c @@ -197,7 +197,7 @@ struct rt_dlmodule *dlmodule_create(void) void dlmodule_destroy_subthread(struct rt_dlmodule *module, rt_thread_t thread) { - RT_ASSERT(thread->module_id == module); + RT_ASSERT(thread->parent.module_id== module); /* lock scheduler to prevent scheduling in cleanup function. */ rt_enter_critical(); @@ -225,7 +225,7 @@ void dlmodule_destroy_subthread(struct rt_dlmodule *module, rt_thread_t thread) rt_thread_free_sig(thread); #endif - if (thread->type & RT_Object_Class_Static) + if (thread->parent.type & RT_Object_Class_Static) { /* detach object */ rt_object_detach((rt_object_t)thread); @@ -409,7 +409,7 @@ struct rt_dlmodule *dlmodule_self(void) tid = rt_thread_self(); if (tid) { - ret = (struct rt_dlmodule*) tid->module_id; + ret = (struct rt_dlmodule*) tid->parent.module_id; } return ret; @@ -555,7 +555,7 @@ struct rt_dlmodule* dlmodule_exec(const char* pgname, const char* cmd, int cmd_s module->stack_size, module->priority, 10); if (tid) { - tid->module_id = module; + tid->parent.module_id= module; module->main_thread = tid; rt_thread_startup(tid); @@ -732,7 +732,7 @@ struct rt_dlmodule* dlmodule_exec_custom(const char* pgname, const char* cmd, in module->stack_size, module->priority, 10); if (tid) { - tid->module_id = module; + tid->parent.module_id= module; module->main_thread = tid; rt_thread_startup(tid); diff --git a/components/lwp/arch/x86/i386/lwp_arch.c b/components/lwp/arch/x86/i386/lwp_arch.c index aa93abd3f6..9f9e846582 100644 --- a/components/lwp/arch/x86/i386/lwp_arch.c +++ b/components/lwp/arch/x86/i386/lwp_arch.c @@ -48,7 +48,7 @@ int arch_expand_user_stack(void *addr) else /* map failed, send signal SIGSEGV */ { #ifdef RT_USING_SIGNALS - dbg_log(DBG_ERROR, "[fault] thread %s mapped addr %p failed!\n", rt_thread_self()->name, addr); + dbg_log(DBG_ERROR, "[fault] thread %s mapped addr %p failed!\n", rt_thread_self()->parent.name, addr); lwp_thread_kill(rt_thread_self(), SIGSEGV); ret = 1; /* return 1, will return back to intr, then check exit */ #endif @@ -57,7 +57,7 @@ int arch_expand_user_stack(void *addr) else /* not stack, send signal SIGSEGV */ { #ifdef RT_USING_SIGNALS - dbg_log(DBG_ERROR, "[fault] thread %s access unmapped addr %p!\n", rt_thread_self()->name, addr); + dbg_log(DBG_ERROR, "[fault] thread %s access unmapped addr %p!\n", rt_thread_self()->parent.name, addr); lwp_thread_kill(rt_thread_self(), SIGSEGV); ret = 1; /* return 1, will return back to intr, then check exit */ #endif diff --git a/components/lwp/lwp.c b/components/lwp/lwp.c index 7fe3230ac5..0af0399cc6 100644 --- a/components/lwp/lwp.c +++ b/components/lwp/lwp.c @@ -1034,7 +1034,7 @@ void lwp_cleanup(struct rt_thread *tid) return; } - LOG_I("cleanup thread: %s, stack_addr: %08X", tid->name, tid->stack_addr); + LOG_I("cleanup thread: %s, stack_addr: %08X", tid->parent.name, tid->stack_addr); level = rt_hw_interrupt_disable(); lwp = (struct rt_lwp *)tid->lwp; diff --git a/components/lwp/lwp_pid.c b/components/lwp/lwp_pid.c index caff790f5e..d22c3f3d68 100644 --- a/components/lwp/lwp_pid.c +++ b/components/lwp/lwp_pid.c @@ -709,11 +709,11 @@ static void print_thread_info(struct rt_thread* thread, int maxlen) #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); + rt_kprintf("%-*.*s %3d %3d ", maxlen, RT_NAME_MAX, thread->parent.name, thread->oncpu, thread->current_priority); else - rt_kprintf("%-*.*s N/A %3d ", maxlen, RT_NAME_MAX, thread->name, thread->current_priority); + rt_kprintf("%-*.*s N/A %3d ", maxlen, RT_NAME_MAX, thread->parent.name, thread->current_priority); #else - rt_kprintf("%-*.*s %3d ", maxlen, RT_NAME_MAX, thread->name, thread->current_priority); + rt_kprintf("%-*.*s %3d ", maxlen, RT_NAME_MAX, thread->parent.name, thread->current_priority); #endif /*RT_USING_SMP*/ stat = (thread->stat & RT_THREAD_STAT_MASK); @@ -787,7 +787,7 @@ long list_process(void) thread = threads[index]; level = rt_hw_interrupt_disable(); - if ((thread->type & ~RT_Object_Class_Static) != RT_Object_Class_Thread) + if ((thread->parent.type & ~RT_Object_Class_Static) != RT_Object_Class_Thread) { rt_hw_interrupt_enable(level); continue; diff --git a/components/lwp/lwp_syscall.c b/components/lwp/lwp_syscall.c index da9812d947..77eb77f556 100644 --- a/components/lwp/lwp_syscall.c +++ b/components/lwp/lwp_syscall.c @@ -1525,7 +1525,7 @@ long _sys_clone(void *arg[]) goto fail; } - thread = rt_thread_create(self->name, + thread = rt_thread_create(self->parent.name, RT_NULL, RT_NULL, self->stack_size, @@ -1713,7 +1713,7 @@ sysret_t _sys_fork(void) /* create thread */ self_thread = rt_thread_self(); - thread = rt_thread_create(self_thread->name, + thread = rt_thread_create(self_thread->parent.name, RT_NULL, RT_NULL, self_thread->stack_size, @@ -2361,7 +2361,7 @@ sysret_t sys_execve(const char *path, char *const argv[], char *const envp[]) /* load ok, now set thread name and swap the data of lwp and new_lwp */ level = rt_hw_interrupt_disable(); - rt_strncpy(thread->name, run_name + last_backslash, RT_NAME_MAX); + rt_strncpy(thread->parent.name, run_name + last_backslash, RT_NAME_MAX); rt_pages_free(page, 0); @@ -2420,7 +2420,7 @@ rt_err_t sys_thread_delete(rt_thread_t thread) #else rt_err_t ret = 0; - if(thread->type != RT_Object_Class_Thread) + if(thread->parent.type != RT_Object_Class_Thread) { ret = -EINVAL; goto __exit; diff --git a/components/net/lwip/port/sys_arch.c b/components/net/lwip/port/sys_arch.c index 145958a0fb..066a75e92a 100644 --- a/components/net/lwip/port/sys_arch.c +++ b/components/net/lwip/port/sys_arch.c @@ -525,7 +525,7 @@ void sys_arch_unprotect(sys_prot_t pval) void sys_arch_assert(const char *file, int line) { rt_kprintf("\nAssertion: %d in %s, thread %s\n", - line, file, rt_thread_self()->name); + line, file, rt_thread_self()->parent.name); RT_ASSERT(0); } diff --git a/components/utilities/ulog/syslog/syslog.c b/components/utilities/ulog/syslog/syslog.c index 474a524b89..213379ee4b 100644 --- a/components/utilities/ulog/syslog/syslog.c +++ b/components/utilities/ulog/syslog/syslog.c @@ -213,7 +213,7 @@ rt_weak rt_size_t syslog_formater(char *log_buf, int level, const char *tag, rt_ /* is not in interrupt context */ if (rt_interrupt_get_nest() == 0) { - log_len += ulog_strcpy(log_len, log_buf + log_len, rt_thread_self()->name); + log_len += ulog_strcpy(log_len, log_buf + log_len, rt_thread_self()->parent.name); } else { diff --git a/components/utilities/ulog/ulog.c b/components/utilities/ulog/ulog.c index 49c111a41c..c83d40dbfe 100644 --- a/components/utilities/ulog/ulog.c +++ b/components/utilities/ulog/ulog.c @@ -352,7 +352,7 @@ rt_weak rt_size_t ulog_head_formater(char *log_buf, rt_uint32_t level, const cha const char *thread_name = "N/A"; if (rt_thread_self()) { - thread_name = rt_thread_self()->name; + thread_name = rt_thread_self()->parent.name; } name_len = rt_strnlen(thread_name, RT_NAME_MAX); rt_strncpy(log_buf + log_len, thread_name, name_len); diff --git a/components/vbus/watermark_queue.c b/components/vbus/watermark_queue.c index 15c42d8080..6108046905 100644 --- a/components/vbus/watermark_queue.c +++ b/components/vbus/watermark_queue.c @@ -46,7 +46,7 @@ void rt_wm_que_dump(struct rt_watermark_queue *wg) thread = rt_list_entry(wg->suspended_threads.next, struct rt_thread, tlist); - rt_kprintf(" %.*s", RT_NAME_MAX, thread->name); + rt_kprintf(" %.*s", RT_NAME_MAX, thread->parent.name); } rt_kprintf("\n"); } diff --git a/include/rtdef.h b/include/rtdef.h index 9746fea388..1c3b1a5027 100644 --- a/include/rtdef.h +++ b/include/rtdef.h @@ -744,24 +744,7 @@ struct rt_user_context */ struct rt_thread { - /* rt object */ -#if RT_NAME_MAX > 0 - char name[RT_NAME_MAX]; /**< dynamic name of kernel object */ -#else - const char *name; /**< static name of kernel object */ -#endif /* RT_NAME_MAX > 0 */ - rt_uint8_t type; /**< type of object */ - rt_uint8_t flags; /**< thread's flags */ - -#ifdef RT_USING_MODULE - void *module_id; /**< id of application module */ -#endif /* RT_USING_MODULE */ - -#ifdef RT_USING_SMART - int lwp_ref_count; /**< ref count for lwp */ -#endif /* RT_USING_SMART */ - - rt_list_t list; /**< the object list */ + struct rt_object parent; rt_list_t tlist; /**< the thread list */ /* stack point and entry */ diff --git a/libcpu/aarch64/common/trap.c b/libcpu/aarch64/common/trap.c index 59378d08e4..dd5468daf1 100644 --- a/libcpu/aarch64/common/trap.c +++ b/libcpu/aarch64/common/trap.c @@ -289,7 +289,7 @@ void rt_hw_trap_exception(struct rt_hw_exp_stack *regs) #endif process_exception(esr, regs->pc); rt_hw_show_register(regs); - rt_kprintf("current: %s\n", rt_thread_self()->name); + rt_kprintf("current: %s\n", rt_thread_self()->parent.name); #ifdef RT_USING_LWP check_user_fault(regs, 0, "user fault"); #endif @@ -304,7 +304,7 @@ void rt_hw_trap_serror(struct rt_hw_exp_stack *regs) { rt_kprintf("SError\n"); rt_hw_show_register(regs); - rt_kprintf("current: %s\n", rt_thread_self()->name); + rt_kprintf("current: %s\n", rt_thread_self()->parent.name); #ifdef RT_USING_FINSH list_thread(); #endif diff --git a/libcpu/arm/AT91SAM7X/trap.c b/libcpu/arm/AT91SAM7X/trap.c index 3c012dd85e..b2dfdb4949 100644 --- a/libcpu/arm/AT91SAM7X/trap.c +++ b/libcpu/arm/AT91SAM7X/trap.c @@ -41,7 +41,7 @@ void rt_hw_trap_fiq(void) extern struct rt_thread* rt_current_thread; void rt_hw_trap_abort(void) { - rt_kprintf("Abort occured!!! Thread [%s] suspended.\n",rt_current_thread->name); + rt_kprintf("Abort occured!!! Thread [%s] suspended.\n",rt_current_thread->parent.name); rt_thread_suspend(rt_current_thread); rt_schedule(); diff --git a/libcpu/arm/am335x/trap.c b/libcpu/arm/am335x/trap.c index 19cb31ad67..d8893d2a94 100644 --- a/libcpu/arm/am335x/trap.c +++ b/libcpu/arm/am335x/trap.c @@ -65,7 +65,7 @@ void rt_hw_trap_udef(struct rt_hw_register *regs) rt_hw_show_register(regs); rt_kprintf("undefined instruction\n"); - rt_kprintf("thread %.*s stack:\n", RT_NAME_MAX, rt_current_thread->name); + rt_kprintf("thread %.*s stack:\n", RT_NAME_MAX, rt_current_thread->parent.name); #if defined(RT_USING_FINSH) && defined(MSH_USING_BUILT_IN_COMMANDS) list_thread(); @@ -103,7 +103,7 @@ void rt_hw_trap_pabt(struct rt_hw_register *regs) rt_hw_show_register(regs); rt_kprintf("prefetch abort\n"); - rt_kprintf("thread %.*s stack:\n", RT_NAME_MAX, rt_current_thread->name); + rt_kprintf("thread %.*s stack:\n", RT_NAME_MAX, rt_current_thread->parent.name); #if defined(RT_USING_FINSH) && defined(MSH_USING_BUILT_IN_COMMANDS) list_thread(); @@ -131,7 +131,7 @@ void rt_hw_trap_dabt(struct rt_hw_register *regs) rt_hw_show_register(regs); rt_kprintf("data abort\n"); - rt_kprintf("thread %.*s stack:\n", RT_NAME_MAX, rt_current_thread->name); + rt_kprintf("thread %.*s stack:\n", RT_NAME_MAX, rt_current_thread->parent.name); #if defined(RT_USING_FINSH) && defined(MSH_USING_BUILT_IN_COMMANDS) list_thread(); diff --git a/libcpu/arm/arm926/trap.c b/libcpu/arm/arm926/trap.c index a1458f9bdf..64fc274ca9 100644 --- a/libcpu/arm/arm926/trap.c +++ b/libcpu/arm/arm926/trap.c @@ -88,7 +88,7 @@ void rt_hw_trap_udef(struct rt_hw_register *regs) rt_hw_show_register(regs); rt_kprintf("undefined instruction\n"); - rt_kprintf("thread - %s stack:\n", rt_current_thread->name); + rt_kprintf("thread - %s stack:\n", rt_current_thread->parent.name); #if defined(RT_USING_FINSH) && defined(MSH_USING_BUILT_IN_COMMANDS) list_thread(); @@ -140,7 +140,7 @@ void rt_hw_trap_pabt(struct rt_hw_register *regs) rt_hw_show_register(regs); rt_kprintf("prefetch abort\n"); - rt_kprintf("thread - %.*s stack:\n", RT_NAME_MAX, rt_current_thread->name); + rt_kprintf("thread - %.*s stack:\n", RT_NAME_MAX, rt_current_thread->parent.name); #if defined(RT_USING_FINSH) && defined(MSH_USING_BUILT_IN_COMMANDS) list_thread(); @@ -168,7 +168,7 @@ void rt_hw_trap_dabt(struct rt_hw_register *regs) rt_hw_show_register(regs); rt_kprintf("data abort\n"); - rt_kprintf("thread - %.*s stack:\n", RT_NAME_MAX, rt_current_thread->name); + rt_kprintf("thread - %.*s stack:\n", RT_NAME_MAX, rt_current_thread->parent.name); #if defined(RT_USING_FINSH) && defined(MSH_USING_BUILT_IN_COMMANDS) list_thread(); diff --git a/libcpu/arm/cortex-m0/cpuport.c b/libcpu/arm/cortex-m0/cpuport.c index 4d53640b2d..2d326364cf 100644 --- a/libcpu/arm/cortex-m0/cpuport.c +++ b/libcpu/arm/cortex-m0/cpuport.c @@ -108,7 +108,7 @@ void rt_hw_hard_fault_exception(struct exception_stack_frame *contex) rt_kprintf("r01: 0x%08x\n", contex->r1); rt_kprintf("r00: 0x%08x\n", contex->r0); - rt_kprintf("hard fault on thread: %s\n", rt_current_thread->name); + rt_kprintf("hard fault on thread: %s\n", rt_current_thread->parent.name); #if defined(RT_USING_FINSH) && defined(MSH_USING_BUILT_IN_COMMANDS) list_thread(); diff --git a/libcpu/arm/cortex-m23/cpuport.c b/libcpu/arm/cortex-m23/cpuport.c index 1385118211..7533f2811f 100644 --- a/libcpu/arm/cortex-m23/cpuport.c +++ b/libcpu/arm/cortex-m23/cpuport.c @@ -109,7 +109,7 @@ void rt_hw_hard_fault_exception(struct exception_stack_frame *contex) rt_kprintf("r01: 0x%08x\n", contex->r1); rt_kprintf("r00: 0x%08x\n", contex->r0); - rt_kprintf("hard fault on thread: %s\n", rt_current_thread->name); + rt_kprintf("hard fault on thread: %s\n", rt_current_thread->parent.name); #if defined(RT_USING_FINSH) && defined(MSH_USING_BUILT_IN_COMMANDS) list_thread(); diff --git a/libcpu/arm/cortex-m3/cpuport.c b/libcpu/arm/cortex-m3/cpuport.c index 75449fad3a..65fc7969c6 100644 --- a/libcpu/arm/cortex-m3/cpuport.c +++ b/libcpu/arm/cortex-m3/cpuport.c @@ -325,7 +325,7 @@ void rt_hw_hard_fault_exception(struct exception_info * exception_info) if(exception_info->exc_return & (1 << 2) ) { - rt_kprintf("hard fault on thread: %s\r\n\r\n", rt_thread_self()->name); + rt_kprintf("hard fault on thread: %s\r\n\r\n", rt_thread_self()->parent.name); #if defined(RT_USING_FINSH) && defined(MSH_USING_BUILT_IN_COMMANDS) list_thread(); diff --git a/libcpu/arm/cortex-m33/cpuport.c b/libcpu/arm/cortex-m33/cpuport.c index a713665539..9c110c7f55 100644 --- a/libcpu/arm/cortex-m33/cpuport.c +++ b/libcpu/arm/cortex-m33/cpuport.c @@ -462,7 +462,7 @@ void rt_hw_hard_fault_exception(struct exception_info *exception_info) if (exception_info->exc_return & (1 << 2)) { - rt_kprintf("hard fault on thread: %s\r\n\r\n", rt_thread_self()->name); + rt_kprintf("hard fault on thread: %s\r\n\r\n", rt_thread_self()->parent.name); #if defined(RT_USING_FINSH) && defined(MSH_USING_BUILT_IN_COMMANDS) list_thread(); diff --git a/libcpu/arm/cortex-m4/cpuport.c b/libcpu/arm/cortex-m4/cpuport.c index 903c228f82..1674d846e0 100644 --- a/libcpu/arm/cortex-m4/cpuport.c +++ b/libcpu/arm/cortex-m4/cpuport.c @@ -405,7 +405,7 @@ void rt_hw_hard_fault_exception(struct exception_info *exception_info) if (exception_info->exc_return & (1 << 2)) { - rt_kprintf("hard fault on thread: %s\r\n\r\n", rt_thread_self()->name); + rt_kprintf("hard fault on thread: %s\r\n\r\n", rt_thread_self()->parent.name); #if defined(RT_USING_FINSH) && defined(MSH_USING_BUILT_IN_COMMANDS) list_thread(); diff --git a/libcpu/arm/cortex-m7/cpuport.c b/libcpu/arm/cortex-m7/cpuport.c index 510a51dde1..14fee85262 100644 --- a/libcpu/arm/cortex-m7/cpuport.c +++ b/libcpu/arm/cortex-m7/cpuport.c @@ -404,7 +404,7 @@ void rt_hw_hard_fault_exception(struct exception_info *exception_info) if (exception_info->exc_return & (1 << 2)) { - rt_kprintf("hard fault on thread: %s\r\n\r\n", rt_thread_self()->name); + rt_kprintf("hard fault on thread: %s\r\n\r\n", rt_thread_self()->parent.name); #if defined(RT_USING_FINSH) && defined(MSH_USING_BUILT_IN_COMMANDS) list_thread(); diff --git a/libcpu/arm/cortex-r4/trap.c b/libcpu/arm/cortex-r4/trap.c index 3ff3d297c0..961c21445c 100644 --- a/libcpu/arm/cortex-r4/trap.c +++ b/libcpu/arm/cortex-r4/trap.c @@ -50,7 +50,7 @@ void rt_hw_trap_udef(struct rt_hw_exp_stack *regs) rt_kprintf("undefined instruction\n"); rt_hw_show_register(regs); if (rt_thread_self() != RT_NULL) - rt_kprintf("Current Thread: %s\n", rt_thread_self()->name); + rt_kprintf("Current Thread: %s\n", rt_thread_self()->parent.name); rt_hw_cpu_shutdown(); } diff --git a/libcpu/arm/lpc24xx/trap.c b/libcpu/arm/lpc24xx/trap.c index 7ad7328a93..e773b54ffb 100644 --- a/libcpu/arm/lpc24xx/trap.c +++ b/libcpu/arm/lpc24xx/trap.c @@ -49,7 +49,7 @@ void rt_hw_trap_udef(struct rt_hw_register *regs) rt_kprintf("undefined instruction\n"); rt_hw_show_register(regs); if (rt_thread_self() != RT_NULL) - rt_kprintf("Current Thread: %s\n", rt_thread_self()->name); + rt_kprintf("Current Thread: %s\n", rt_thread_self()->parent.name); rt_hw_cpu_shutdown(); } @@ -67,7 +67,7 @@ void rt_hw_trap_swi(struct rt_hw_register *regs) rt_kprintf("software interrupt\n"); rt_hw_show_register(regs); if (rt_thread_self() != RT_NULL) - rt_kprintf("Current Thread: %s\n", rt_thread_self()->name); + rt_kprintf("Current Thread: %s\n", rt_thread_self()->parent.name); rt_hw_cpu_shutdown(); } @@ -84,7 +84,7 @@ void rt_hw_trap_pabt(struct rt_hw_register *regs) rt_kprintf("prefetch abort\n"); rt_hw_show_register(regs); if (rt_thread_self() != RT_NULL) - rt_kprintf("Current Thread: %s\n", rt_thread_self()->name); + rt_kprintf("Current Thread: %s\n", rt_thread_self()->parent.name); rt_hw_cpu_shutdown(); } @@ -101,7 +101,7 @@ void rt_hw_trap_dabt(struct rt_hw_register *regs) rt_kprintf("Data Abort "); rt_hw_show_register(regs); if (rt_thread_self() != RT_NULL) - rt_kprintf("Current Thread: %s\n", rt_thread_self()->name); + rt_kprintf("Current Thread: %s\n", rt_thread_self()->parent.name); rt_hw_cpu_shutdown(); } @@ -117,7 +117,7 @@ void rt_hw_trap_resv(struct rt_hw_register *regs) rt_kprintf("not used\n"); rt_hw_show_register(regs); if (rt_thread_self() != RT_NULL) - rt_kprintf("Current Thread: %s\n", rt_thread_self()->name); + rt_kprintf("Current Thread: %s\n", rt_thread_self()->parent.name); rt_hw_cpu_shutdown(); } diff --git a/libcpu/arm/s3c24x0/trap.c b/libcpu/arm/s3c24x0/trap.c index c4be806dc6..e1881df991 100644 --- a/libcpu/arm/s3c24x0/trap.c +++ b/libcpu/arm/s3c24x0/trap.c @@ -56,7 +56,7 @@ void rt_hw_trap_udef(struct rt_hw_register *regs) rt_hw_show_register(regs); rt_kprintf("undefined instruction\n"); - rt_kprintf("thread - %s stack:\n", rt_current_thread->name); + rt_kprintf("thread - %s stack:\n", rt_current_thread->parent.name); #if defined(RT_USING_FINSH) && defined(MSH_USING_BUILT_IN_COMMANDS) list_thread(); @@ -94,7 +94,7 @@ void rt_hw_trap_pabt(struct rt_hw_register *regs) rt_hw_show_register(regs); rt_kprintf("prefetch abort\n"); - rt_kprintf("thread - %s stack:\n", rt_current_thread->name); + rt_kprintf("thread - %s stack:\n", rt_current_thread->parent.name); #if defined(RT_USING_FINSH) && defined(MSH_USING_BUILT_IN_COMMANDS) list_thread(); @@ -115,7 +115,7 @@ void rt_hw_trap_dabt(struct rt_hw_register *regs) rt_hw_show_register(regs); rt_kprintf("data abort\n"); - rt_kprintf("thread - %s stack:\n", rt_current_thread->name); + rt_kprintf("thread - %s stack:\n", rt_current_thread->parent.name); #if defined(RT_USING_FINSH) && defined(MSH_USING_BUILT_IN_COMMANDS) list_thread(); diff --git a/libcpu/arm/sep4020/trap.c b/libcpu/arm/sep4020/trap.c index 441a55bd6d..594d902a5b 100644 --- a/libcpu/arm/sep4020/trap.c +++ b/libcpu/arm/sep4020/trap.c @@ -53,7 +53,7 @@ void rt_hw_trap_udef(struct rt_hw_register *regs) rt_hw_show_register(regs); rt_kprintf("undefined instruction\n"); - rt_kprintf("thread - %s stack:\n", rt_current_thread->name); + rt_kprintf("thread - %s stack:\n", rt_current_thread->parent.name); rt_hw_backtrace((rt_uint32_t *)regs->fp, (rt_uint32_t)rt_current_thread->entry); rt_hw_cpu_shutdown(); @@ -89,7 +89,7 @@ void rt_hw_trap_pabt(struct rt_hw_register *regs) rt_hw_show_register(regs); rt_kprintf("prefetch abort\n"); - rt_kprintf("thread - %s stack:\n", rt_current_thread->name); + rt_kprintf("thread - %s stack:\n", rt_current_thread->parent.name); rt_hw_backtrace((rt_uint32_t *)regs->fp, (rt_uint32_t)rt_current_thread->entry); rt_hw_cpu_shutdown(); @@ -108,7 +108,7 @@ void rt_hw_trap_dabt(struct rt_hw_register *regs) rt_hw_show_register(regs); rt_kprintf("data abort\n"); - rt_kprintf("thread - %s stack:\n", rt_current_thread->name); + rt_kprintf("thread - %s stack:\n", rt_current_thread->parent.name); rt_hw_backtrace((rt_uint32_t *)regs->fp, (rt_uint32_t)rt_current_thread->entry); rt_hw_cpu_shutdown(); diff --git a/libcpu/risc-v/k210/interrupt.c b/libcpu/risc-v/k210/interrupt.c index 23d11c1813..6e62a2cfb5 100644 --- a/libcpu/risc-v/k210/interrupt.c +++ b/libcpu/risc-v/k210/interrupt.c @@ -388,7 +388,7 @@ uintptr_t handle_trap(uintptr_t mcause, uintptr_t epc, uintptr_t * sp) rt_kprintf("\n"); print_stack_frame(sp); rt_kprintf("exception pc => 0x%08x\n", epc); - rt_kprintf("current thread: %.*s\n", RT_NAME_MAX, tid->name); + rt_kprintf("current thread: %.*s\n", RT_NAME_MAX, tid->parent.name); #if defined(RT_USING_FINSH) && defined(MSH_USING_BUILT_IN_COMMANDS) list_thread(); #endif diff --git a/libcpu/risc-v/t-head/c906/backtrace.c b/libcpu/risc-v/t-head/c906/backtrace.c index c10d9f3522..0bcfa0b9d9 100644 --- a/libcpu/risc-v/t-head/c906/backtrace.c +++ b/libcpu/risc-v/t-head/c906/backtrace.c @@ -131,7 +131,7 @@ extern struct rt_thread *rt_current_thread; static char *_get_elf_name(size_t sepc) { - return IN_USERSPACE ? rt_current_thread->name : "rtthread.elf"; + return IN_USERSPACE ? rt_current_thread->parent.name : "rtthread.elf"; } #endif /* RT_USING_SMART */ diff --git a/libcpu/risc-v/t-head/c906/trap.c b/libcpu/risc-v/t-head/c906/trap.c index c95facb0f7..184765507b 100644 --- a/libcpu/risc-v/t-head/c906/trap.c +++ b/libcpu/risc-v/t-head/c906/trap.c @@ -220,7 +220,7 @@ void handle_user(rt_size_t scause, rt_size_t stval, rt_size_t sepc, struct rt_hw rt_hw_backtrace((uint32_t *)sp->s0_fp, sepc); - LOG_E("User Fault, killing thread: %s", rt_thread_self()->name); + LOG_E("User Fault, killing thread: %s", rt_thread_self()->parent.name); EXIT_TRAP; sys_exit(-1); @@ -332,7 +332,7 @@ void handle_trap(rt_size_t scause, rt_size_t stval, rt_size_t sepc, struct rt_hw rt_kprintf("scause:0x%p,stval:0x%p,sepc:0x%p\n", scause, stval, sepc); dump_regs(sp); rt_kprintf("--------------Thread list--------------\n"); - rt_kprintf("current thread: %s\n", rt_thread_self()->name); + rt_kprintf("current thread: %s\n", rt_thread_self()->parent.name); extern struct rt_thread *rt_current_thread; rt_kprintf("--------------Backtrace--------------\n"); diff --git a/libcpu/risc-v/virt64/backtrace.c b/libcpu/risc-v/virt64/backtrace.c index c10d9f3522..0bcfa0b9d9 100644 --- a/libcpu/risc-v/virt64/backtrace.c +++ b/libcpu/risc-v/virt64/backtrace.c @@ -131,7 +131,7 @@ extern struct rt_thread *rt_current_thread; static char *_get_elf_name(size_t sepc) { - return IN_USERSPACE ? rt_current_thread->name : "rtthread.elf"; + return IN_USERSPACE ? rt_current_thread->parent.name : "rtthread.elf"; } #endif /* RT_USING_SMART */ diff --git a/libcpu/risc-v/virt64/trap.c b/libcpu/risc-v/virt64/trap.c index 944cee629a..f8413c9d78 100644 --- a/libcpu/risc-v/virt64/trap.c +++ b/libcpu/risc-v/virt64/trap.c @@ -217,7 +217,7 @@ void handle_user(rt_size_t scause, rt_size_t stval, rt_size_t sepc, struct rt_hw rt_hw_backtrace((uint32_t *)sp->s0_fp, sepc); - LOG_E("User Fault, killing thread: %s", rt_thread_self()->name); + LOG_E("User Fault, killing thread: %s", rt_thread_self()->parent.name); EXIT_TRAP; sys_exit(-1); @@ -344,7 +344,7 @@ void handle_trap(rt_size_t scause, rt_size_t stval, rt_size_t sepc, struct rt_hw rt_kprintf("scause:0x%p,stval:0x%p,sepc:0x%p\n", scause, stval, sepc); dump_regs(sp); rt_kprintf("--------------Thread list--------------\n"); - rt_kprintf("current thread: %s\n", rt_thread_self()->name); + rt_kprintf("current thread: %s\n", rt_thread_self()->parent.name); extern struct rt_thread *rt_current_thread; rt_kprintf("--------------Backtrace--------------\n"); diff --git a/libcpu/rx/cpuport.c b/libcpu/rx/cpuport.c index 20ae133bb1..3425b6b9c9 100644 --- a/libcpu/rx/cpuport.c +++ b/libcpu/rx/cpuport.c @@ -126,7 +126,7 @@ void rt_hw_hard_fault_exception(struct stack_frame* exception_contex) rt_kprintf("acchi: 0x%08x\n", exception_contex->ACCHI); rt_kprintf("acclo: 0x%08x\n", exception_contex->ACCLO); } - rt_kprintf("hard fault on thread: %s\n", rt_current_thread->name); + rt_kprintf("hard fault on thread: %s\n", rt_current_thread->parent.name); #if defined(RT_USING_FINSH) && defined(MSH_USING_BUILT_IN_COMMANDS) list_thread(); #endif diff --git a/libcpu/sim/posix/cpu_port.c b/libcpu/sim/posix/cpu_port.c index dc3e9379dd..636f82cde1 100644 --- a/libcpu/sim/posix/cpu_port.c +++ b/libcpu/sim/posix/cpu_port.c @@ -163,11 +163,11 @@ static void *thread_run(void *parameter) tid = rt_thread_self(); TRACE("pid <%08x> tid <%s> starts...\n", (unsigned int)(thread->pthread), - tid->name); + tid->parent.name); thread->rtthread = tid; thread->task(thread->para); TRACE("pid <%08x> tid <%s> exit...\n", (unsigned int)(thread->pthread), - tid->name); + tid->parent.name); thread->exit(); /*TODO: diff --git a/libcpu/sim/win32/cpu_port.c b/libcpu/sim/win32/cpu_port.c index b7510819b9..4f8b32271b 100644 --- a/libcpu/sim/win32/cpu_port.c +++ b/libcpu/sim/win32/cpu_port.c @@ -147,7 +147,7 @@ static DWORD WINAPI thread_run( LPVOID lpThreadParameter ) rt_thread_t tid = rt_thread_self(); win_thread_t *pWinThread = (win_thread_t *)lpThreadParameter; - SetThreadName(GetCurrentThreadId(), tid->name); + SetThreadName(GetCurrentThreadId(), tid->parent.name); pWinThread->Entry(pWinThread->Param); diff --git a/libcpu/unicore32/sep6200/trap.c b/libcpu/unicore32/sep6200/trap.c index f2f342cfbe..a6a8e166dc 100644 --- a/libcpu/unicore32/sep6200/trap.c +++ b/libcpu/unicore32/sep6200/trap.c @@ -53,7 +53,7 @@ void rt_hw_trap_extn(struct rt_hw_register *regs) rt_hw_show_register(regs); rt_kprintf("extn instruction\n"); - rt_kprintf("thread - %s stack:\n", rt_current_thread->name); + rt_kprintf("thread - %s stack:\n", rt_current_thread->parent.name); rt_hw_backtrace((rt_uint32_t *)regs->fp, (rt_uint32_t)rt_current_thread->entry); rt_hw_cpu_shutdown(); @@ -89,7 +89,7 @@ void rt_hw_trap_pabt(struct rt_hw_register *regs) rt_hw_show_register(regs); rt_kprintf("prefetch abort\n"); - rt_kprintf("thread - %s stack:\n", rt_current_thread->name); + rt_kprintf("thread - %s stack:\n", rt_current_thread->parent.name); rt_hw_backtrace((rt_uint32_t *)regs->fp, (rt_uint32_t)rt_current_thread->entry); rt_hw_cpu_shutdown(); @@ -108,7 +108,7 @@ void rt_hw_trap_dabt(struct rt_hw_register *regs) rt_hw_show_register(regs); rt_kprintf("data abort\n"); - rt_kprintf("thread - %s stack:\n", rt_current_thread->name); + rt_kprintf("thread - %s stack:\n", rt_current_thread->parent.name); rt_hw_backtrace((rt_uint32_t *)regs->fp, (rt_uint32_t)rt_current_thread->entry); rt_hw_cpu_shutdown(); diff --git a/src/idle.c b/src/idle.c index dcd278c628..4903ed3fe5 100644 --- a/src/idle.c +++ b/src/idle.c @@ -207,7 +207,7 @@ static void rt_defunct_execute(void) break; } #ifdef RT_USING_MODULE - module = (struct rt_dlmodule*)thread->module_id; + module = (struct rt_dlmodule*)thread->parent.module_id; if (module) { dlmodule_destroy(module); diff --git a/src/ipc.c b/src/ipc.c index be220439b8..3bd94b5b1b 100644 --- a/src/ipc.c +++ b/src/ipc.c @@ -209,7 +209,7 @@ rt_inline rt_err_t _ipc_list_resume(rt_list_t *list) thread->error = RT_EOK; - RT_DEBUG_LOG(RT_DEBUG_IPC, ("resume thread:%s\n", thread->name)); + RT_DEBUG_LOG(RT_DEBUG_IPC, ("resume thread:%s\n", thread->parent.name)); /* resume it */ rt_thread_resume(thread); @@ -509,8 +509,8 @@ static rt_err_t _rt_sem_take(rt_sem_t sem, rt_int32_t timeout, int suspend_flag) level = rt_hw_interrupt_disable(); RT_DEBUG_LOG(RT_DEBUG_IPC, ("thread %s take sem:%s, which value is: %d\n", - rt_thread_self()->name, - ((struct rt_object *)sem)->name, + rt_thread_self()->parent.name, + sem->parent.parent.name, sem->value)); if (sem->value > 0) @@ -542,8 +542,7 @@ static rt_err_t _rt_sem_take(rt_sem_t sem, rt_int32_t timeout, int suspend_flag) /* reset thread error number */ thread->error = -RT_EINTR; - RT_DEBUG_LOG(RT_DEBUG_IPC, ("sem take: suspend thread - %s\n", - thread->name)); + RT_DEBUG_LOG(RT_DEBUG_IPC, ("sem take: suspend thread - %s\n", thread->parent.name)); /* suspend thread */ ret = _ipc_list_suspend(&(sem->parent.suspend_thread), @@ -559,8 +558,7 @@ static rt_err_t _rt_sem_take(rt_sem_t sem, rt_int32_t timeout, int suspend_flag) /* has waiting time, start thread timer */ if (timeout > 0) { - RT_DEBUG_LOG(RT_DEBUG_IPC, ("set thread:%s to timer list\n", - thread->name)); + RT_DEBUG_LOG(RT_DEBUG_IPC, ("set thread:%s to timer list\n", thread->parent.name)); /* reset the timeout of thread timer and start it */ rt_timer_control(&(thread->thread_timer), @@ -655,8 +653,8 @@ rt_err_t rt_sem_release(rt_sem_t sem) level = rt_hw_interrupt_disable(); RT_DEBUG_LOG(RT_DEBUG_IPC, ("thread %s releases sem:%s, which value is: %d\n", - rt_thread_self()->name, - ((struct rt_object *)sem)->name, + rt_thread_self()->parent.name, + sem->parent.parent.name, sem->value)); if (!rt_list_isempty(&sem->parent.suspend_thread)) @@ -789,7 +787,7 @@ rt_inline void _thread_update_priority(struct rt_thread *thread, rt_uint8_t prio { rt_err_t ret; RT_DEBUG_LOG(RT_DEBUG_IPC, - ("thread:%s priority -> %d\n", thread->name, priority)); + ("thread:%s priority -> %d\n", thread->parent.name, priority)); /* change priority of the thread */ rt_thread_control(thread, @@ -1182,7 +1180,7 @@ static rt_err_t _rt_mutex_take(rt_mutex_t mutex, rt_int32_t timeout, int suspend RT_DEBUG_LOG(RT_DEBUG_IPC, ("mutex_take: current thread %s, hold: %d\n", - thread->name, mutex->hold)); + thread->parent.name, mutex->hold)); /* reset thread error */ thread->error = RT_EOK; @@ -1239,7 +1237,7 @@ static rt_err_t _rt_mutex_take(rt_mutex_t mutex, rt_int32_t timeout, int suspend /* mutex is unavailable, push to suspend list */ RT_DEBUG_LOG(RT_DEBUG_IPC, ("mutex_take: suspend thread: %s\n", - thread->name)); + thread->parent.name)); /* suspend current thread */ ret = _ipc_list_suspend(&(mutex->parent.suspend_thread), @@ -1270,7 +1268,7 @@ static rt_err_t _rt_mutex_take(rt_mutex_t mutex, rt_int32_t timeout, int suspend { RT_DEBUG_LOG(RT_DEBUG_IPC, ("mutex_take: start the timer of thread:%s\n", - thread->name)); + thread->parent.name)); /* reset the timeout of thread timer and start it */ rt_timer_control(&(thread->thread_timer), @@ -1424,7 +1422,7 @@ rt_err_t rt_mutex_release(rt_mutex_t mutex) RT_DEBUG_LOG(RT_DEBUG_IPC, ("mutex_release:current thread %s, hold: %d\n", - thread->name, mutex->hold)); + thread->parent.name, mutex->hold)); RT_OBJECT_HOOK_CALL(rt_object_put_hook, (&(mutex->parent.parent))); @@ -1471,7 +1469,7 @@ rt_err_t rt_mutex_release(rt_mutex_t mutex) tlist); RT_DEBUG_LOG(RT_DEBUG_IPC, ("mutex_release: resume thread: %s\n", - next_thread->name)); + next_thread->parent.name)); /* remove the thread from the suspended list of mutex */ rt_list_remove(&(next_thread->tlist)); @@ -2418,7 +2416,7 @@ static rt_err_t _rt_mb_send_wait(rt_mailbox_t mb, tick_delta = rt_tick_get(); RT_DEBUG_LOG(RT_DEBUG_IPC, ("mb_send_wait: start timer of thread:%s\n", - thread->name)); + thread->parent.name)); /* reset the timeout of thread timer and start it */ rt_timer_control(&(thread->thread_timer), @@ -2712,7 +2710,7 @@ static rt_err_t _rt_mb_recv(rt_mailbox_t mb, rt_ubase_t *value, rt_int32_t timeo tick_delta = rt_tick_get(); RT_DEBUG_LOG(RT_DEBUG_IPC, ("mb_recv: start timer of thread:%s\n", - thread->name)); + thread->parent.name)); /* reset the timeout of thread timer and start it */ rt_timer_control(&(thread->thread_timer), @@ -3259,7 +3257,7 @@ static rt_err_t _rt_mq_send_wait(rt_mq_t mq, tick_delta = rt_tick_get(); RT_DEBUG_LOG(RT_DEBUG_IPC, ("mq_send_wait: start timer of thread:%s\n", - thread->name)); + thread->parent.name)); /* reset the timeout of thread timer and start it */ rt_timer_control(&(thread->thread_timer), @@ -3614,7 +3612,7 @@ static rt_err_t _rt_mq_recv(rt_mq_t mq, tick_delta = rt_tick_get(); RT_DEBUG_LOG(RT_DEBUG_IPC, ("set thread:%s to timer list\n", - thread->name)); + thread->parent.name)); /* reset the timeout of thread timer and start it */ rt_timer_control(&(thread->thread_timer), diff --git a/src/mem.c b/src/mem.c index aade0f5bfa..79affcaa9b 100644 --- a/src/mem.c +++ b/src/mem.c @@ -375,7 +375,7 @@ void *rt_smem_alloc(rt_smem_t m, rt_size_t size) mem->pool_ptr = MEM_USED(); #ifdef RT_USING_MEMTRACE if (rt_thread_self()) - rt_smem_setname(mem, rt_thread_self()->name); + rt_smem_setname(mem, rt_thread_self()->parent.name); else rt_smem_setname(mem, "NONE"); #endif /* RT_USING_MEMTRACE */ diff --git a/src/memheap.c b/src/memheap.c index 26d7ecfa3e..0df9ed41ed 100644 --- a/src/memheap.c +++ b/src/memheap.c @@ -312,7 +312,7 @@ void *rt_memheap_alloc(struct rt_memheap *heap, rt_size_t size) #ifdef RT_USING_MEMTRACE if (rt_thread_self()) - rt_memcpy(header_ptr->owner_thread_name, rt_thread_self()->name, sizeof(header_ptr->owner_thread_name)); + rt_memcpy(header_ptr->owner_thread_name, rt_thread_self()->parent.name, sizeof(header_ptr->owner_thread_name)); else rt_memcpy(header_ptr->owner_thread_name, "NONE", sizeof(header_ptr->owner_thread_name)); #endif /* RT_USING_MEMTRACE */ diff --git a/src/scheduler_mp.c b/src/scheduler_mp.c index a4d07e6233..543d9abc6a 100644 --- a/src/scheduler_mp.c +++ b/src/scheduler_mp.c @@ -112,7 +112,7 @@ static void _scheduler_stack_check(struct rt_thread *thread) { rt_base_t level; - rt_kprintf("thread:%s stack overflow\n", thread->name); + rt_kprintf("thread:%s stack overflow\n", thread->parent.name); level = rt_hw_interrupt_disable(); while (level); @@ -121,13 +121,13 @@ static void _scheduler_stack_check(struct rt_thread *thread) else if ((rt_ubase_t)thread->sp > ((rt_ubase_t)thread->stack_addr + thread->stack_size)) { rt_kprintf("warning: %s stack is close to the top of stack address.\n", - thread->name); + thread->parent.name); } #else else if ((rt_ubase_t)thread->sp <= ((rt_ubase_t)thread->stack_addr + 32)) { rt_kprintf("warning: %s stack is close to end of stack address.\n", - thread->name); + thread->parent.name); } #endif /* ARCH_CPU_STACK_GROWS_UPWARD */ } @@ -349,8 +349,8 @@ void rt_schedule(void) "thread:%.*s(sp:0x%08x), " "from thread:%.*s(sp: 0x%08x)\n", pcpu->irq_nest, highest_ready_priority, - RT_NAME_MAX, to_thread->name, to_thread->sp, - RT_NAME_MAX, current_thread->name, current_thread->sp)); + RT_NAME_MAX, to_thread->parent.name, to_thread->sp, + RT_NAME_MAX, current_thread->parent.name, current_thread->sp)); #ifdef RT_USING_OVERFLOW_CHECK _scheduler_stack_check(to_thread); @@ -584,7 +584,7 @@ void rt_schedule_insert_thread(struct rt_thread *thread) } RT_DEBUG_LOG(RT_DEBUG_SCHEDULER, ("insert thread[%.*s], the priority: %d\n", - RT_NAME_MAX, thread->name, thread->current_priority)); + RT_NAME_MAX, thread->parent.name, thread->current_priority)); __exit: /* enable interrupt */ @@ -608,7 +608,7 @@ void rt_schedule_remove_thread(struct rt_thread *thread) level = rt_hw_interrupt_disable(); RT_DEBUG_LOG(RT_DEBUG_SCHEDULER, ("remove thread[%.*s], the priority: %d\n", - RT_NAME_MAX, thread->name, + RT_NAME_MAX, thread->parent.name, thread->current_priority)); /* remove thread from ready list */ diff --git a/src/scheduler_up.c b/src/scheduler_up.c index a5cfecc6f2..6c552c6a24 100644 --- a/src/scheduler_up.c +++ b/src/scheduler_up.c @@ -117,7 +117,7 @@ static void _scheduler_stack_check(struct rt_thread *thread) { rt_base_t level; - rt_kprintf("thread:%s stack overflow\n", thread->name); + rt_kprintf("thread:%s stack overflow\n", thread->parent.name); level = rt_hw_interrupt_disable(); while (level); @@ -126,13 +126,13 @@ static void _scheduler_stack_check(struct rt_thread *thread) else if ((rt_ubase_t)thread->sp > ((rt_ubase_t)thread->stack_addr + thread->stack_size)) { rt_kprintf("warning: %s stack is close to the top of stack address.\n", - thread->name); + thread->parent.name); } #else else if ((rt_ubase_t)thread->sp <= ((rt_ubase_t)thread->stack_addr + 32)) { rt_kprintf("warning: %s stack is close to end of stack address.\n", - thread->name); + thread->parent.name); } #endif /* ARCH_CPU_STACK_GROWS_UPWARD */ } @@ -281,8 +281,8 @@ void rt_schedule(void) "thread:%.*s(sp:0x%08x), " "from thread:%.*s(sp: 0x%08x)\n", rt_interrupt_nest, highest_ready_priority, - RT_NAME_MAX, to_thread->name, to_thread->sp, - RT_NAME_MAX, from_thread->name, from_thread->sp)); + RT_NAME_MAX, to_thread->parent.name, to_thread->sp, + RT_NAME_MAX, from_thread->parent.name, from_thread->sp)); #ifdef RT_USING_OVERFLOW_CHECK _scheduler_stack_check(to_thread); @@ -384,7 +384,7 @@ void rt_schedule_insert_thread(struct rt_thread *thread) } RT_DEBUG_LOG(RT_DEBUG_SCHEDULER, ("insert thread[%.*s], the priority: %d\n", - RT_NAME_MAX, thread->name, thread->current_priority)); + RT_NAME_MAX, thread->parent.name, thread->current_priority)); /* set priority mask */ #if RT_THREAD_PRIORITY_MAX > 32 @@ -414,7 +414,7 @@ void rt_schedule_remove_thread(struct rt_thread *thread) level = rt_hw_interrupt_disable(); RT_DEBUG_LOG(RT_DEBUG_SCHEDULER, ("remove thread[%.*s], the priority: %d\n", - RT_NAME_MAX, thread->name, + RT_NAME_MAX, thread->parent.name, thread->current_priority)); /* remove thread from ready list */ diff --git a/src/thread.c b/src/thread.c index 5614edea4d..56f9094ab0 100644 --- a/src/thread.c +++ b/src/thread.c @@ -237,7 +237,7 @@ static rt_err_t _thread_init(struct rt_thread *thread, /* initialize thread timer */ rt_timer_init(&(thread->thread_timer), - thread->name, + thread->parent.name, _thread_timeout, thread, 0, @@ -274,7 +274,7 @@ static rt_err_t _thread_init(struct rt_thread *thread, #endif /* RT_USING_PTHREADS */ #ifdef RT_USING_MODULE - thread->module_id = 0; + thread->parent.module_id = 0; #endif /* RT_USING_MODULE */ RT_OBJECT_HOOK_CALL(rt_thread_inited_hook, (thread)); @@ -386,7 +386,7 @@ rt_err_t rt_thread_startup(rt_thread_t thread) #endif /* RT_THREAD_PRIORITY_MAX > 32 */ RT_DEBUG_LOG(RT_DEBUG_THREAD, ("startup a thread:%s with priority:%d\n", - thread->name, thread->current_priority)); + thread->parent.name, thread->current_priority)); /* change thread stat */ thread->stat = RT_THREAD_SUSPEND; /* then resume it */ @@ -983,7 +983,7 @@ rt_err_t rt_thread_suspend_with_flag(rt_thread_t thread, int suspend_flag) RT_ASSERT(rt_object_get_type((rt_object_t)thread) == RT_Object_Class_Thread); RT_ASSERT(thread == rt_thread_self()); - RT_DEBUG_LOG(RT_DEBUG_THREAD, ("thread suspend: %s\n", thread->name)); + RT_DEBUG_LOG(RT_DEBUG_THREAD, ("thread suspend: %s\n", thread->parent.name)); stat = thread->stat & RT_THREAD_STAT_MASK; if ((stat != RT_THREAD_READY) && (stat != RT_THREAD_RUNNING)) @@ -1046,7 +1046,7 @@ rt_err_t rt_thread_resume(rt_thread_t thread) RT_ASSERT(thread != RT_NULL); RT_ASSERT(rt_object_get_type((rt_object_t)thread) == RT_Object_Class_Thread); - RT_DEBUG_LOG(RT_DEBUG_THREAD, ("thread resume: %s\n", thread->name)); + RT_DEBUG_LOG(RT_DEBUG_THREAD, ("thread resume: %s\n", thread->parent.name)); if ((thread->stat & RT_THREAD_SUSPEND_MASK) != RT_THREAD_SUSPEND_MASK) {