首页 > 其他 > 详细

LiteOS创建任务的一个BUG

时间:2018-07-27 17:56:28      阅读:320      评论:0      收藏:0      [点我收藏+]

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

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

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

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!