Skip to content

Commit 75c8515

Browse files
committed
[dlmodule] Add priority and stack size option for dlmodule.
1 parent f89b8ed commit 75c8515

File tree

2 files changed

+21
-8
lines changed

2 files changed

+21
-8
lines changed

components/libc/libdl/dlmodule.c

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -174,16 +174,21 @@ static void _dlmodule_thread_entry(void* parameter)
174174

175175
struct rt_dlmodule *dlmodule_create(void)
176176
{
177-
struct rt_dlmodule *ret = RT_NULL;
177+
struct rt_dlmodule *module = RT_NULL;
178178

179-
ret = (struct rt_dlmodule*) rt_object_allocate(RT_Object_Class_Module, "module");
180-
if (ret)
179+
module = (struct rt_dlmodule*) rt_object_allocate(RT_Object_Class_Module, "module");
180+
if (module)
181181
{
182-
ret->stat = RT_DLMODULE_STAT_INIT;
183-
rt_list_init(&(ret->object_list));
182+
module->stat = RT_DLMODULE_STAT_INIT;
183+
184+
/* set initial priority and stack size */
185+
module->priority = RT_THREAD_PRIORITY_MAX - 1;
186+
module->stack_size = 2048;
187+
188+
rt_list_init(&(module->object_list));
184189
}
185190

186-
return ret;
191+
return module;
187192
}
188193

189194
void dlmodule_destroy_subthread(struct rt_dlmodule *module, rt_thread_t thread)
@@ -519,8 +524,13 @@ struct rt_dlmodule* dlmodule_exec(const char* pgname, const char* cmd, int cmd_s
519524
rt_thread_t tid;
520525

521526
module->cmd_line = rt_strdup(cmd);
527+
528+
/* check stack size and priority */
529+
if (module->priority > RT_THREAD_PRIORITY_MAX) module->priority = RT_THREAD_PRIORITY_MAX - 1;
530+
if (module->stack_size < 2048 || module->stack_size > (1024 * 32)) module->stack_size = 2048;
531+
522532
tid = rt_thread_create(module->parent.name, _dlmodule_thread_entry, (void*)module,
523-
2048, RT_THREAD_PRIORITY_MAX - 1, 10);
533+
module->stack_size, module->priority, 10);
524534
if (tid)
525535
{
526536
tid->module_id = module;

components/libc/libdl/dlmodule.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,11 @@ struct rt_dlmodule
3333
rt_uint8_t stat; /* status of module */
3434

3535
/* main thread of this module */
36+
rt_uint16_t priority;
37+
rt_uint32_t stack_size;
3638
struct rt_thread *main_thread;
37-
int ret_code; /* the return code */
39+
/* the return code */
40+
int ret_code;
3841

3942
/* VMA base address for the first LOAD segment */
4043
rt_uint32_t vstart_addr;

0 commit comments

Comments
 (0)