Running different tasks at different frequency? Design help

abhishekkumar19 wrote on Tuesday, July 24, 2018:

I am new to FreeRTOS and am designing a system in which there will be several tasks running at different frequency. I am just seeking advice how should I be defining the timers/tasks for this kinda of a requirement for example where I have:

  1. one tak running at 500 Hz
  2. another task running at 50 Hz
  3. another task running at 250 Hz
  4. another task running at 1000 Hz

and provided all the taks share the same priority.
Any help or advice is appreciated, please also let me know if this is an incomplete question!

richard_damon wrote on Tuesday, July 24, 2018:

One first question comes how much do these ‘tasks’ need to do. If it is something simple, then they may not need to be a task at all, but could just be a Timer Callback function. If some are more complicated (perhaps needing to do I/O that blocks for a short while) they could be full tasks running in a loop using vTaskDelayUntil().

Since you have a task that needs to run once a millisecond, and all other tasks have a period of multiples of a millisecond, it looks like you want to have your system tick running at 1000 Hz,

I will also put forward a concern that you say that all tasks can be the same priority., as that implies that all of the lower frequency tasks have the potential to delay the higher frequency tasks and make them miss their deadline unless they are also very sort and quick operations. More commonly frequently running tasks are quick but less frequent tasks take longer to run, and thus the higher frequency tasks need to have a higher priority to meet their deadline. Priority is nornmally determined by how short of a deadline the task has, based on when it gets triggered, short deadline tasks need to have a priority higher than tasks that take more time to run.