MCPcopy Create free account
hub / github.com/RT-Thread/rt-thread / dlmodule_exec

Function dlmodule_exec

components/libc/posix/libdl/dlmodule.c:566–603  ·  view source on GitHub ↗

* @brief load a dynamic module, and create a thread to excute the module main function. * * @param pgname path of the module to be loaded. * @param cmd the command string (with commandline options) for startup module. * @param cmd_size the command's length. * @return struct rt_dlmodule* On success, it returns a pointer to the module object. otherwise, RT_NULL is returned. */

Source from the content-addressed store, hash-verified

564 * @return struct rt_dlmodule* On success, it returns a pointer to the module object. otherwise, RT_NULL is returned.
565 */
566struct rt_dlmodule* dlmodule_exec(const char* pgname, const char* cmd, int cmd_size)
567{
568 struct rt_dlmodule *module = RT_NULL;
569
570 module = dlmodule_load(pgname);
571 if (module)
572 {
573 if (module->entry_addr)
574 {
575 /* exec this module */
576 rt_thread_t tid;
577
578 module->cmd_line = rt_strdup(cmd);
579
580 /* check stack size and priority */
581 if (module->priority > RT_THREAD_PRIORITY_MAX) module->priority = RT_THREAD_PRIORITY_MAX - 1;
582 if (module->stack_size < 2048 || module->stack_size > (1024 * 32)) module->stack_size = 2048;
583
584 tid = rt_thread_create(module->parent.name, _dlmodule_thread_entry, (void*)module,
585 module->stack_size, module->priority, 10);
586 if (tid)
587 {
588 tid->parent.module_id= module;
589 module->main_thread = tid;
590
591 rt_thread_startup(tid);
592 }
593 else
594 {
595 /* destory dl module */
596 dlmodule_destroy(module);
597 module = RT_NULL;
598 }
599 }
600 }
601
602 return module;
603}
604
605#if defined(RT_USING_CUSTOM_DLMODULE)
606struct rt_dlmodule* dlmodule_load_custom(const char* filename, struct rt_dlmodule_ops* ops)

Callers 1

msh_exec_moduleFunction · 0.85

Calls 5

dlmodule_loadFunction · 0.85
rt_strdupFunction · 0.85
rt_thread_createFunction · 0.85
rt_thread_startupFunction · 0.85
dlmodule_destroyFunction · 0.85

Tested by

no test coverage detected