Copyright ©2005 Pär Spjuth
IntroductionTutorialAPIDownload Logo


The StrawLib is released under MIT Licence, which basically means I take no responsibility for the source, and you can do whatevery you want with the code as long as the copyright statement is included and remains intact.

What is StrawLib?

StrawLib is a framework written in ANSI C for state machine like designs, optimized especially for embedded software on hardware with little RAM and only a few system processes. This also means that if you are developing software on a high level platform you are probably better off using threads.

Why use StrawLib?

Because traditional state machine designs tend to become very complex very fast. They are also hard to maintain and refactor when not using a graphical tool to generate them. StrawLib allows a programmer to use a sort of thread concept to a very large extent, actually eliminating the need for traditional state machines in many cases.

Using StrawLib you get the following without any extra effort:

  • Instantiation
  • Code Independence
  • Predictable Termination
  • Semi-consecutive Execution
  • Execution Logging

Why the name StrawLib?

This is based on the terminology for executing instructions on a computer. The top level execution entities are normally spoken of as processes. In a high level system these entities do not share memory space and run in parallel. One step down the hierarchy are threads. This is basically sub-processes, but are normally only scheduled for execution within the process that starts them, and they also share the same memory space.

The most important feature of processes and threads are that they can always be considered as running in parallel because the system schedules when they are allowed to run on the CPU. This is why there are room for a third concept called fibers. These are essentially the same as threads, but they are not scheduled. Instead the developer has to put in yielding instruction where appropriate, to allow other fibers to gain control of the CPU.

With this terminology in mind one could see it logical to use the term straw (as in a component of a fiber) to describe the concept of the framework hosted on this page. The straws do, just as fibers, lack a scheduler. They also lack the property of simple yielding; Where fibers can yield anywhere in a code sequence, straws must be split into event driven code chunks.

Page was last updated 2005-08-15