码迷,mamicode.com
首页 > 其他好文 > 详细

LiteOS创建任务的一个BUG

时间:2018-07-27 18:05:02      阅读:338      评论:0      收藏:0      [点我收藏+]

标签:att   attr   kinit   cms   self   thread   char   创建   无法   

在任务创建的时候,参数无法传递,第二个参数本来是用来做参数传递的,但是却没用到,很尴尬啊,缺少了这个功能,很多无法写了?

osThreadId_t osThreadNew (osThreadFunc_t func, void *argument, const osThreadAttr_t *attr)
{
    UNUSED(argument);

    UINT32 uwTid;
    UINT32 uwRet;
    LOS_TASK_CB *pstTaskCB = NULL;
    TSK_INIT_PARAM_S stTskInitParam;

    if (OS_INT_ACTIVE)
    {
        return NULL;
    }

    if ((attr == NULL) ||
        (func == NULL) ||
        (attr->priority < osPriorityLow1) ||
        (attr->priority > osPriorityAboveNormal6))
    {
        return (osThreadId_t)NULL;
    }

    memset(&stTskInitParam, 0, sizeof(TSK_INIT_PARAM_S));
    stTskInitParam.pfnTaskEntry = (TSK_ENTRY_FUNC)func;
    stTskInitParam.uwStackSize  = attr->stack_size*4;
    stTskInitParam.pcName       = (CHAR *)attr->name;
    stTskInitParam.usTaskPrio   = OS_TASK_PRIORITY_LOWEST - ((UINT16)(attr->priority) - LOS_PRIORITY_WIN); /*0~31*/
    stTskInitParam.uwResved     = LOS_TASK_STATUS_DETACHED; /*the cmsis task is detached,the task can deleteself*/

    uwRet = LOS_TaskCreate(&uwTid, &stTskInitParam);

    if (LOS_OK != uwRet)
    {
        return (osThreadId_t)NULL;
    }

    pstTaskCB = OS_TCB_FROM_TID(uwTid);

    return (osThreadId_t)pstTaskCB;
}

 

LiteOS创建任务的一个BUG

标签:att   attr   kinit   cms   self   thread   char   创建   无法   

原文地址:https://www.cnblogs.com/429512065qhq/p/9378858.html

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