Other Parts Discussed in Thread: SYSBIOS
Hi,
I am new to SYS/BIOS. After I import example project 'memory_EK_TM4C1294XL_TI_TivaTM4C1294NCPDT' to TM4C1294 LaunchPad, I want to to add a task to the project. task1 is dynamic created task. Then, I add a similar task (task3) to task1 to the project. When either one (task1 or task3) is in the project, either one works as the original example project. When both are in the project, it has an exception error:
ti.sysbios.heaps.HeapMem: line 307: out of memory: handle=0x20006618, size=2048
xdc.runtime.Error.raise: terminating execution
I don't know what is the problem. It perhaps does not allow two tasks to create its respective heap memory? I don't know yet. I would give more info about the project.
task1:
#define TASK1BUFSIZE0 128 /* size of allocation */
#define TASK1BUFSIZE1 64 /* size of allocation */
#define TASK1BUFSIZE2 32 /* size of allocation */
#define TASK1BUFSIZE3 16 /* size of allocation */
#define TASK1NUMBUFS 4 /* number of buffers */
Void task1Fxn(UArg arg0, UArg arg1)
{
Ptr bufs[TASK1NUMBUFS];
IHeap_Handle heap = HeapMem_Handle_upCast(task1Heap);
System_printf("Initial task1 heap status\n");
/* print initial task1Heap status */
printHeapStats(heap);
bufs[0] = Memory_alloc(heap, TASK1BUFSIZE0, 0, NULL);
bufs[1] = Memory_alloc(heap, TASK1BUFSIZE1, 0, NULL);
bufs[2] = Memory_alloc(heap, TASK1BUFSIZE2, 0, NULL);
Memory_free(heap, bufs[1], TASK1BUFSIZE1);
Memory_free(heap, bufs[2], TASK1BUFSIZE2);
bufs[3] = Memory_alloc(heap, TASK1BUFSIZE3, 0, NULL);
Memory_free(heap, bufs[0], TASK1BUFSIZE0);
Memory_free(heap, bufs[3], TASK1BUFSIZE3);
System_printf("Final task1 heap status\n");
/* print task1Heap status */
printHeapStats(heap);
System_printf("Task1 Complete\n");
}
......
#define TASK3BUFSIZE0 32 /* size of allocation */
#define TASK3BUFSIZE1 4 /* size of allocation */
#define TASK3BUFSIZE2 4 /* size of allocation */
#define TASK3BUFSIZE3 4 /* size of allocation */
#define TASK3NUMBUFS 4 /* number of buffers */
Void task3(UArg arg0, UArg arg1)
{
Ptr bufs[TASK3NUMBUFS];
IHeap_Handle heap = HeapMem_Handle_upCast(task2heap);
System_printf("Initial TASK3 heap status\n");
/* print initial TASK3Heap status */
printHeapStats(heap);
bufs[0] = Memory_alloc(heap, TASK3BUFSIZE0, 0, NULL);
bufs[1] = Memory_alloc(heap, TASK3BUFSIZE1, 0, NULL);
bufs[2] = Memory_alloc(heap, TASK3BUFSIZE2, 0, NULL);
Memory_free(heap, bufs[1], TASK3BUFSIZE1);
Memory_free(heap, bufs[2], TASK3BUFSIZE2);
bufs[3] = Memory_alloc(heap, TASK3BUFSIZE3, 0, NULL);
Memory_free(heap, bufs[0], TASK3BUFSIZE0);
Memory_free(heap, bufs[3], TASK3BUFSIZE3);
System_printf("Final TASK3 heap status\n");
/* print TASK3Heap status */
printHeapStats(heap);
System_printf("TASK3 Complete\n");
}
...........
Int main()
{
/* Call board init functions */
Board_initGeneral();
Task_create(task1Fxn, NULL, NULL);
Task_create(task3, NULL, NULL);
Is there some restriction I break in the above code?
Thanks,