Event driven programming
You may want to take a look at LMX by David Anderson A Light-Weight Multi-Tasking Executive.

He has a very good set of videos on the code that he did for Dallas Personal Robotics Group (DPRG).

The specific videos for LMX are:


David Anderson on Robotics Software - part 1
David Anderson on Robotics Software - part 2