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.

Can't Create Dynamic Tasks in DSP/BIOS 5.33.06

Here's a snippet of a dynamic task creation:

 

    tsk_attrs = TSK_ATTRS;
    tsk_attrs.priority = 2;
    tsk_attrs.name = "Test";
    tsk = TSK_create((Fxn)TestTask, &tsk_attrs);

The task function is this:

 

void TestTask()
{
  while (1)
  {
    TSK_sleep(1000);
  }
}

However, the return value of TSK_create is 0, indicating it failed. I cannot see any reason why it would fail. Any suggestions?

 

  • I also cannot find the definition of the TSK_ATTRS default values. the tsk.h file says it's defined in tsk.c, but it's not in tsk.c.

     

    --Randy

  • Randy Yates said:

    However, the return value of TSK_create is 0, indicating it failed. I cannot see any reason why it would fail. Any suggestions?

    Usually it is because you do not have enough heap to allocate the task. Please take a look at the DSP/BIOS examples that create tasks dynamically.

    This one does:

    ...\bios_5_41_03_17\packages\ti\bios\examples\advanced\msgq_tsk2tsk\

    Randy Yates said:
    I also cannot find the definition of the TSK_ATTRS default values. the tsk.h file says it's defined in tsk.c, but it's not in tsk.c.

    Here are the default attributes:

    TSK_Attrs TSK_ATTRS = {
        0,   /* priority */
        NULL,  /* stack */
        0,   /* stacksize */
    #ifdef _55_
        0,  /* sys stacksize*/
    #endif
        0,   /* stackseg */
        NULL,  /* environ */
        "",  /* name */
        TRUE, /* exitflag */
        TRUE /* initstackflag */
    };

     

     

  • Mariana,

     

    Thanks for the suggestion and the TSK_ATTRS defaults. I still wonder where TI hid those.. grepping the whole bios directory tree for "TSK_ATTRS" in all .c files revealed zip.

    I too suspected heap and increased my heap size, but that wasn't the problem. The problem <drum roll, please> was that the "Stack segment for dynamic tasks" in the Task Manager Properties was set to MEM_NULL. Arg! Shouldn't this be in the DSP/BIOS API guide? Like, under TSK_create()?

    Also, what if I wanted to have dynamically-created tasks utilize a different segment? How does one, in C at run-time, obtain the "Int" required by the stackseg element?

    --Randy

  • OK, it IS in the manual, in the overview of the TSK module. My oversight! It seems a mention of it under TSK_create would add to the value of the document, however.