码迷,mamicode.com
首页 > 编程语言 > 详细

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

时间:2014-12-27 21:38:08      阅读:291      评论:0      收藏:0      [点我收藏+]

标签:

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

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

标签:

原文地址:http://www.cnblogs.com/jingzhishen/p/4189166.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!