The controller which i am using executes code in terms of tasks (Round- robin fashion). It does not got any main function. for example:
Code:
int i ; // getting the i value over serial interface

task1(i==0)
{
  do something;
}

task2(i==1)
{
 do something;
}
Considering the above situation, when i variable gets value 0 over serial interface task1 evaluates to TRUE and it executes again and again before the value changes to 1. When i variable changes to 1 task2 executes again and again before the value changes to 0. My question is, i want these tasks to execute only once but not again n again.

What is precisely mean is

task1(i==0)
do something but next time only if i changes to 1 and back to 0;

PS: the i value can only be 1 or 0 and i can improvise the task's condition. for example: task1(i==0 & something)


Please give your inputs n ideas about solving such problem.