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

时间:2023-03-09 16:46:33
linux 和 ecos 内核线程创建/信号量/event等对比

ecos:

 int gx_thread_create (const char *thread_name, gx_thread_id *thread_id,
void(*entry_func)(void *), void *arg,
void *stack_base,
unsigned int stack_size,
unsigned int priority,
gx_thread_info *thread_info)
{
#define GX_THREAD_PRIORITY_MAX 255 if (priority > GX_THREAD_PRIORITY_MAX || thread_id == NULL \
|| entry_func == NULL || thread_name == NULL \
|| stack_base == NULL || thread_info == NULL)
return -; cyg_thread_create_ex((cyg_addrword_t)priority, (cyg_thread_entry_t *)entry_func, (cyg_addrword_t)arg,
(char *)thread_name, stack_base, (cyg_ucount32)stack_size, thread_id, thread_info, ); cyg_thread_resume(*thread_id); return ;
}

linux:

 int gx_thread_create (const char *thread_name, gx_thread_id *thread_id,
void(*entry_func)(void *), void *arg,
void *stack_base,
unsigned int stack_size,
unsigned int priority,
gx_thread_info *thread_info)
{
struct task_struct *task = NULL; task = kthread_create((int (*)(void *))entry_func, arg, "%s",thread_name);
if(task == NULL)
return -; GXAV_DBG("%s(),task : %p\n",__func__,task); *thread_id = (unsigned int)task; GXAV_DBG("%s(),thread_id : 0x%x\n",__func__,*thread_id); wake_up_process(task); return ;
}

aa