Re: Running same algorithm simultaneously?
Posted: 31 Jan 2011, 22:33
In the code below...
Task 0 never appears to execute.
Task 1 does not wait the 4 seconds.
Program never exits.
Yes, calling the same function simultaneously is bad
If I have any utility function then should I safecall or inline it so program doesn't go into this weird state if more than one task accesses it?
If I have a single function that needs to be run to control multiple items, should I either inline it or refactor it to handle all items in one function (essentially do my own poor man's scheduling)? Some of these functions are 60 lines of code. Inlining just seems wrong
Task 0 never appears to execute.
Task 1 does not wait the 4 seconds.
Program never exits.
Yes, calling the same function simultaneously is bad
If I have any utility function then should I safecall or inline it so program doesn't go into this weird state if more than one task accesses it?
If I have a single function that needs to be run to control multiple items, should I either inline it or refactor it to handle all items in one function (essentially do my own poor man's scheduling)? Some of these functions are 60 lines of code. Inlining just seems wrong
Code: Select all
void run(int ref)
{
Wait(4000);
NumOut(0, (ref == 0 ? LCD_LINE1 : LCD_LINE2), ref);
}
task task0()
{
run(0);
}
task task1()
{
run(1);
}
task main()
{
StartTask(task0);
StartTask(task1);
}