TCPmaker : Visual Tour    Exploring and Customizing the Generated Code  

The code that runs in your embedded Web server device is a bit like one of those jugglers that you may have seen on TV or in a circus: he is juggling maybe 2 oranges, a bowling ball, and maybe a chain saw as well, all at the same time.

Just like your device, that juggler is pretty busy, all the time.  He only touches each item for a brief amount of time: just long enough to toss it up in the air again to keep everything moving.  If he spends too much time on any one thing, all the other items come crashing down, with painful results.

This process is called Cooperative Multitasking.  Your device calls routines in all sorts of servers in the Microchip Stack, and all sorts of event handlers in TCPmaker's code as well.  These routines all cooperate by doing just a little work, saving some reminder of where they left off, and exiting with the knowledge that they will be called again soon.

The code you add to any of TCPmaker's event handlers has to work like that juggler: do just the minimum that you have to do, and get out of that event handler fast, so the next task can get done.

In particular, Never write code in an event handler that waits for something to finish: just start the process (whatever it is) and exit the event handler.  You can check whether your process has finished the next time you call your event handler. 


11 of 21
Copyright Notice and Author Information