Hi guys
In my embedded system, I usually have a timer to keep time, and I usually have a many different tasks to run in different interval in the main loop. That's how I usually do it:
It's OK to only have a few task, what if I have 20 different task need to run at different interval, is that a way to write a function like this:
Thanks guys
In my embedded system, I usually have a timer to keep time, and I usually have a many different tasks to run in different interval in the main loop. That's how I usually do it:
Code:
while(1)
{
time_now = get_now();
if (( time_now - time_xyz_task ) > time_1s )
do_task_xyz();
if (( time_now - time_abc_taks ) > time_100ms )
do_taks_abc();
// another task ...
// another task ...
}
Code:
schedule( run_every_1s, some_task_1());
schedule( run_every_2s, some_task_2());
// another task ...
// another task ...
schedule( run_every_ns, some_task_n());