I need help with designing my RTOS system. My application is running on a frequency 20 KHz, and consists of three main tasks. I have it functional with a sequential scheduler with adjustable frequencies. Say, Task1 and Task2 will run at 20KHz and Task3 will run at 10KHz. So each 50 uS Task1 Task2 will run and Task3 will run each 100 uS.
I am trying to implement this using RTOS, to evaluate how this will affect the system.
My First question is: Can FreeRTOS handle these frequencies, the sum of the e.t of all functions combined is almost 50 uS.
Also, I am having trouble now understanding which function RTOS decides to run. I am using vTaskDelayUntil to control the function at a specific period.
So if I want to run two tasks at a frequency and the third at half this frequency, how can I do it?
Having a tick rate that high is a bit unusual for an RTOS, but depending on the processor it is possible (Don’t try it on a low power processor running at just a few megahertz). FreeRTOS has no natural tick rate limits except processor bandwidth. An interrupt, and a context switch will take a certain number of processor cycles, and if you try to do it too often, you spend a lot of time in system overhead.
Using a tick of 50 us (20kHz) Task1 and Task2 could be using a simple vTaskDelay/vTaskDelayUntil of 1 tick, and Task3 of 2 ticks. Then when the tick interrupt occurs, Task1 will wake up, do its stuff, and the block o the delay, which will cause a switch to task2, which will run, and then when it delays, task3 will run if it is time.
Since Task1 and Task2 are running at the same rate, and sound like they are running on a per time basis, it may well be possible to just combine them into a single task to eliminate some ot the task delays by making a Task12 which basically first does the stuff of Task1, and then does the stuff assigned to Task2. This assumes that Task1 doesn’t block a lot to have been able to give time to Task2, but at these speeds, I find that tends to be unlikely. Task3 may even be able to be folded into this task, with just a check for every other cycle (that depend on if task3 can finish in time to run Task1 on schedule or not). If this is the case, you may not need an RTOS at all.
It may seem strange, but very high speed system which just need very simple scheduling often don’t need an RTOS, the RTOS is more needed when you have a number of somewhat slower but time critical tasks that don’t have a simple scheduling (like many things ‘on demand’ as opposed to time based).
Having a tick rate that high is a bit unusual for an RTOS, but depending on the processor it is possible (Don’t try it on a low power processor running at just a few megahertz). FreeRTOS has no natural tick rate limits except processor bandwidth. An interrupt, and a context switch will take a certain number of processor cycles, and if you try to do it too often, you spend a lot of time in system overhead.
Using a tick of 50 us (20kHz) Task1 and Task2 could be using a simple vTaskDelay/vTaskDelayUntil of 1 tick, and Task3 of 2 ticks. Then when the tick interrupt occurs, Task1 will wake up, do its stuff, and the block o the delay, which will cause a switch to task2, which will run, and then when it delays, task3 will run if it is time.
Since Task1 and Task2 are running at the same rate, and sound like they are running on a per time basis, it may well be possible to just combine them into a single task to eliminate some ot the task delays by making a Task12 which basically first does the stuff of Task1, and then does the stuff assigned to Task2. This assumes that Task1 doesn’t block a lot to have been able to give time to Task2, but at these speeds, I find that tends to be unlikely. Task3 may even be able to be folded into this task, with just a check for every other cycle (that depend on if task3 can finish in time to run Task1 on schedule or not). If this is the case, you may not need an RTOS at all.
It may seem strange, but very high speed system which just need very simple scheduling often don’t need an RTOS, the RTOS is more needed when you have a number of somewhat slower but time critical tasks that don’t have a simple scheduling (like many things ‘on demand’ as opposed to time based).
I am using it with a STM32F469 micrcontroller running at 180 MHz.
I totally agree with you regarding the need for RTOS, I am just exploring the possibility of its intergation in such frequency.
And as you said, I already implemented a sequential scheduler and it works very good and which is driven by a timer interrupt at the required time period which is 50 uS.
Thank you very much for your reponse, it also showed me that I am already on the right track