R
refigh
hi every body,
I have a embedded board with a processor without OS on it. there are
some independent tasks which should be run always. I put them into a
while(true) loop and call them one after another i.g.
while(true){
task(1);
task(2);
task(3);
}
by above code it seems they are run concurrently.
sometimes one of these task takes too much time and then causes
problem for other tasks. I want to emulate context switch in c++. the
method I consider to implement is:
I divide each task to some reasonable parts and after reach any of
these checkpoints, a task should return and a task_manager in body of
main function select another task to continue( for example by a
priority mechanism ).
but I think pausing a function is not easy? am I right? I think I must
define many variables as static and also save the inputs of function
for call a paused function again,
is there a simpler method in assembly? does anybody has a better
suggestion?
( I should mention that it is not possible to use interrupts for me
also. )
thanks.
I have a embedded board with a processor without OS on it. there are
some independent tasks which should be run always. I put them into a
while(true) loop and call them one after another i.g.
while(true){
task(1);
task(2);
task(3);
}
by above code it seems they are run concurrently.
sometimes one of these task takes too much time and then causes
problem for other tasks. I want to emulate context switch in c++. the
method I consider to implement is:
I divide each task to some reasonable parts and after reach any of
these checkpoints, a task should return and a task_manager in body of
main function select another task to continue( for example by a
priority mechanism ).
but I think pausing a function is not easy? am I right? I think I must
define many variables as static and also save the inputs of function
for call a paused function again,
is there a simpler method in assembly? does anybody has a better
suggestion?
( I should mention that it is not possible to use interrupts for me
also. )
thanks.