Continuous execution of a Task

Many thanks for the inputs @aggarg. I think your suggestions and example code brought much clarity. I learnt from it and tried to bring logic to my code. I still have some queries left.

  • Regarding my queue point: I implemented simple FreeRTOS tasks. One used to push to the queue and another one used to pull from the queue. This ran infinitely without any error or unexpected performance. So the issue was with some of my simple link tasks for socket communication.
  • update 1 from the example code: I could implement UDP send task on one microcontroller and UDP receive task on another microcontroller that ran for more than messages. So that issue is resolved.
  • query 1 From the example code: while server task (receive task) has higher priority as compared to the client task (sender task). There is no vTaskDelay implemented at the end of UDP server task. Then how does task switching take place between server task and client task?
  • query 2 from the example code: in continuation with my first query, as I implemented server receive) task and client (sender) task, sequence of task execution is a bit random. Have a look at the image below. Transmit and Receive messages are completely random. By any chance do you have any idea what may be the probable cause and how do I make it more streamlined in which sequence be like:
    received…
    transmitted…
    received…
    transmitted…
    received…
    transmitted…
    received…
    transmitted…

Thanks,
H C Trivedi