Return to Website   
Quantum Leaps Discussion Forum

Search the Forum for answers or post your questions to the
Quantum Leaps community



Return to Website

  Reply
  Forum

Subject:   Re: When should I use FSM instead of HSM ?
Name:   Miro Samek
Date Posted:   Jun 13, 08 - 9:00 AM
Email:   miro@quantum-leaps.com
Website:   http://www.quantum-leaps.com
Message:   FSM provides just a subset of HSM functionality. In other words, an HSM can do everything that FSM can do, and more.

I would recommend using FSM only in extreme cases as an optimization in time and space. If you are extremely pressed for CPU time, such as for example inside ISRs, you can use FSM to save a few CPU cycles compared to HSM.

In general, a non-hierarchical FSM coded as HSM uses just a little more CPU, so the savings here are not that significant. Please note that even FSM in QP supports entry and exit actions. However, FSM uses a little less of stack for local variables than HSM. Again this might be important inside ISRs.

If you are extremely short of code space (ROM), you might use FSM to save some 0.5-1KB of code space. (You need to eliminate HSM in the entire system to save the code, though).

So, as a general rule, I'd recommend coding everything as HSM at first, and only replace HSMs with FSMs in critical spots, as final fine-tuning step.

Miro
   


  Reply
  Forum


powered by Powered by Bravenet bravenet.com