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.

TM4C1294NCPDT: Race condition with Serial to Ethernet Converter example

Part Number: TM4C1294NCPDT

Hi,

This is with regard to the Serial to Ethernet Converter Demo, using Tiva TM4C129 Controller: http://www.ti.com/lit/ug/tidu951/tidu951.pdf

An overview of software architecture used with FreeRTOS suggests to me that there can be a data race-condition/concurrency-issue between the Serial Task and the TCP-IP thread. The data received over Serial is being queued onto the Ring buffer (using the 'RingBuf' utilities library). This API is not thread safe, and no FreeRTOS API's are being used to ensure thread safety around it. 

Is this a problem? Will there be undefined behavior when, for example, Ethernet task is preempted while using the Ring buffer API, by the Serial task, which also uses Ring buffer API?

I am using EK-TM4C129XL for the evaluation.

  • Hello Omkar,

    Very good question.

    While filling and emptying the ring buffer, the S2E example uses the functions "RingBufWriteOne" and "RingBufReadOne". These functions disables interrupts when updating the index. So preemption should not cause data corruption. This utility could be improved by using FreeRTOS APIs, but I think it does the job.

    Data corruption could still be caused if the ring buffer gets filled up sooner than getting emptied. This can be handled by having a large enough ring buffer and the updating the frequency with which the tasks free-up the buffer.

    Thanks,
    Sai