Here we see the flow of a message generated by an I/O event.
Once the code responsible for looking after the I/O has generated the message and passed it to the comms handler, it can get back to looking after its I/O. In this desgin, multi-tasking is effectively performed by the state machine scheduler. As a consequence the I/O handling code is clean and lean and does not have to be interleaved with comms code. This design uses just two state machines per CPU, but it is possible to use many interacting state machines per CPU. The exact number is dependent on the amount of physical memory availabel in the CPU. Using background comms it is a simple matter to add aditional CPUs to increase the computing power of the system. By replacing the high level comms state machine in this example, with one that simply passes events, it is possible to build very large distributed state machines with very little effort using ZMech. |