1e31 Gen fsm - Telecomix Crypto Munitions Bureau

Gen fsm

From Telecomix Crypto Munitions Bureau

Jump to: navigation, search
Finite state machines are used to describe state changes and (sometimes) what actions to take when specific state changes has occurred. Finite state machines can only assume a finite (non-infinite) amount of different states.

Essentially: "If this happens after this and that has happened, then perform these actions."

The picture to the right shows a finite state machine, each ball is a state. Each arrow is a potential state change. When the system switches to a new state, it may have a piece of code that executes (performs actions).

Finite state machines may be linked together so that the actions taken by one FSM results in state changes in another FSM, and so on. They can thus be used to create very complex logic machinery when combined.

Examples

  • Communication protocols such as TCP and BGP uses finite state machines to describe in which state the connection is in, and which actions should be taken at different states. Handshaking works like this.
  • Code locks that require the user to enter a password could be described as a finite state machine (like in this example)
  • Many industrial CISC processors use FSMs to decode machine code. RISC processors where all instructions are of equal length does not need FSMs for decoding.
  • Programming language syntax can be described using FSMs and/or/mixed_with regular expressions.
  • If it is very important that something is in a well-defined state, FSMs should be used, unless you come up with a better solution.

[edit] API mappings

Image:gen_fsm.png

Also see worker patterns for more info.

[edit] Parsers

yecc can be used to quickly create language parsers from BNF grammars. There is also a Leex lexer.

Tutorial: [1]

[edit] Sources

Personal tools
0