Other Parts Discussed in Thread: SYSBIOS
Dear support,
I have already asked a few questions regarding message queues and heap. I thought I understood but I guess I don't. I cannot get the "heap" and "messageQ" to work together because I am not sure I understand how they interact. Can you please help.
The idea in the code is that I have communication between cores and communication between threads in the same core.
The inter_core is working (following example from the wizard using shared region), I am having problems for the inter_thread because I am not sure how to allocate a heap that will be assigned to the messages and use it there. There are examples (like memory or messageQ from the wizard) but too much is done in the cfg file that I cannot use as it.
Let's say that a would like 2 pools of set size messages that will be used for 2 different purposes. Here what I thought I should have been done (repeat the same procesure for all the pools I need to create)
1) allocate a big enough heap global to the program in the config file:
var Memory = xdc.useModule('xdc.runtime.Memory')
var HeapMem = xdc.useModule('ti.sysbios.heaps.HeapMem');
var HeapBuf = xdc.useModule('ti.sysbios.heaps.HeapBuf');
/* confgiure a heap */
var HeapMem = xdc.useModule('ti.sysbios.heaps.HeapMem');
var heapMemParams = new HeapMem.Params();
/* size of 64k */
heapMemParams.size = 0x10000;
heapMemParams.sectionName = "systemHeap";
Program.global.heap0 = HeapMem.create(heapMemParams);
2) now that I have a big heap, I can allocate segments of this heap to use for any purpose (let say a segment of 10 buffers of 64 bytes)
heapSize = NUM_MTS_MSG * sizeof(MTS_MSG_TYPE);
heapAddress = Osal_platformMalloc(heapSize,0);
prms.blockSize = sizeof(MTS_MSG_TYPE);
prms.numBlocks = NUM_MTS_MSG;
prms.buf = heapAddress;
prms.bufSize = heapSize;
gMtsHeapHandle = HeapBuf_create(&prms, &eb);
gMtsHeapAddress = heapAddress;
3) All seems to be ok up to this point as far as I can see using ROV.So since I have a section, I can assign it to the message Q using any id I want as long as it is not used, then I will be able to use MessageQ_alloc using the same heapID.
MessageQ_registerHeap (gMtsHeapAddress,MTS_HEAP_ID_MSG_REGISTRATION); (return 0)
ROV does not show anything in the MessageQ module, I am not sure it works
4) Now I should be able to use this pool to allocate and free. However, I will need to cast to the real messages I want
msg = (MTS_MSG_TYPE*) MessageQ_alloc(MTS_HEAP_ID_MSG_REGISTRATION,sizeof(MTS_MSG_TYPE))
And I got:
00001a B23=0x1028262
B24=0x23343642 B25=0x4a4101
B26=0xbab550a7 B27=0x0
B28=0x0 B29=0x1
B30=0xffffffff B31=0xffffffff
NTSR=0x1000c
ITSR=0x0
IRP=0x0
SSR=0x0
AMR=0x0
RILC=0x0
ILC=0x0
Exception at 0x0
EFR=0x2 NRP=0x0
Internal exception: IERR=0x1
Instruction f[C66xx_0] etch exception
ti.sysbios.family.c64p.Exception: line 248: E_exceptionMin: pc = 0x00000000, sp = 0x00889220.
To see more exception detail, use ROV or set 'ti.sysbios.family.c64p.Exception.enablePrint = t[C66xx_0] rue;'
xdc.runtime.Error.raise: terminating execution
What am I not understanding? Isn't it the way to allocate a heap to the messaging module?
Furthermore, I do I get the statistics of my heaps? (the one for messages and the global one)
Here is the releavnt code that I am using1057.heap_messages.c