Application Notes & Articles
Application notes authored at Quantum Leaps, and relevant articles about active objects (actors), hierarchical state machines, and event-driven real-time programming written by various authors.
Most documents are PDF files. Links marked with ↑ lead to other websites.
On this page:
Application Notes
Application Notes authored at Quantum Leaps, sorted by category.
State-Machine Design Patterns
- Ultimate Hook
Provide common look-and-feel, but let clients specialize every aspect of a system's behavior. - Reminder
Provide more flexibility by inventing an event and posting it to self - Deferred Event
Control the sequence of events - Orthogonal Component
Use state machines as components of other state machines - Transition to History
Transition to the most recent state configuration of a given composite state - State-Local Storage
Reduce memory footprint of state machines by introducing the state-local variable scope
Programming Techniques
- Object-Oriented Programming in C — Companion Code for OOP in C↑
How to implement encapsulation (classes), inheritance, and polymorphism in portable and standard-compliant C without the use of the preprocessor - Inheriting State Machines with QP 4.x
How to inherit entire state machines in QP 4.x and how to extend the existing states and transitions in the subclasses
Example Applications
- Dining Philosophers Problem (DPP)
The Dining Philosophers Problem (DPP) application is used mostly in the QP/C and QP/C++ examples for various processors - "Fly 'n' Shoot" Game (Chapter 1 of PSiCC2 book)
The Fly-n-Shoot game application is used mostly in the QP/C, QP/C++, and QP-nano examples for various processors (Chapter 1 of PSiCC2) - PEdestrian LIght CONtrolled (PELICAN) crossing
The PEdestrian LIght CONtrolled (PELICAN) crossing application is used mostly in the QP-nano examples for various processors
QP™ Ports (Built-in Kernels)
- QP Ports to ARM Cortex-M
- Setting ARM Cortex-M Priorities in QP 5.x
- QP and ARM Cortex-R
QP on ARM Cortex-R - QP and ARM7/ARM9
QP/C/C++ on ARM7/ARM9 with the GNU-ARM toolset
QP™ Ports (3rd-Party RTOS)
- QP™ and SEGGER embOS
QP/C/C++ Port to SEGGER embOS - QP™ and ThreadX
QP/C/C++ Port to ThreadX - QP and uC/OS-II
QP/C/C++ Port to uC/OS-II
QP™ Ports (General-Purpose OSes)
- QP™ and POSIX (Linux)
QP/C/C++ Port to POSIX - QP™ and Windows
QP/C/C++ Port to Windows - QP and Qt Framework
QP/C++ and Qt Framework
QP™ Ports (3rd-Party Middleware)
- QP™ and lwIP (TCP/IP Stack) — Video: "lwIP TCP/IP stack and QP framework" (6:24)↑
QP/C/C++ and lwIP - QP™ and emWin Embedded GUI
QP/C/C++ and emWin
Prototyping / Dual Targeting
- QWIN GUI Kit for Prototyping Embedded Systems on Windows — Video: "Fly 'n' Shoot" game on Windows made with the QWIN GUI Kit (1:18)↑
QP™ Performance Tests and Results
Articles
Relevant and recommended articles written by various authors, sorted by category.
Active Objects (Actors)
- Blocking == Technical Debt — Miro Samek
- Beyond the RTOS — Miro Samek · Slideshare, April 2016↑
This presentation introduces the reusable event-driven reactive architecture for embedded systems based on asynchronous active object (actor) frameworks that goes beyond the traditional RTOS. - Active Object Computing Model — Miro Samek
Active Object Computing Model description from Practical UML Statecharts in C/C++, 2nd Ed. - Quantum Programming for Embedded Systems — Miro Samek · CUJ, March 2003↑
Cover story of the Real-Time Computing issue of the C/C++ Users Journal - Managing Concurrency in Complex Embedded Systems — Dr. David M. Cummings↑ · Paper, June 2010↑
- Sharing Is the Root of All Contention — Herb Sutter↑ · DDJ, February 2009↑
Sharing requires waiting and overhead, and is a natural enemy of scalability. - Use Threads Correctly = Isolation + Asynchronous Messages — Herb Sutter↑ · DDJ, March 2009↑
Explicit threads are undisciplined. They need some structure to keep them in line. - Know When to Use an Active Object Instead of a Mutex — Herb Sutter↑ · DDJ, September 2010↑
Got state? Hide it! And if it's shared and either popular or slow, make it asynchronous...it's just good encapsulation. - Message Passing for Intertask Communication — Dr. David Kalinsky↑ · Kalinsky & Associates 2010↑
This online training explains the concepts and benefits of asynchronous message passing, which is the first step towards implementing the active object model with a traditional RTOS. - New Directions in RTOS Kernels — Dr. David Kalinsky↑ · Kalinsky & Associates 2014↑
This technical whitepaper examines some of the future trends that embedded systems and software designers can expect to encounter in choosing real-time operating system kernels for future projects during the next 5-10 years. The main focus is on intertask communication via asynchronous direct message passing, which is the cornerstone of the active object computing model. - Parallel Microsoft Style — Andrew Binstock · DDJ, July 2011↑
The actor model of concurrency is gaining favor in Java but remains largely ignored by Microsoft. - The Actor Model: Towards Better Concurrency — Dror Bereznitsky · Slideshare, January 2010↑
Applications must be built for concurrency. The traditional 'shared state concurrency' is hard and the Actor Model provides an easier to use alternative.
Hierarchical State Machines (UML Statecharts) / Modeling
- A crash course in UML state machines — Miro Samek · Embedded.com 2009↑
Introduction to UML State Machines (UML Statecharts) based on Chapter 2 of the book Practical UML Statecharts in C/C++, 2nd Ed. - The Pragmatics of Model-Driven Development — Bran Selic · IEEE Computer Society 2003↑
- State Oriented Programming — Miro Samek, Paul Y. Montgomery · ESP 2000↑ · GitHub repo↑
This cover story article describes the first version (v1.0) of the implementation that later became the Quantum Event Processor™ (QEP). The article mentions a possibility of using an event-driven framework in conjunction with the hierarchical event processor. Such a framework, which was a predecessor of QP™ - UML Statecharts at $10.99 — Miro Samek · DDJ 2006↑ · Code for the Article
This Dr. Dobb's article describes a method and software for implementing UML statecharts in C, small enough to fit a low-end 8-bit microcontroller. More specifically, it presents a nontrivial UML statechart example, implemented with QP-nano, that runs on the USB Toolstick from Silicon Laboratories with room to spare (8051-derivative, 256 bytes of RAM, 8KB of Flash). The example has been implemented with QP-nano for 8051 - Auto-coding UML Statecharts for Flight Software — Ed Benowitz, et al. · IEEE Computer Society 2006↑
This article describes Auto-Coder for the QP frameworks and state machines developed at NASA JPL - Yet Another Hierarchical State Machine — Stefan Heinzmann · ACCU Overload 64 2004↑
This article is for advanced C++ users, who want apply modern C++ templates to tackle Hierarchical State Machines. Stefan presents an interesting implementation that a good C++ compiler can turn into excellent code. In particular, all transition chains can be entirely optimized at compile-time. An interesting read... - Statecharts in the Making: A Personal Account — Prof. David Harel · Communications of the ACM 2010↑
A highly personal account of how the language of statecharts came into being. The story is told in a way that puts statecharts into perspective and discusses the role of the language in the emergence of broader concepts, such as visual formalisms in general, reactive systems, model-driven development, model executability and code generation. - Statecharts: A Visual Formalism for Complex Systems — Prof. David Harel · Science of Computer Programming 1987↑
This is the most important paper on the subject that marks the birth of statecharts and is quoted in any subsequent work in this area. An absolute must-read for anybody interested in these fundamental programming concepts.
Event-Driven & Real-Time Programming
- Build a Super Simple Tasker — Miro Samek, Robert Ward · ESD 2006↑ · GitHub repo↑
This cover story article describes a very lightweight fully preemptive kernel for event-driven systems. The kernel (called Super Simple Tasker) executes basic tasks to completion and can manage all the task contexts with a single stack. The SST kernel is the precursor of the lightweight QK™ preemptive kernels. This article is strongly recommended for everyone interested in lightweight preemptive multitasking. - Use an MCU's Low-Power Modes in Foreground/Background Systems — Miro Samek · ESD 2007↑
This article describes how to use the low-power sleep modes of various MCUs safely in the venerable foreground/background architecture. The following processors are discussed: HC08, MSP430, AVR, ARM7/ARM9, ARM Cortex-M3, 8051, M16C. - Building Bare-Metal ARM7/ARM9 Systems With GNU — Miro Samek · Embedded.com 2007↑ · Code (C) · Code (C++)
The complete article in PDF with the latest code
"The Embedded Angle" Column (C/C++ Users Journal)
- The Embedded Mindset — Miro Samek · CUJ, February 2003↑
The proliferation of embedded systems means ever-increasing demand for firmware. Developing embedded code, however, takes significantly more than just learning a new API — it requires adapting an entirely new mindset. You can still use C or even C++, but beware: many time-honored techniques from the desktop can hurt you. - Who Moved My State? — Miro Samek · CUJ, April 2003↑
Just as the mice and little-people from the Spencer Johnson's little story 'Who Moved My Cheese?', we programmers use different strategies to find our favorite kind of 'Cheese': robust, adaptable, and maintainable software. Interestingly, techniques based on hierarchical state machines aren't among the popular, mainstream programming strategies. Yet, state machines are perhaps the most effective method of all for developing robust event-driven code, because they give us the map to the software maze — the blueprint of all the states of the system at any given time. If you don't use state machines today, you'll likely use them tomorrow. - Déjà Vu — Miro Samek · CUJ, June 2003↑ · PELICAN crossing example is included in QP/C++
I hope that you experience a strange feeling of déjà vu when you read about programming-by-difference, inheritance, guaranteed initialization and cleanup, and the Liskov Substitution Principle (LSP) in the context of hierarchical state machines (HSMs). Such a close analogy between the fundamental concepts of OOP and HSMs is truly remarkable. Indeed, the analogy adds another dimension to the OOP. The traditional OO method seems to stop short at the boundary of a class, leaving the internal implementation of individual class methods to mostly procedural techniques. The concept of behavioral inheritance goes beyond that frontier. It allows applying the OO concepts inside reactive classes. - An Exception or a Bug? — Miro Samek · CUJ, August 2003↑
If you were to single out just one most effective programming technique for delivering high-quality code, what would you choose? Object-oriented programming? Generic programming? Design patterns? Software components? Frameworks? UML? CASE tools? I don't know if these suggestions would top your list, but I suppose that not many programmers would pick assertions (or more scientifically, Design by Contract) as the single most effective programming technique. Yet, if I were to search my soul, I'd have to admit that none of the aforementioned techniques (not even my favorite hierarchical state machines) has helped me as much as the consistent use of assertions. In this installment of 'The Embedded Angle', I try to explain the Design by Contract philosophy, what can it do for you, and why, I think, embedded systems programmers should care. - Patterns of Thinking — Miro Samek · CUJ, October 2003↑
I'm sure that you have used system metaphors, concept metaphors, or 'naive psychology' before, but perhaps you didn't fully realize the fact. I hope that this article will make you more aware of the different roles metaphors and analogies can play in software development, and that there is more to it than just the venerable system metaphor. I hope that you start paying more attention how you and others use metaphors with the goal of making better use of the natural god-given abilities built into your brain. I hope that you start thinking more about metaphors, learn their limits, and remember their critical aspects. Perhaps you will start collecting metaphors? - Back to Basics — Miro Samek · CUJ, December 2003↑
My preoccupation in this installment is with state machine fundamentals and some very straightforward programming guidelines for coding state machines in C or C++. I hope that the simple techniques could become more common, so that you (and others) can readily see the state machine structure right from the source code.

