Depending on your experience with C, this might help...
Go to here and look at the "Patterns in C" section at the bottom.
Another good place to start for some solutions (like a microcontoller controlling a vending machine) is by using a state machine. The "poor man's version" is using a switch statement, and is fine for lots of small control programmes... You can then use multiple switch statements and implement your own cooperative multitasking system.
The thing that you need to remember when you do this is to not use blocking code... i.e.
Code:
while(i!=someNumber)
{
Blah...
}
becomes...
Code:
switch(state)
{
...
case state1:
someNumber = 123;
i=0;
state = state2;
break;
case state2:
Blah...
if (i==someNumber)
state=state3;
break;
...
}
... The idea is that after each "Blah" you can have other state machines doing separate tasks.
There are heaps of solutions for different problems, and better ways to implement a state machines