linux 和 ecos 内核线程创建/信号量/event等对比

ecos:

 1 int gx_thread_create (const char *thread_name, gx_thread_id *thread_id,
 2         void(*entry_func)(void *), void *arg,
 3         void *stack_base,
 4         unsigned int stack_size,
 5         unsigned int priority,
 6         gx_thread_info *thread_info)
 7 {
 8 #define GX_THREAD_PRIORITY_MAX  255
 9 
10     if (priority > GX_THREAD_PRIORITY_MAX || thread_id == NULL \
11             || entry_func == NULL || thread_name == NULL \
12             || stack_base == NULL || thread_info == NULL)
13         return -1; 
14 
15     cyg_thread_create_ex((cyg_addrword_t)priority, (cyg_thread_entry_t *)entry_func, (cyg_addrword_t)arg,
16             (char *)thread_name, stack_base, (cyg_ucount32)stack_size, thread_id, thread_info, 0); 
17 
18     cyg_thread_resume(*thread_id);
19 
20     return 0;
21 }

 linux:

 1 int gx_thread_create (const char *thread_name, gx_thread_id *thread_id,
 2         void(*entry_func)(void *), void *arg,
 3         void *stack_base,
 4         unsigned int stack_size,
 5         unsigned int priority,
 6         gx_thread_info *thread_info)
 7 {
 8     struct task_struct *task = NULL;
 9 
10     task = kthread_create((int (*)(void *))entry_func, arg, "%s",thread_name);
11     if(task == NULL)
12         return -1; 
13 
14     GXAV_DBG("%s(),task : %p\n",__func__,task);
15 
16     *thread_id = (unsigned int)task;
17 
18     GXAV_DBG("%s(),thread_id : 0x%x\n",__func__,*thread_id);
19 
20     wake_up_process(task);
21 
22     return 0;
23 }

 

 

aa

posted @ 2014-12-27 20:50  静之深  阅读(601)  评论(0编辑  收藏  举报