Peter Mueller wrote:
I have the problem that I need two background tasks. The first task has
a cycle time of 10 ms, the second one of 1000ms. In the second task I
want to execute a complex algorithm taking much longer than 10ms.
Therefore it is not possible to run both in a while(1) loop. One way to
ok
solve to problem would be to break the algorithm up into short chunks to
> be able execute the faster task in time, which I would not like to do
> (if possible).
yes, thats a good solution, and you probably end up with that one ;-)
Is there a good way to solve this problem without an OS? Is there a
simple scheduler available?
yes, there is one in the examples repository in the CVS.
but its a cooperative scheduler, that means that you hav to call
SWITCH(); by hand. task switches can only occur on SWITCH calls, that
means you have to place some of these calls in your algorithm (making
chunks ;-)
to write a preemtive or time slice scheduler is probably possible too,
using the timer interrupts and issuing context switches, but that way a
lot of problems arise too, speaking of semaphores, mutexes, locks,
messages, ...
can you consider to run the 10ms task in a timer interrupt? the "long"
task can run in a while(1) in the foreground, while it gets interrupted
every 10ms by an interrupt. if you dont have free timers, maybe the
watchdog timer in timer mode can be an option.
chris