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.

Task Creation Failure



Hi,

I am trying to run my program, but fails to create my task. I am not sure how to start debugging this to find my problem, would anybody have any ideas?

The output I see is : Task_create() failed!

Here's the main :

Void main()
{
Task_Params taskParams;
Error_Block eb;

Task_Params_init(&taskParams);
taskParams.priority = 1;
taskParams.stackSize = 8000;
tsk1 = Task_create (task1, &taskParams, &eb);
if (tsk1 == NULL) {
System_printf("Task_create() failed!\n");
//BIOS_exit(0);
}
BIOS_start();
}

My config file is below, one thing I am very confused about is how to set my heap memory. I am not sure if I should set my heap memory via BIOS.heapSize, or using HeapMem, what is the difference between them etc.

var Memory = xdc.useModule('xdc.runtime.Memory');
var System = xdc.useModule('xdc.runtime.System');
var SysStd = xdc.useModule('xdc.runtime.SysStd');
var Error = xdc.useModule('xdc.runtime.Error');
var Diags = xdc.useModule('xdc.runtime.Diags');


var BIOS = xdc.useModule('ti.sysbios.BIOS');
//BIOS.heapSize = 800000;
var Task = xdc.useModule('ti.sysbios.knl.Task');


var xdc_runtime_Timestamp = xdc.useModule('xdc.runtime.Timestamp');

var ti_sysbios_knl_Clock = xdc.useModule('ti.sysbios.knl.Clock');


/* Create default heap and hook it into Memory */

var HeapMem = xdc.useModule('ti.sysbios.heaps.HeapMem');
//var heapMemParams = new HeapMem.Params;
//heapMemParams.size = 8192;
//var heap0 = HeapMem.create(heapMemParams);
//Memory.defaultHeapInstance = heap0;
//Memory.defaultHeapSize = 800000;


/* Configure SysStd to send System_printfs to standard out */
System.SupportProxy = SysStd;

ti_sysbios_knl_Clock.tickPeriod = 100;
  • tsk1 is NULL most likely because there wasn't enough memory in the heap to create the Task object and its stack.

    If you want to see an informational print out of the error, pass 'NULL' instead of the '&eb' to Task_create().

    For most cases, you do NOT need to manually configure the Memory module. BIOS does this for you by default using only the BIOS.heapSize parameter.

    I think you should remove all of your references to HeapMem and Memory and simply set the BIOS.heapSize:

        BIOS.heapSize = 16384;  /* create a heap of 16,384 bytes */

    Alan

  • Hi Alan,

    Thanks for your quick reply! I am able to run my code now.

    Steph

  • Also, as a footnote, passing in an Error Block object without initializing it first can cause BIOS object creation failures, too.  It took me half a day to track that down a few weeks ago.