change module priority;

strip module name from loaded path;

git-svn-id: https://rt-thread.googlecode.com/svn/trunk@2262 bbd45198-f89e-11dd-88c7-29a3b14d5316
This commit is contained in:
qiuyiuestc@gmail.com 2012-08-27 01:19:04 +00:00
parent d5a0362bb4
commit 907e1703e6
1 changed files with 27 additions and 2 deletions

View File

@ -785,7 +785,7 @@ rt_module_t rt_module_load(const char *name, void *module_ptr)
/* create module thread */ /* create module thread */
module->stack_size = 2048; module->stack_size = 2048;
module->thread_priority = RT_THREAD_PRIORITY_MAX - 1; module->thread_priority = RT_THREAD_PRIORITY_MAX - 2;
module->module_thread = rt_thread_create(name, module->module_thread = rt_thread_create(name,
(void(*)(void *))module->module_entry, RT_NULL, (void(*)(void *))module->module_entry, RT_NULL,
module->stack_size, module->stack_size,
@ -814,6 +814,28 @@ rt_module_t rt_module_load(const char *name, void *module_ptr)
return module; return module;
} }
static char* module_name(const char *path)
{
char *first, *end, *name;
int size;
char *ptr = (char*)path;
while(*ptr != '\0')
{
if(*ptr == '/') first = ptr + 1;
if(*ptr == '.') end = ptr - 1;
ptr++;
}
size = end - first + 1;
name = rt_malloc(size);
rt_strncpy(name, first, size);
name[size] = '\0';
return name;
}
#ifdef RT_USING_DFS #ifdef RT_USING_DFS
#include <dfs_posix.h> #include <dfs_posix.h>
/** /**
@ -829,6 +851,7 @@ rt_module_t rt_module_open(const char *path)
struct rt_module *module; struct rt_module *module;
struct stat s; struct stat s;
char *buffer, *offset_ptr; char *buffer, *offset_ptr;
char* name;
RT_DEBUG_NOT_IN_INTERRUPT; RT_DEBUG_NOT_IN_INTERRUPT;
@ -879,8 +902,10 @@ rt_module_t rt_module_open(const char *path)
return RT_NULL; return RT_NULL;
} }
module = rt_module_load(path, (void *)buffer); name = module_name(path);
module = rt_module_load(name,(void *)buffer);
rt_free(buffer); rt_free(buffer);
rt_free(name);
return module; return module;
} }