How to make each task time guaranteed?

i am running tasks, one task is strongly time guaranteed needed.
it means that the task should be running in a exact given time, if the task is out of the expected time, then should restart again.
my idea is using

VtaskdelayUntil();

to realize the aim.
my question is : are there some other options that I can realize the
request?
thanks advance.

Depending on your constraints regarding jitter you could use a HW timer doing the real-time processing in the ISR (lowest jitter, especially if the interrupt priority is outside the FreeRTOS covered range) or signal the expiration e.g. via task notification to a high(est) prio post-processing task or use a FreeRTOS timer doing the (non-blocking) processing in the timer callback or just again notify a post-processing task (worst jitter).
Using FreeRTOS timers doesn’t provide lower jitter than your approach because internally it’s also based on task delay/SysTick.
If you have to do more complex processing your approach is likely the best one given the task is the highest prio task in your application.
See also this interesting post regarding comparison of using task delay or FreeRTOS timers.
However, when using a task you’ll have to deal with jitters caused by interrupts kicking in and some (very short) critical sections in the FreeRTOS code and maybe in your application if you’re using them.

+1 Regarding FreeRTOS timers. To reiterate, doing so with tasks you’d have to set the tick period such that the time threshold for this task is an integer multiple of it. You’ll still have jitter, but excluding that, the scheduling should line up with the timeout.

Perhaps there’s some acceptable amount of error for the task, allowing for some jitter? If not, directly using a hardware timer or native ISR is probably more appropriate IMO.

1 Like

If you use vTaskdelayUntil API instead of a hardware timer interrupt.
Suggest to set the task priority higher than other tasks.

1 Like

Another thing to consider is that even if your task has highest priority, it may be starved out by ISRs. Ensuring the required timing is a job of system design which an RTOS can only supplement with the right tool box.