提交 32d325b7 编写于 作者: mysterywolf's avatar mysterywolf

[kenel] add static name for rt_object

上级 19106eb3
...@@ -398,7 +398,11 @@ typedef struct rt_slist_node rt_slist_t; /**< Type for single lis ...@@ -398,7 +398,11 @@ typedef struct rt_slist_node rt_slist_t; /**< Type for single lis
*/ */
struct rt_object struct rt_object
{ {
char name[RT_NAME_MAX]; /**< name of kernel object */ #if RT_NAME_MAX == 0
char *name; /**< static name of kernel object */
#else
char name[RT_NAME_MAX]; /**< dynamic name of kernel object */
#endif /* RT_NAME_MAX == 0 */
rt_uint8_t type; /**< type of kernel object */ rt_uint8_t type; /**< type of kernel object */
rt_uint8_t flag; /**< flag of kernel object */ rt_uint8_t flag; /**< flag of kernel object */
...@@ -630,7 +634,11 @@ struct rt_cpu ...@@ -630,7 +634,11 @@ struct rt_cpu
struct rt_thread struct rt_thread
{ {
/* rt object */ /* rt object */
char name[RT_NAME_MAX]; /**< the name of thread */ #if RT_NAME_MAX == 0
char *name; /**< static name of kernel object */
#else
char name[RT_NAME_MAX]; /**< dynamic name of kernel object */
#endif /* RT_NAME_MAX == 0 */
rt_uint8_t type; /**< type of object */ rt_uint8_t type; /**< type of object */
rt_uint8_t flags; /**< thread's flags */ rt_uint8_t flags; /**< thread's flags */
......
...@@ -2,7 +2,7 @@ menu "RT-Thread Kernel" ...@@ -2,7 +2,7 @@ menu "RT-Thread Kernel"
config RT_NAME_MAX config RT_NAME_MAX
int "The maximal size of kernel object name" int "The maximal size of kernel object name"
range 2 32 range 0 64
default 8 default 8
help help
Each kernel object, such as thread, timer, semaphore etc, has a name, Each kernel object, such as thread, timer, semaphore etc, has a name,
......
...@@ -306,13 +306,21 @@ static void rt_thread_system_entry(void *parameter) ...@@ -306,13 +306,21 @@ static void rt_thread_system_entry(void *parameter)
void rt_thread_idle_init(void) void rt_thread_idle_init(void)
{ {
rt_ubase_t i; rt_ubase_t i;
#if RT_NAME_MAX > 0
char idle_thread_name[RT_NAME_MAX]; char idle_thread_name[RT_NAME_MAX];
#endif /* RT_NAME_MAX > 0 */
for (i = 0; i < _CPUS_NR; i++) for (i = 0; i < _CPUS_NR; i++)
{ {
rt_sprintf(idle_thread_name, "tidle%d", i); #if RT_NAME_MAX > 0
rt_snprintf(idle_thread_name, RT_NAME_MAX, "tidle%d", i);
#endif /* RT_NAME_MAX > 0 */
rt_thread_init(&idle_thread[i], rt_thread_init(&idle_thread[i],
#if RT_NAME_MAX > 0
idle_thread_name, idle_thread_name,
#else
"tidle",
#endif /* RT_NAME_MAX > 0 */
idle_thread_entry, idle_thread_entry,
RT_NULL, RT_NULL,
&idle_thread_stack[i][0], &idle_thread_stack[i][0],
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册