This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

No.of arguments in Task_create task function.

Other Parts Discussed in Thread: SYSBIOS


Processor: c6657 Gauss DSP

following is a task create function in vxworks. where there are 10 possible arguments to the task function_fn. 
int taskSpawn
    (
    char *  name,             
    int     priority,         
    int     options,       
    int     stackSize,   
    FUNCPTR function_fn,   
    int     arg1,             /* 1st of 10 req'd task args to pass to func */
    int     arg2,
    int     arg3,
    int     arg4,
    int     arg5,
    int     arg6,
    int     arg7,
    int     arg8,
    int     arg9,
    int     arg10
    )
but in Task_create of sysbios I see arg0 and arg1 (2 arguments only). I see elsewhere in the code capability of above number of arguments. 
Pl. advise how to accomodate 10 arguments in the task_create(). 

Regards,
Hari
  • Hi Hari,

    It is not possible to pass more than 2 arguments to a task. If you do need to pass more arguments, you could put all the arguments in a structure object and pass a pointer to the structure.

    Best,

    Ashish

  • Hi Ashish,

      This is a quick response. Appreciate your help. 

        I see in sysbios \bios_6_33_06_50\packages\ti\bios\tsk.c:

         The implementation is a wrapper function over regular task functions defined. Can we use these functions? 

    Hari

    /*
    * ======== dynamicGlue ========
    * used to create dynamically created tasks
    */
    static Void dynamicGlue(UArg arg0)
    {
    TSK_Glue *glue = ((TSK_Glue *)arg0);
    Fxn fxn = glue->fxn;
    Arg *args = glue->args;
    Task_Handle tsk;

    tsk = Task_self();
    tsk->fxn = (ti_sysbios_knl_Task_FuncPtr)fxn;

    fxn(args[0], args[1], args[2], args[3], args[4], args[5], args[6], args[7]);
    }

    /*
    * ======== TSK_checkstacks ========
    */
    Void TSK_checkstacks(TSK_Handle oldtask, TSK_Handle newtask)
    {
    Task_checkStacks((Task_Handle)oldtask, (Task_Handle)newtask);
    }

    /*
    * ======== TSK_create ========
    */
    TSK_Handle TSK_create(Fxn fxn, TSK_Attrs *attrs, ...)
    {
    Int i;
    va_list arglist;
    TSK_Handle task;
    TSK_Glue *glue;
    Task_Params params;
    Error_Block eb;


    Task_Params_init(&params);

    /* Use segid 0. No alignment needed */
    glue = MEM_alloc(0, sizeof(TSK_Glue), 0);

    if (glue == NULL) {
    return (NULL);
    }

    if (attrs == NULL) {
    attrs = &TSK_ATTRS;
    }

    params.instance->name = attrs->name;
    params.priority = attrs->priority;
    params.stack = attrs->stack;
    params.stackSize = attrs->stacksize;
    params.stackHeap = MEM_getHandle(attrs->stackseg);
    params.env = attrs->environ;
    params.vitalTaskFlag = attrs->exitflag;

    params.arg0 = (UArg)glue;

    /*
    * Encode arg1 with the fxn for ROV to use prior to task running
    */
    params.arg1 = (UArg)fxn;

    /* copy args from stack into argument buffer */
    va_start(arglist, attrs);
    for (i = 0; i < TSK_MAXARGS; i++) {
    glue->args[i] = (Arg)va_arg(arglist, UArg);
    }
    va_end(arglist);

    glue->fxn = fxn;
    glue->errno = 0;

    Error_init(&eb);
    task = (TSK_Handle)Task_create((Task_FuncPtr)dynamicGlue, &params, &eb);

    if (task == NULL) {
    /* Use segid 0 */
    MEM_free(0, glue, sizeof(TSK_Glue));
    }

    return (task);
    }

  • Hi Hari,

    This package (bios_6_33_06_50\packages\ti\bios) contains code to support the legacy DSP/BIOS APIs and we would not recommend using these for SYS/BIOS development. I still think the best way to pass more arguments is to create a structure of 10 arguments and pass a pointer to the structure.

    Best,

    Ashish