[kernel] 将rt_thread结构体改为显式继承rt_object (#7131)

This commit is contained in:
Shicheng Chu 2023-04-04 21:06:27 +08:00 committed by GitHub
parent 8a52e65013
commit 93f3cb30e4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
49 changed files with 126 additions and 145 deletions

View File

@ -87,7 +87,7 @@ void rt_hw_trap_udef(struct rt_hw_register *regs)
rt_hw_show_register(regs); rt_hw_show_register(regs);
rt_kprintf("undefined instruction\n"); 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) #if defined(RT_USING_FINSH) && defined(MSH_USING_BUILT_IN_COMMANDS)
list_thread(); list_thread();
@ -139,7 +139,7 @@ void rt_hw_trap_pabt(struct rt_hw_register *regs)
rt_hw_show_register(regs); rt_hw_show_register(regs);
rt_kprintf("prefetch abort\n"); 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) #if defined(RT_USING_FINSH) && defined(MSH_USING_BUILT_IN_COMMANDS)
list_thread(); list_thread();
@ -167,7 +167,7 @@ void rt_hw_trap_dabt(struct rt_hw_register *regs)
rt_hw_show_register(regs); rt_hw_show_register(regs);
rt_kprintf("data abort\n"); 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) #if defined(RT_USING_FINSH) && defined(MSH_USING_BUILT_IN_COMMANDS)
list_thread(); list_thread();

View File

@ -281,7 +281,7 @@ void exception_isr(void)
#if defined(RT_USING_CONSOLE) && defined(RT_USING_DEVICE) #if defined(RT_USING_CONSOLE) && defined(RT_USING_DEVICE)
rt_console_set_device(RT_NULL); 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 #endif
while (1); while (1);

View File

@ -54,7 +54,7 @@ void rt_hw_trap_udef(struct rt_hw_register *regs)
rt_hw_show_register(regs); rt_hw_show_register(regs);
rt_kprintf("undefined instruction\n"); 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) #if defined(RT_USING_FINSH) && defined(MSH_USING_BUILT_IN_COMMANDS)
list_thread(); list_thread();
@ -92,7 +92,7 @@ void rt_hw_trap_pabt(struct rt_hw_register *regs)
rt_hw_show_register(regs); rt_hw_show_register(regs);
rt_kprintf("prefetch abort\n"); 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) #if defined(RT_USING_FINSH) && defined(MSH_USING_BUILT_IN_COMMANDS)
list_thread(); list_thread();
@ -128,7 +128,7 @@ void rt_hw_trap_dabt(struct rt_hw_register *regs)
rt_hw_show_register(regs); rt_hw_show_register(regs);
rt_kprintf("data abort\n"); 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) #if defined(RT_USING_FINSH) && defined(MSH_USING_BUILT_IN_COMMANDS)
list_thread(); list_thread();

View File

@ -253,9 +253,9 @@ void rt_hw_hard_fault_exception(struct exception_stack_frame *contex)
#ifdef RT_USING_SMP #ifdef RT_USING_SMP
rt_thread_t rt_current_thread = rt_thread_self(); 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 #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 #endif
#if defined(RT_USING_FINSH) && defined(MSH_USING_BUILT_IN_COMMANDS) #if defined(RT_USING_FINSH) && defined(MSH_USING_BUILT_IN_COMMANDS)
list_thread(); list_thread();

View File

@ -143,7 +143,7 @@ rt_module_t rt_module_self(void)
return RT_NULL; return RT_NULL;
/* return current module */ /* return current module */
return (rt_module_t)tid->module_id; return (rt_module_t)tid->parent.module_id;
} }
RTM_EXPORT(rt_module_self); RTM_EXPORT(rt_module_self);
@ -319,7 +319,7 @@ rt_module_t rt_module_open(const char *path)
module->module_entry)); module->module_entry));
/* set module id */ /* 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; module->parent.flag = RT_MODULE_FLAG_WITHENTRY;
/* startup module thread */ /* 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); 2048, RT_THREAD_PRIORITY_MAX - 2, 10);
/* set module id */ /* 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; module->parent.flag = RT_MODULE_FLAG_WITHENTRY;
/* startup module thread */ /* startup module thread */
rt_thread_startup(module->module_thread); rt_thread_startup(module->parent.module_thread);
} }
else else
{ {

View File

@ -26,9 +26,9 @@ static void thread1_entry(void* parameter)
while (1) while (1)
{ {
rt_sem_release(&sem2); 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_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) while (1)
{ {
rt_sem_take(&sem2, RT_WAITING_FOREVER); 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); rt_sem_release(&sem1);
} }
} }
@ -73,7 +73,7 @@ static void thread1_entry(void* parameter)
rt_uint32_t count = 0; rt_uint32_t count = 0;
while (1) 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); rt_thread_delay(10);
} }

View File

@ -143,7 +143,7 @@ static void _thread_inited_hook(rt_thread_t thread)
if ((stk_start + stack_size) >= TASK_STACK_USING_MEM_UPPER_RANGE) 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", 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); RT_ASSERT((stk_start + stack_size) < TASK_STACK_USING_MEM_UPPER_RANGE);
} }

View File

@ -204,12 +204,12 @@ long list_thread(void)
#ifdef RT_USING_SMP #ifdef RT_USING_SMP
if (thread->oncpu != RT_CPU_DETACHED) 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 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 #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*/ #endif /*RT_USING_SMP*/
stat = (thread->stat & RT_THREAD_STAT_MASK); stat = (thread->stat & RT_THREAD_STAT_MASK);
if (stat == RT_THREAD_READY) rt_kprintf(" ready "); 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) for (node = list->next; node != list; node = node->next)
{ {
thread = rt_list_entry(node, struct rt_thread, tlist); 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) if (node->next != list)
rt_kprintf("/"); rt_kprintf("/");
@ -439,7 +439,7 @@ long list_mutex(void)
maxlen, RT_NAME_MAX, maxlen, RT_NAME_MAX,
m->parent.parent.name, m->parent.parent.name,
RT_NAME_MAX, RT_NAME_MAX,
m->owner->name, m->owner->parent.name,
m->hold, m->hold,
m->priority, m->priority,
rt_list_len(&m->parent.suspend_thread)); rt_list_len(&m->parent.suspend_thread));
@ -452,7 +452,7 @@ long list_mutex(void)
maxlen, RT_NAME_MAX, maxlen, RT_NAME_MAX,
m->parent.parent.name, m->parent.parent.name,
RT_NAME_MAX, RT_NAME_MAX,
m->owner->name, m->owner->parent.name,
m->hold, m->hold,
m->priority, m->priority,
rt_list_len(&m->parent.suspend_thread)); rt_list_len(&m->parent.suspend_thread));

View File

@ -20,7 +20,7 @@ void __rt_libc_exit(int status)
if (self != RT_NULL) 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 #ifdef RT_USING_PTHREADS
if(self->pthread_data != RT_NULL) if(self->pthread_data != RT_NULL)
{ {

View File

@ -197,7 +197,7 @@ struct rt_dlmodule *dlmodule_create(void)
void dlmodule_destroy_subthread(struct rt_dlmodule *module, rt_thread_t thread) 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. */ /* lock scheduler to prevent scheduling in cleanup function. */
rt_enter_critical(); rt_enter_critical();
@ -225,7 +225,7 @@ void dlmodule_destroy_subthread(struct rt_dlmodule *module, rt_thread_t thread)
rt_thread_free_sig(thread); rt_thread_free_sig(thread);
#endif #endif
if (thread->type & RT_Object_Class_Static) if (thread->parent.type & RT_Object_Class_Static)
{ {
/* detach object */ /* detach object */
rt_object_detach((rt_object_t)thread); rt_object_detach((rt_object_t)thread);
@ -409,7 +409,7 @@ struct rt_dlmodule *dlmodule_self(void)
tid = rt_thread_self(); tid = rt_thread_self();
if (tid) if (tid)
{ {
ret = (struct rt_dlmodule*) tid->module_id; ret = (struct rt_dlmodule*) tid->parent.module_id;
} }
return ret; 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); module->stack_size, module->priority, 10);
if (tid) if (tid)
{ {
tid->module_id = module; tid->parent.module_id= module;
module->main_thread = tid; module->main_thread = tid;
rt_thread_startup(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); module->stack_size, module->priority, 10);
if (tid) if (tid)
{ {
tid->module_id = module; tid->parent.module_id= module;
module->main_thread = tid; module->main_thread = tid;
rt_thread_startup(tid); rt_thread_startup(tid);

View File

@ -48,7 +48,7 @@ int arch_expand_user_stack(void *addr)
else /* map failed, send signal SIGSEGV */ else /* map failed, send signal SIGSEGV */
{ {
#ifdef RT_USING_SIGNALS #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); lwp_thread_kill(rt_thread_self(), SIGSEGV);
ret = 1; /* return 1, will return back to intr, then check exit */ ret = 1; /* return 1, will return back to intr, then check exit */
#endif #endif
@ -57,7 +57,7 @@ int arch_expand_user_stack(void *addr)
else /* not stack, send signal SIGSEGV */ else /* not stack, send signal SIGSEGV */
{ {
#ifdef RT_USING_SIGNALS #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); lwp_thread_kill(rt_thread_self(), SIGSEGV);
ret = 1; /* return 1, will return back to intr, then check exit */ ret = 1; /* return 1, will return back to intr, then check exit */
#endif #endif

View File

@ -1034,7 +1034,7 @@ void lwp_cleanup(struct rt_thread *tid)
return; 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(); level = rt_hw_interrupt_disable();
lwp = (struct rt_lwp *)tid->lwp; lwp = (struct rt_lwp *)tid->lwp;

View File

@ -709,11 +709,11 @@ static void print_thread_info(struct rt_thread* thread, int maxlen)
#ifdef RT_USING_SMP #ifdef RT_USING_SMP
if (thread->oncpu != RT_CPU_DETACHED) 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 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 #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*/ #endif /*RT_USING_SMP*/
stat = (thread->stat & RT_THREAD_STAT_MASK); stat = (thread->stat & RT_THREAD_STAT_MASK);
@ -787,7 +787,7 @@ long list_process(void)
thread = threads[index]; thread = threads[index];
level = rt_hw_interrupt_disable(); 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); rt_hw_interrupt_enable(level);
continue; continue;

View File

@ -1525,7 +1525,7 @@ long _sys_clone(void *arg[])
goto fail; goto fail;
} }
thread = rt_thread_create(self->name, thread = rt_thread_create(self->parent.name,
RT_NULL, RT_NULL,
RT_NULL, RT_NULL,
self->stack_size, self->stack_size,
@ -1713,7 +1713,7 @@ sysret_t _sys_fork(void)
/* create thread */ /* create thread */
self_thread = rt_thread_self(); self_thread = rt_thread_self();
thread = rt_thread_create(self_thread->name, thread = rt_thread_create(self_thread->parent.name,
RT_NULL, RT_NULL,
RT_NULL, RT_NULL,
self_thread->stack_size, 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 */ /* load ok, now set thread name and swap the data of lwp and new_lwp */
level = rt_hw_interrupt_disable(); 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); rt_pages_free(page, 0);
@ -2420,7 +2420,7 @@ rt_err_t sys_thread_delete(rt_thread_t thread)
#else #else
rt_err_t ret = 0; rt_err_t ret = 0;
if(thread->type != RT_Object_Class_Thread) if(thread->parent.type != RT_Object_Class_Thread)
{ {
ret = -EINVAL; ret = -EINVAL;
goto __exit; goto __exit;

View File

@ -525,7 +525,7 @@ void sys_arch_unprotect(sys_prot_t pval)
void sys_arch_assert(const char *file, int line) void sys_arch_assert(const char *file, int line)
{ {
rt_kprintf("\nAssertion: %d in %s, thread %s\n", 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); RT_ASSERT(0);
} }

View File

@ -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 */ /* is not in interrupt context */
if (rt_interrupt_get_nest() == 0) 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 else
{ {

View File

@ -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"; const char *thread_name = "N/A";
if (rt_thread_self()) 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); name_len = rt_strnlen(thread_name, RT_NAME_MAX);
rt_strncpy(log_buf + log_len, thread_name, name_len); rt_strncpy(log_buf + log_len, thread_name, name_len);

View File

@ -46,7 +46,7 @@ void rt_wm_que_dump(struct rt_watermark_queue *wg)
thread = rt_list_entry(wg->suspended_threads.next, thread = rt_list_entry(wg->suspended_threads.next,
struct rt_thread, struct rt_thread,
tlist); tlist);
rt_kprintf(" %.*s", RT_NAME_MAX, thread->name); rt_kprintf(" %.*s", RT_NAME_MAX, thread->parent.name);
} }
rt_kprintf("\n"); rt_kprintf("\n");
} }

View File

@ -744,24 +744,7 @@ struct rt_user_context
*/ */
struct rt_thread struct rt_thread
{ {
/* rt object */ struct rt_object parent;
#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 */
rt_list_t tlist; /**< the thread list */ rt_list_t tlist; /**< the thread list */
/* stack point and entry */ /* stack point and entry */

View File

@ -289,7 +289,7 @@ void rt_hw_trap_exception(struct rt_hw_exp_stack *regs)
#endif #endif
process_exception(esr, regs->pc); process_exception(esr, regs->pc);
rt_hw_show_register(regs); 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 #ifdef RT_USING_LWP
check_user_fault(regs, 0, "user fault"); check_user_fault(regs, 0, "user fault");
#endif #endif
@ -304,7 +304,7 @@ void rt_hw_trap_serror(struct rt_hw_exp_stack *regs)
{ {
rt_kprintf("SError\n"); rt_kprintf("SError\n");
rt_hw_show_register(regs); 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 #ifdef RT_USING_FINSH
list_thread(); list_thread();
#endif #endif

View File

@ -41,7 +41,7 @@ void rt_hw_trap_fiq(void)
extern struct rt_thread* rt_current_thread; extern struct rt_thread* rt_current_thread;
void rt_hw_trap_abort(void) 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_thread_suspend(rt_current_thread);
rt_schedule(); rt_schedule();

View File

@ -65,7 +65,7 @@ void rt_hw_trap_udef(struct rt_hw_register *regs)
rt_hw_show_register(regs); rt_hw_show_register(regs);
rt_kprintf("undefined instruction\n"); 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) #if defined(RT_USING_FINSH) && defined(MSH_USING_BUILT_IN_COMMANDS)
list_thread(); list_thread();
@ -103,7 +103,7 @@ void rt_hw_trap_pabt(struct rt_hw_register *regs)
rt_hw_show_register(regs); rt_hw_show_register(regs);
rt_kprintf("prefetch abort\n"); 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) #if defined(RT_USING_FINSH) && defined(MSH_USING_BUILT_IN_COMMANDS)
list_thread(); list_thread();
@ -131,7 +131,7 @@ void rt_hw_trap_dabt(struct rt_hw_register *regs)
rt_hw_show_register(regs); rt_hw_show_register(regs);
rt_kprintf("data abort\n"); 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) #if defined(RT_USING_FINSH) && defined(MSH_USING_BUILT_IN_COMMANDS)
list_thread(); list_thread();

View File

@ -88,7 +88,7 @@ void rt_hw_trap_udef(struct rt_hw_register *regs)
rt_hw_show_register(regs); rt_hw_show_register(regs);
rt_kprintf("undefined instruction\n"); 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) #if defined(RT_USING_FINSH) && defined(MSH_USING_BUILT_IN_COMMANDS)
list_thread(); list_thread();
@ -140,7 +140,7 @@ void rt_hw_trap_pabt(struct rt_hw_register *regs)
rt_hw_show_register(regs); rt_hw_show_register(regs);
rt_kprintf("prefetch abort\n"); 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) #if defined(RT_USING_FINSH) && defined(MSH_USING_BUILT_IN_COMMANDS)
list_thread(); list_thread();
@ -168,7 +168,7 @@ void rt_hw_trap_dabt(struct rt_hw_register *regs)
rt_hw_show_register(regs); rt_hw_show_register(regs);
rt_kprintf("data abort\n"); 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) #if defined(RT_USING_FINSH) && defined(MSH_USING_BUILT_IN_COMMANDS)
list_thread(); list_thread();

View File

@ -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("r01: 0x%08x\n", contex->r1);
rt_kprintf("r00: 0x%08x\n", contex->r0); 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) #if defined(RT_USING_FINSH) && defined(MSH_USING_BUILT_IN_COMMANDS)
list_thread(); list_thread();

View File

@ -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("r01: 0x%08x\n", contex->r1);
rt_kprintf("r00: 0x%08x\n", contex->r0); 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) #if defined(RT_USING_FINSH) && defined(MSH_USING_BUILT_IN_COMMANDS)
list_thread(); list_thread();

View File

@ -325,7 +325,7 @@ void rt_hw_hard_fault_exception(struct exception_info * exception_info)
if(exception_info->exc_return & (1 << 2) ) 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) #if defined(RT_USING_FINSH) && defined(MSH_USING_BUILT_IN_COMMANDS)
list_thread(); list_thread();

View File

@ -462,7 +462,7 @@ void rt_hw_hard_fault_exception(struct exception_info *exception_info)
if (exception_info->exc_return & (1 << 2)) 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) #if defined(RT_USING_FINSH) && defined(MSH_USING_BUILT_IN_COMMANDS)
list_thread(); list_thread();

View File

@ -405,7 +405,7 @@ void rt_hw_hard_fault_exception(struct exception_info *exception_info)
if (exception_info->exc_return & (1 << 2)) 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) #if defined(RT_USING_FINSH) && defined(MSH_USING_BUILT_IN_COMMANDS)
list_thread(); list_thread();

View File

@ -404,7 +404,7 @@ void rt_hw_hard_fault_exception(struct exception_info *exception_info)
if (exception_info->exc_return & (1 << 2)) 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) #if defined(RT_USING_FINSH) && defined(MSH_USING_BUILT_IN_COMMANDS)
list_thread(); list_thread();

View File

@ -50,7 +50,7 @@ void rt_hw_trap_udef(struct rt_hw_exp_stack *regs)
rt_kprintf("undefined instruction\n"); rt_kprintf("undefined instruction\n");
rt_hw_show_register(regs); rt_hw_show_register(regs);
if (rt_thread_self() != RT_NULL) 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(); rt_hw_cpu_shutdown();
} }

View File

@ -49,7 +49,7 @@ void rt_hw_trap_udef(struct rt_hw_register *regs)
rt_kprintf("undefined instruction\n"); rt_kprintf("undefined instruction\n");
rt_hw_show_register(regs); rt_hw_show_register(regs);
if (rt_thread_self() != RT_NULL) 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(); rt_hw_cpu_shutdown();
} }
@ -67,7 +67,7 @@ void rt_hw_trap_swi(struct rt_hw_register *regs)
rt_kprintf("software interrupt\n"); rt_kprintf("software interrupt\n");
rt_hw_show_register(regs); rt_hw_show_register(regs);
if (rt_thread_self() != RT_NULL) 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(); rt_hw_cpu_shutdown();
} }
@ -84,7 +84,7 @@ void rt_hw_trap_pabt(struct rt_hw_register *regs)
rt_kprintf("prefetch abort\n"); rt_kprintf("prefetch abort\n");
rt_hw_show_register(regs); rt_hw_show_register(regs);
if (rt_thread_self() != RT_NULL) 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(); rt_hw_cpu_shutdown();
} }
@ -101,7 +101,7 @@ void rt_hw_trap_dabt(struct rt_hw_register *regs)
rt_kprintf("Data Abort "); rt_kprintf("Data Abort ");
rt_hw_show_register(regs); rt_hw_show_register(regs);
if (rt_thread_self() != RT_NULL) 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(); rt_hw_cpu_shutdown();
} }
@ -117,7 +117,7 @@ void rt_hw_trap_resv(struct rt_hw_register *regs)
rt_kprintf("not used\n"); rt_kprintf("not used\n");
rt_hw_show_register(regs); rt_hw_show_register(regs);
if (rt_thread_self() != RT_NULL) 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(); rt_hw_cpu_shutdown();
} }

View File

@ -56,7 +56,7 @@ void rt_hw_trap_udef(struct rt_hw_register *regs)
rt_hw_show_register(regs); rt_hw_show_register(regs);
rt_kprintf("undefined instruction\n"); 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) #if defined(RT_USING_FINSH) && defined(MSH_USING_BUILT_IN_COMMANDS)
list_thread(); list_thread();
@ -94,7 +94,7 @@ void rt_hw_trap_pabt(struct rt_hw_register *regs)
rt_hw_show_register(regs); rt_hw_show_register(regs);
rt_kprintf("prefetch abort\n"); 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) #if defined(RT_USING_FINSH) && defined(MSH_USING_BUILT_IN_COMMANDS)
list_thread(); list_thread();
@ -115,7 +115,7 @@ void rt_hw_trap_dabt(struct rt_hw_register *regs)
rt_hw_show_register(regs); rt_hw_show_register(regs);
rt_kprintf("data abort\n"); 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) #if defined(RT_USING_FINSH) && defined(MSH_USING_BUILT_IN_COMMANDS)
list_thread(); list_thread();

View File

@ -53,7 +53,7 @@ void rt_hw_trap_udef(struct rt_hw_register *regs)
rt_hw_show_register(regs); rt_hw_show_register(regs);
rt_kprintf("undefined instruction\n"); 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_backtrace((rt_uint32_t *)regs->fp, (rt_uint32_t)rt_current_thread->entry);
rt_hw_cpu_shutdown(); rt_hw_cpu_shutdown();
@ -89,7 +89,7 @@ void rt_hw_trap_pabt(struct rt_hw_register *regs)
rt_hw_show_register(regs); rt_hw_show_register(regs);
rt_kprintf("prefetch abort\n"); 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_backtrace((rt_uint32_t *)regs->fp, (rt_uint32_t)rt_current_thread->entry);
rt_hw_cpu_shutdown(); rt_hw_cpu_shutdown();
@ -108,7 +108,7 @@ void rt_hw_trap_dabt(struct rt_hw_register *regs)
rt_hw_show_register(regs); rt_hw_show_register(regs);
rt_kprintf("data abort\n"); 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_backtrace((rt_uint32_t *)regs->fp, (rt_uint32_t)rt_current_thread->entry);
rt_hw_cpu_shutdown(); rt_hw_cpu_shutdown();

View File

@ -388,7 +388,7 @@ uintptr_t handle_trap(uintptr_t mcause, uintptr_t epc, uintptr_t * sp)
rt_kprintf("\n"); rt_kprintf("\n");
print_stack_frame(sp); print_stack_frame(sp);
rt_kprintf("exception pc => 0x%08x\n", epc); 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) #if defined(RT_USING_FINSH) && defined(MSH_USING_BUILT_IN_COMMANDS)
list_thread(); list_thread();
#endif #endif

View File

@ -131,7 +131,7 @@ extern struct rt_thread *rt_current_thread;
static char *_get_elf_name(size_t sepc) 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 */ #endif /* RT_USING_SMART */

View File

@ -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); 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; EXIT_TRAP;
sys_exit(-1); 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); rt_kprintf("scause:0x%p,stval:0x%p,sepc:0x%p\n", scause, stval, sepc);
dump_regs(sp); dump_regs(sp);
rt_kprintf("--------------Thread list--------------\n"); 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; extern struct rt_thread *rt_current_thread;
rt_kprintf("--------------Backtrace--------------\n"); rt_kprintf("--------------Backtrace--------------\n");

View File

@ -131,7 +131,7 @@ extern struct rt_thread *rt_current_thread;
static char *_get_elf_name(size_t sepc) 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 */ #endif /* RT_USING_SMART */

View File

@ -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); 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; EXIT_TRAP;
sys_exit(-1); 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); rt_kprintf("scause:0x%p,stval:0x%p,sepc:0x%p\n", scause, stval, sepc);
dump_regs(sp); dump_regs(sp);
rt_kprintf("--------------Thread list--------------\n"); 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; extern struct rt_thread *rt_current_thread;
rt_kprintf("--------------Backtrace--------------\n"); rt_kprintf("--------------Backtrace--------------\n");

View File

@ -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("acchi: 0x%08x\n", exception_contex->ACCHI);
rt_kprintf("acclo: 0x%08x\n", exception_contex->ACCLO); 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) #if defined(RT_USING_FINSH) && defined(MSH_USING_BUILT_IN_COMMANDS)
list_thread(); list_thread();
#endif #endif

View File

@ -163,11 +163,11 @@ static void *thread_run(void *parameter)
tid = rt_thread_self(); tid = rt_thread_self();
TRACE("pid <%08x> tid <%s> starts...\n", (unsigned int)(thread->pthread), TRACE("pid <%08x> tid <%s> starts...\n", (unsigned int)(thread->pthread),
tid->name); tid->parent.name);
thread->rtthread = tid; thread->rtthread = tid;
thread->task(thread->para); thread->task(thread->para);
TRACE("pid <%08x> tid <%s> exit...\n", (unsigned int)(thread->pthread), TRACE("pid <%08x> tid <%s> exit...\n", (unsigned int)(thread->pthread),
tid->name); tid->parent.name);
thread->exit(); thread->exit();
/*TODO: /*TODO:

View File

@ -147,7 +147,7 @@ static DWORD WINAPI thread_run( LPVOID lpThreadParameter )
rt_thread_t tid = rt_thread_self(); rt_thread_t tid = rt_thread_self();
win_thread_t *pWinThread = (win_thread_t *)lpThreadParameter; win_thread_t *pWinThread = (win_thread_t *)lpThreadParameter;
SetThreadName(GetCurrentThreadId(), tid->name); SetThreadName(GetCurrentThreadId(), tid->parent.name);
pWinThread->Entry(pWinThread->Param); pWinThread->Entry(pWinThread->Param);

View File

@ -53,7 +53,7 @@ void rt_hw_trap_extn(struct rt_hw_register *regs)
rt_hw_show_register(regs); rt_hw_show_register(regs);
rt_kprintf("extn instruction\n"); 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_backtrace((rt_uint32_t *)regs->fp, (rt_uint32_t)rt_current_thread->entry);
rt_hw_cpu_shutdown(); rt_hw_cpu_shutdown();
@ -89,7 +89,7 @@ void rt_hw_trap_pabt(struct rt_hw_register *regs)
rt_hw_show_register(regs); rt_hw_show_register(regs);
rt_kprintf("prefetch abort\n"); 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_backtrace((rt_uint32_t *)regs->fp, (rt_uint32_t)rt_current_thread->entry);
rt_hw_cpu_shutdown(); rt_hw_cpu_shutdown();
@ -108,7 +108,7 @@ void rt_hw_trap_dabt(struct rt_hw_register *regs)
rt_hw_show_register(regs); rt_hw_show_register(regs);
rt_kprintf("data abort\n"); 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_backtrace((rt_uint32_t *)regs->fp, (rt_uint32_t)rt_current_thread->entry);
rt_hw_cpu_shutdown(); rt_hw_cpu_shutdown();

View File

@ -207,7 +207,7 @@ static void rt_defunct_execute(void)
break; break;
} }
#ifdef RT_USING_MODULE #ifdef RT_USING_MODULE
module = (struct rt_dlmodule*)thread->module_id; module = (struct rt_dlmodule*)thread->parent.module_id;
if (module) if (module)
{ {
dlmodule_destroy(module); dlmodule_destroy(module);

View File

@ -209,7 +209,7 @@ rt_inline rt_err_t _ipc_list_resume(rt_list_t *list)
thread->error = RT_EOK; 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 */ /* resume it */
rt_thread_resume(thread); 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(); level = rt_hw_interrupt_disable();
RT_DEBUG_LOG(RT_DEBUG_IPC, ("thread %s take sem:%s, which value is: %d\n", RT_DEBUG_LOG(RT_DEBUG_IPC, ("thread %s take sem:%s, which value is: %d\n",
rt_thread_self()->name, rt_thread_self()->parent.name,
((struct rt_object *)sem)->name, sem->parent.parent.name,
sem->value)); sem->value));
if (sem->value > 0) 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 */ /* reset thread error number */
thread->error = -RT_EINTR; thread->error = -RT_EINTR;
RT_DEBUG_LOG(RT_DEBUG_IPC, ("sem take: suspend thread - %s\n", RT_DEBUG_LOG(RT_DEBUG_IPC, ("sem take: suspend thread - %s\n", thread->parent.name));
thread->name));
/* suspend thread */ /* suspend thread */
ret = _ipc_list_suspend(&(sem->parent.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 */ /* has waiting time, start thread timer */
if (timeout > 0) if (timeout > 0)
{ {
RT_DEBUG_LOG(RT_DEBUG_IPC, ("set thread:%s to timer list\n", RT_DEBUG_LOG(RT_DEBUG_IPC, ("set thread:%s to timer list\n", thread->parent.name));
thread->name));
/* reset the timeout of thread timer and start it */ /* reset the timeout of thread timer and start it */
rt_timer_control(&(thread->thread_timer), 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(); level = rt_hw_interrupt_disable();
RT_DEBUG_LOG(RT_DEBUG_IPC, ("thread %s releases sem:%s, which value is: %d\n", RT_DEBUG_LOG(RT_DEBUG_IPC, ("thread %s releases sem:%s, which value is: %d\n",
rt_thread_self()->name, rt_thread_self()->parent.name,
((struct rt_object *)sem)->name, sem->parent.parent.name,
sem->value)); sem->value));
if (!rt_list_isempty(&sem->parent.suspend_thread)) 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_err_t ret;
RT_DEBUG_LOG(RT_DEBUG_IPC, 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 */ /* change priority of the thread */
rt_thread_control(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, RT_DEBUG_LOG(RT_DEBUG_IPC,
("mutex_take: current thread %s, hold: %d\n", ("mutex_take: current thread %s, hold: %d\n",
thread->name, mutex->hold)); thread->parent.name, mutex->hold));
/* reset thread error */ /* reset thread error */
thread->error = RT_EOK; 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 */ /* mutex is unavailable, push to suspend list */
RT_DEBUG_LOG(RT_DEBUG_IPC, ("mutex_take: suspend thread: %s\n", RT_DEBUG_LOG(RT_DEBUG_IPC, ("mutex_take: suspend thread: %s\n",
thread->name)); thread->parent.name));
/* suspend current thread */ /* suspend current thread */
ret = _ipc_list_suspend(&(mutex->parent.suspend_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, RT_DEBUG_LOG(RT_DEBUG_IPC,
("mutex_take: start the timer of thread:%s\n", ("mutex_take: start the timer of thread:%s\n",
thread->name)); thread->parent.name));
/* reset the timeout of thread timer and start it */ /* reset the timeout of thread timer and start it */
rt_timer_control(&(thread->thread_timer), 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, RT_DEBUG_LOG(RT_DEBUG_IPC,
("mutex_release:current thread %s, hold: %d\n", ("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))); 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); tlist);
RT_DEBUG_LOG(RT_DEBUG_IPC, ("mutex_release: resume thread: %s\n", 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 */ /* remove the thread from the suspended list of mutex */
rt_list_remove(&(next_thread->tlist)); 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(); tick_delta = rt_tick_get();
RT_DEBUG_LOG(RT_DEBUG_IPC, ("mb_send_wait: start timer of thread:%s\n", 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 */ /* reset the timeout of thread timer and start it */
rt_timer_control(&(thread->thread_timer), 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(); tick_delta = rt_tick_get();
RT_DEBUG_LOG(RT_DEBUG_IPC, ("mb_recv: start timer of thread:%s\n", 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 */ /* reset the timeout of thread timer and start it */
rt_timer_control(&(thread->thread_timer), 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(); tick_delta = rt_tick_get();
RT_DEBUG_LOG(RT_DEBUG_IPC, ("mq_send_wait: start timer of thread:%s\n", 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 */ /* reset the timeout of thread timer and start it */
rt_timer_control(&(thread->thread_timer), 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(); tick_delta = rt_tick_get();
RT_DEBUG_LOG(RT_DEBUG_IPC, ("set thread:%s to timer list\n", 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 */ /* reset the timeout of thread timer and start it */
rt_timer_control(&(thread->thread_timer), rt_timer_control(&(thread->thread_timer),

View File

@ -375,7 +375,7 @@ void *rt_smem_alloc(rt_smem_t m, rt_size_t size)
mem->pool_ptr = MEM_USED(); mem->pool_ptr = MEM_USED();
#ifdef RT_USING_MEMTRACE #ifdef RT_USING_MEMTRACE
if (rt_thread_self()) if (rt_thread_self())
rt_smem_setname(mem, rt_thread_self()->name); rt_smem_setname(mem, rt_thread_self()->parent.name);
else else
rt_smem_setname(mem, "NONE"); rt_smem_setname(mem, "NONE");
#endif /* RT_USING_MEMTRACE */ #endif /* RT_USING_MEMTRACE */

View File

@ -312,7 +312,7 @@ void *rt_memheap_alloc(struct rt_memheap *heap, rt_size_t size)
#ifdef RT_USING_MEMTRACE #ifdef RT_USING_MEMTRACE
if (rt_thread_self()) 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 else
rt_memcpy(header_ptr->owner_thread_name, "NONE", sizeof(header_ptr->owner_thread_name)); rt_memcpy(header_ptr->owner_thread_name, "NONE", sizeof(header_ptr->owner_thread_name));
#endif /* RT_USING_MEMTRACE */ #endif /* RT_USING_MEMTRACE */

View File

@ -112,7 +112,7 @@ static void _scheduler_stack_check(struct rt_thread *thread)
{ {
rt_base_t level; 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(); level = rt_hw_interrupt_disable();
while (level); 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)) 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", rt_kprintf("warning: %s stack is close to the top of stack address.\n",
thread->name); thread->parent.name);
} }
#else #else
else if ((rt_ubase_t)thread->sp <= ((rt_ubase_t)thread->stack_addr + 32)) 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", rt_kprintf("warning: %s stack is close to end of stack address.\n",
thread->name); thread->parent.name);
} }
#endif /* ARCH_CPU_STACK_GROWS_UPWARD */ #endif /* ARCH_CPU_STACK_GROWS_UPWARD */
} }
@ -349,8 +349,8 @@ void rt_schedule(void)
"thread:%.*s(sp:0x%08x), " "thread:%.*s(sp:0x%08x), "
"from thread:%.*s(sp: 0x%08x)\n", "from thread:%.*s(sp: 0x%08x)\n",
pcpu->irq_nest, highest_ready_priority, pcpu->irq_nest, highest_ready_priority,
RT_NAME_MAX, to_thread->name, to_thread->sp, RT_NAME_MAX, to_thread->parent.name, to_thread->sp,
RT_NAME_MAX, current_thread->name, current_thread->sp)); RT_NAME_MAX, current_thread->parent.name, current_thread->sp));
#ifdef RT_USING_OVERFLOW_CHECK #ifdef RT_USING_OVERFLOW_CHECK
_scheduler_stack_check(to_thread); _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_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: __exit:
/* enable interrupt */ /* enable interrupt */
@ -608,7 +608,7 @@ void rt_schedule_remove_thread(struct rt_thread *thread)
level = rt_hw_interrupt_disable(); level = rt_hw_interrupt_disable();
RT_DEBUG_LOG(RT_DEBUG_SCHEDULER, ("remove thread[%.*s], the priority: %d\n", 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)); thread->current_priority));
/* remove thread from ready list */ /* remove thread from ready list */

View File

@ -117,7 +117,7 @@ static void _scheduler_stack_check(struct rt_thread *thread)
{ {
rt_base_t level; 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(); level = rt_hw_interrupt_disable();
while (level); 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)) 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", rt_kprintf("warning: %s stack is close to the top of stack address.\n",
thread->name); thread->parent.name);
} }
#else #else
else if ((rt_ubase_t)thread->sp <= ((rt_ubase_t)thread->stack_addr + 32)) 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", rt_kprintf("warning: %s stack is close to end of stack address.\n",
thread->name); thread->parent.name);
} }
#endif /* ARCH_CPU_STACK_GROWS_UPWARD */ #endif /* ARCH_CPU_STACK_GROWS_UPWARD */
} }
@ -281,8 +281,8 @@ void rt_schedule(void)
"thread:%.*s(sp:0x%08x), " "thread:%.*s(sp:0x%08x), "
"from thread:%.*s(sp: 0x%08x)\n", "from thread:%.*s(sp: 0x%08x)\n",
rt_interrupt_nest, highest_ready_priority, rt_interrupt_nest, highest_ready_priority,
RT_NAME_MAX, to_thread->name, to_thread->sp, RT_NAME_MAX, to_thread->parent.name, to_thread->sp,
RT_NAME_MAX, from_thread->name, from_thread->sp)); RT_NAME_MAX, from_thread->parent.name, from_thread->sp));
#ifdef RT_USING_OVERFLOW_CHECK #ifdef RT_USING_OVERFLOW_CHECK
_scheduler_stack_check(to_thread); _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_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 */ /* set priority mask */
#if RT_THREAD_PRIORITY_MAX > 32 #if RT_THREAD_PRIORITY_MAX > 32
@ -414,7 +414,7 @@ void rt_schedule_remove_thread(struct rt_thread *thread)
level = rt_hw_interrupt_disable(); level = rt_hw_interrupt_disable();
RT_DEBUG_LOG(RT_DEBUG_SCHEDULER, ("remove thread[%.*s], the priority: %d\n", 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)); thread->current_priority));
/* remove thread from ready list */ /* remove thread from ready list */

View File

@ -237,7 +237,7 @@ static rt_err_t _thread_init(struct rt_thread *thread,
/* initialize thread timer */ /* initialize thread timer */
rt_timer_init(&(thread->thread_timer), rt_timer_init(&(thread->thread_timer),
thread->name, thread->parent.name,
_thread_timeout, _thread_timeout,
thread, thread,
0, 0,
@ -274,7 +274,7 @@ static rt_err_t _thread_init(struct rt_thread *thread,
#endif /* RT_USING_PTHREADS */ #endif /* RT_USING_PTHREADS */
#ifdef RT_USING_MODULE #ifdef RT_USING_MODULE
thread->module_id = 0; thread->parent.module_id = 0;
#endif /* RT_USING_MODULE */ #endif /* RT_USING_MODULE */
RT_OBJECT_HOOK_CALL(rt_thread_inited_hook, (thread)); 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 */ #endif /* RT_THREAD_PRIORITY_MAX > 32 */
RT_DEBUG_LOG(RT_DEBUG_THREAD, ("startup a thread:%s with priority:%d\n", 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 */ /* change thread stat */
thread->stat = RT_THREAD_SUSPEND; thread->stat = RT_THREAD_SUSPEND;
/* then resume it */ /* 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(rt_object_get_type((rt_object_t)thread) == RT_Object_Class_Thread);
RT_ASSERT(thread == rt_thread_self()); 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; stat = thread->stat & RT_THREAD_STAT_MASK;
if ((stat != RT_THREAD_READY) && (stat != RT_THREAD_RUNNING)) 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(thread != RT_NULL);
RT_ASSERT(rt_object_get_type((rt_object_t)thread) == RT_Object_Class_Thread); 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) if ((thread->stat & RT_THREAD_SUSPEND_MASK) != RT_THREAD_SUSPEND_MASK)
{ {