DEV HW: Freescale TWR-K60D100M (ARM Cortex M4)
I have a simple producer consumer set up:
Producer and Consumer task priorities are equal.
void vMsgProducerTask(task_param_t pvParameters)
printf(“starting producer task\n\r”);
uint32_t x = 0;
sprintf(message,“Message # %d”,x);
printf(“producing message %d\n\r”,x);
CHECK_ERR(OSA_MsgQPut(msgQ1_handle,message) != kStatus_OSA_Success);
void vMsgConsumerTask(task_param_t pvParameters)
printf("\n\rstarting consumer task\n\r");
CHECK_ERR(OSA_MsgQGet(msgQ1_handle,message,OSA_WAIT_FOREVER) != kStatus_OSA_Success);
printf(“consuming message: %s\n\r”,message);
OSA_MsgQPut() maps to xQueueSendToBack()
OSA_MsgQGet() maps to xQueueReceive()
So when this code is ran, the following happens:
- Consumer task starts, blocks waiting for message. Queue adds consumer task to xTasksWaitingToReceive.
- Producer task starts, creates message. uxMessagesWaiting increments. Producer task yields.
- Consumer task resumes. Consumer task runs and blocks for new message.
- Producer task resumes. Break before generating message. This time, the queue has added the producer task to the xTasksWaitingToReceive list.
In xTaskRemoveFromEventList(), the xEventListItem next and previous values are 0’s and this causes a hard fault in uxListRemove().
I would think that the consumer task should be added to the waiting list for the message queue (as was done in the first iteration), but the producer task was added instead. And the producer task doesnt need to wait for the queue…
Any thoughts, suggestions, etc for this?