HI ,
These days I am studying the MessageQ of C6678,the test is very easy ,I use core1 to send Message to core0. The following is:
Core0 creates the HeapBuf and Core1 opens the heap which core0 creates. And then registere the heap to MessageQ .core0 and core1 create the
each of MessageQ and open the MessageQ . Then core1 allocates the msg and sends to core0, core0 gets the msg from core1 and frees the msg..
when the loop of that runs for a long time,there will be an error like this:
[C66xx_1] ti.sdo.ipc.heaps.HeapBufMP: line 619: E_noBlocksLeft: No more blocks left in buffer (handle = 0x803260, requested size = 32) MessageQ_alloc failed
when I encrease the heapBufParams.numBlocks,the error is also appearing. this error maybe means no block on the core1,but I was free the msg on core0.So how can I resolve the problem or What should I do to resolve the problem ?
Thanks all.
the code is belowing:
#define HEAP_NAME "myHeapBuf"
#define HEAPID 0
#define NUMLOOPS 1
Char *localQueueName[] = {"CORE0","CORE1"};
Char *nextQueueName[] = {"CORE1","CORE0"};
Void C6678_MessageQtest(UArg arg0, UArg arg1) {
MessageQ_Msg msg;
MessageQ_Handle messageQ;
MessageQ_QueueId remoteQueueId = 0;
Int status;
UInt16 msgId = 0;
HeapBufMP_Handle heapHandle;
HeapBufMP_Params heapBufParams;
int coreid;
coreid = MultiProc_self();
if (coreid == 0) {
/* * Create the heap that will be used to allocate messages. */
HeapBufMP_Params_init(&heapBufParams);
heapBufParams.regionId = 0;
heapBufParams.name = HEAP_NAME;
heapBufParams.numBlocks = 6;
heapBufParams.blockSize = 4 * sizeof(MessageQ_MsgHeader);
heapHandle = HeapBufMP_create(&heapBufParams);
if (heapHandle == NULL) {
System_abort("HeapBufMP_create failed\n" );
}
} else if(coreid == 1){
/* Open the heap created by the other processor. Loop until opened. */
do { status = HeapBufMP_open(HEAP_NAME, &heapHandle);
/* * Sleep for 1 clock tick to avoid inundating remote processor
* with interrupts if open failed */
if (status < 0) {
Task_sleep(1);
}
} while (status < 0); }
/* Register this heap with MessageQ */
MessageQ_registerHeap((IHeap_Handle)heapHandle, HEAPID);
/* Create a message queue using SyncSem as synchronizer */
SyncSem_Handle syncSemHandle = NULL;
syncSemHandle = SyncSem_create(NULL, NULL);
MessageQ_Params msgQParams;
MessageQ_Params_init(&msgQParams); msgQParams.synchronizer = SyncSem_Handle_upCast(syncSemHandle);
/* Create the local message queue */
messageQ = MessageQ_create(localQueueName[coreid], &msgQParams);
if (messageQ == NULL) {
printf("MessageQ_create failed\n" );
}else{
printf("MessageQ_create is ok\n");
}
if (coreid == 1) {
/* Open the remote message queue. Spin until it is ready. */
do { status = MessageQ_open(nextQueueName[coreid], &remoteQueueId);
/* * Sleep for 1 clock tick to avoid inundating remote processor * with interrupts if open failed */
if (status < 0) {
Task_sleep(1);
}
} while (status < 0); }
if (coreid == 1) {
while(1) {
/* Allocate a message to be ping-ponged around the processors */
msg = MessageQ_alloc(HEAPID, sizeof(MessageQ_MsgHeader));
if (msg == NULL) {
System_abort("MessageQ_alloc failed\n" ); }
/* Increment...the remote side will check this */
msgId++;
MessageQ_setMsgId(msg, msgId);
/* send the message to the remote processor */
status = MessageQ_put(remoteQueueId, msg);
if (status < 0) {
System_abort("MessageQ_put had a failure\n");
}
Task_sleep(30);
}
} else if(coreid == 0){
while(1) {
/* Get a message */
printf("I am core 0:%d\n",msgId);
status = MessageQ_get(messageQ, &msg, MessageQ_FOREVER);
if (status < 0) {
System_abort("This should not happen since timeout is forever\n");
}
/* Get the message id */ msgId = MessageQ_getMsgId(msg);
status = MessageQ_free(msg);
if (status < 0) {
System_abort("MessageQ_free is error\n"); }
printf("I am core 0 ,I have get the msg msgId:%d from core1\n",msgId);
Task_sleep(30);
}
}
}