@shurik thanks a ton . That really works in my case. It actually works this way
Code:
int i;
int task1done = 0;
int task2done = 0;
/* i dont have to use while(1) as controller takes care of looping
and the value received in the task1 over serial interface is used
in the execution of rest of tasks. Actually, i am receiving
over 6 bytes in task1 over SPI and there are over 25 tasks following task1 . */
while(1) {
task1(getvalue)
{
i = getvalue;
}
task2 (i==0 && !task1done)
{
task1();
task1done = 1;
task2done = 0;
}
task3(i==1 && !task2done)
{
task2();
task2done = 1;
task1done = 0;
}
}