QP (framework)
Encyclopedia
QP is a family of very lightweight, open-source
Open-source software
Open-source software is computer software that is available in source code form: the source code and certain other rights normally reserved for copyright holders are provided under a software license that permits users to study, change, improve and at times also to distribute the software.Open...

, state machine frameworks
Software framework
In computer programming, a software framework is an abstraction in which software providing generic functionality can be selectively changed by user code, thus providing application specific software...

 for embedded processors, microcontroller
Microcontroller
A microcontroller is a small computer on a single integrated circuit containing a processor core, memory, and programmable input/output peripherals. Program memory in the form of NOR flash or OTP ROM is also often included on chip, as well as a typically small amount of RAM...

s (MCUs), and DSPs
Digital signal processor
A digital signal processor is a specialized microprocessor with an architecture optimized for the fast operational needs of digital signal processing.-Typical characteristics:...

. The QP frameworks enable developing event-driven
Event-driven programming
In computer programming, event-driven programming or event-based programming is a programming paradigm in which the flow of the program is determined by events—i.e., sensor outputs or user actions or messages from other programs or threads.Event-driven programming can also be defined as an...

 real-time
Real-time computing
In computer science, real-time computing , or reactive computing, is the study of hardware and software systems that are subject to a "real-time constraint"— e.g. operational deadlines from event to system response. Real-time programs must guarantee response within strict time constraints...

 embedded software
Embedded software
Embedded software is computer software that plays an integral role in the electronics it is supplied with.Embedded software's principal role is not Information technology , but rather the interaction with the physical world. It's written for machines that are not, first and foremost, computers...

 consisting of concurrently executing UML state machine
UML state machine
UML state machine is a significantly enhanced realization of the mathematical concept of a finite automaton in Computer Science applications as expressed in the Unified Modeling Language notation....

s (UML statecharts). QP frameworks have been primarily designed for manual coding in C
C (programming language)
C is a general-purpose computer programming language developed between 1969 and 1973 by Dennis Ritchie at the Bell Telephone Laboratories for use with the Unix operating system....

 or C++
C++
C++ is a statically typed, free-form, multi-paradigm, compiled, general-purpose programming language. It is regarded as an intermediate-level language, as it comprises a combination of both high-level and low-level language features. It was developed by Bjarne Stroustrup starting in 1979 at Bell...

, but are also an excellent target for automatic code generation
Automatic programming
In computer science, the term automatic programming identifies a type of computer programming in which some mechanism generates a computer program to allow human programmers to write the code at a higher abstraction level....

. The QP frameworks are described in detail in the book Practical UML Statecharts in C/C++, Second Edition: Event-Driven Programming for Embedded Systems.

QP can work with or without a traditional operating system
Operating system
An operating system is a set of programs that manage computer hardware resources and provide common services for application software. The operating system is the most important type of system software in a computer system...

 or Real-Time Operating System (RTOS). In the standalone configuration, QP can completely replace a traditional RTOS. All QP framework types include a simple non-preemptive
Nonpreemptive multitasking
Nonpreemptive multitasking is a style of computer multitasking in which the operating system never initiates a context switch from a running process to another process...

 kernel and a fully preemptive kernel (QK). The QP/C and QP/C++ frameworks can also work with a traditional OS/RTOS to take advantage of existing device driver
Device driver
In computing, a device driver or software driver is a computer program allowing higher-level computer programs to interact with a hardware device....

s, protocol stack
Protocol stack
The protocol stack is an implementation of a computer networking protocol suite. The terms are often used interchangeably. Strictly speaking, the suite is the definition of the protocols, and the stack is the software implementation of them....

s, and other middleware
Middleware
Middleware is computer software that connects software components or people and their applications. The software consists of a set of services that allows multiple processes running on one or more machines to interact...

.

History

The main concepts and the first implementation of the Quantum Framework (QF) has been described in the book Practical Statecharts in C/C++: Quantum Programming for Embedded Systems (CMP Books, 2002). This book coined the term "Quantum Programming" and proposed a quantum-mechanical metaphor as a way of thinking about the event-driven software systems. Even though providing such a metaphor is one of the key practices of eXtreme Programming
Extreme Programming
Extreme programming is a software development methodology which is intended to improve software quality and responsiveness to changing customer requirements...

 and other agile methodologies
Agile software development
Agile software development is a group of software development methodologies based on iterative and incremental development, where requirements and solutions evolve through collaboration between self-organizing, cross-functional teams...

, the metaphor hasn't particularly caught on with readers and has been dropped in the second edition of the book. The abbreviation QP has been reused as Quantum Platform to denote the Quantum Framework (QF) plus the hierarchical event processor, and other components added later (such as the real-time kernels and software tracing instrumentation).

Background

Most software developers are accustomed to the basic sequential control
Structured programming
Structured programming is a programming paradigm aimed on improving the clarity, quality, and development time of a computer program by making extensive use of subroutines, block structures and for and while loops - in contrast to using simple tests and jumps such as the goto statement which could...

, in which a program (foreground-background
Foreground-background
Foreground-background is a scheduling algorithm that is used to control execution of multiple processes on a single processor. It is based on two waiting lists, the first one is called foreground because this is the one in which all processes initially enter, and the second one is called background...

 or a task in a traditional RTOS
Real-time operating system
A real-time operating system is an operating system intended to serve real-time application requests.A key characteristic of a RTOS is the level of its consistency concerning the amount of time it takes to accept and complete an application's task; the variability is jitter...

) waits for events in various places in its execution path by either actively polling
Polling (computer science)
Polling, or polled operation, in computer science, refers to actively sampling the status of an external device by a client program as a synchronous activity. Polling is most often used in terms of input/output , and is also referred to as polled or software driven .Polling is sometimes used...

 for events or passively blocking
Blocking (computing)
Blocking occurs when a subroutine does not return until it either completes its task or fails with an error or exception. A process that is blocked is one that waits for some event, such as a resource becoming available or the completion of an I/O operation.In a multitasking computer system,...

 on a semaphore
Semaphore (programming)
In computer science, a semaphore is a variable or abstract data type that provides a simple but useful abstraction for controlling access by multiple processes to a common resource in a parallel programming environment....

 or other such RTOS mechanism. Though this approach is functional in many situations, it doesn't work very well when the system must timely react to multiple events whose arrival times and order one cannot predict. The fundamental problem is that while a sequential task is waiting on one kind of event, it is not doing any other work and is not responsive to other events.

A long known, better alternative is to structure the software around the event-driven programming
Event-driven programming
In computer programming, event-driven programming or event-based programming is a programming paradigm in which the flow of the program is determined by events—i.e., sensor outputs or user actions or messages from other programs or threads.Event-driven programming can also be defined as an...

 model, which requires a distinctly different way of thinking than conventional sequential programs. Event-driven systems are naturally divided into the application, which actually handles the events, and the supervisory event-driven framework
Software framework
In computer programming, a software framework is an abstraction in which software providing generic functionality can be selectively changed by user code, thus providing application specific software...

, which waits for events and dispatches them to the application. The control resides in the event-driven framework, so from the application standpoint, the control is inverted
Inversion of Control
In software engineering, Inversion of Control is an abstract principle describing an aspect of some software architecture designs in which the flow of control of a system is inverted in comparison to procedural programming....

compared to a traditional sequential program. To remain responsive, the event-driven application cannot block, but must quickly return control after handling each event. Thus, the execution context cannot be preserved in the stack
Call stack
In computer science, a call stack is a stack data structure that stores information about the active subroutines of a computer program. This kind of stack is also known as an execution stack, control stack, run-time stack, or machine stack, and is often shortened to just "the stack"...

-based variables and the program counter
Program counter
The program counter , commonly called the instruction pointer in Intel x86 microprocessors, and sometimes called the instruction address register, or just part of the instruction sequencer in some computers, is a processor register that indicates where the computer is in its instruction sequence...

 as it is in a sequential task
Thread (computer science)
In computer science, a thread of execution is the smallest unit of processing that can be scheduled by an operating system. The implementation of threads and processes differs from one operating system to another, but in most cases, a thread is contained inside a process...

. Instead, the event-driven application becomes a state machine, or actually a set of collaborating state machines that preserve the context from one event to the next in the static variable
Static variable
In computer programming, a static variable is a variable that has been allocated statically — whose lifetime extends across the entire run of the program...

s.

Traditionally, event-driven programming of embedded systems required highly sophisticated design-automation tools, such as Rational Rose-RT
Rational Software
Rational Machines was founded by Paul Levy and Mike Devlin in 1981 to provide tools to expand the use of modern software engineering practices, particularly explicit modular architecture and iterative development...

 or Telelogic Rhapsody
Telelogic Rhapsody
Now called IBM Rational Rhapsody, a modeling environment based on UML, Rhapsody is a visual development environment for systems engineers and software developers creating real-time or embedded systems and software...

 (now both acquired by IBM
IBM
International Business Machines Corporation or IBM is an American multinational technology and consulting corporation headquartered in Armonk, New York, United States. IBM manufactures and sells computer hardware and software, and it offers infrastructure, hosting and consulting services in areas...

). But the really important part of any such tool is not the flashy GUI for drawing the diagrams. The most valuable part of those systems is the event-driven, state machine-based framework that each of those tools contains and which forms the basis for the automatic code generation.

The QP state machine frameworks are in many respects similar to the frameworks buried in all commercially successful tools. The only difference is that the QP frameworks are not concerned with facilities for animation of state machines and are not biased toward mechanical code generation. Instead, the QP frameworks are designed for direct, manual coding of event-driven applications in C
C (programming language)
C is a general-purpose computer programming language developed between 1969 and 1973 by Dennis Ritchie at the Bell Telephone Laboratories for use with the Unix operating system....

 or C++
C++
C++ is a statically typed, free-form, multi-paradigm, compiled, general-purpose programming language. It is regarded as an intermediate-level language, as it comprises a combination of both high-level and low-level language features. It was developed by Bjarne Stroustrup starting in 1979 at Bell...

.

QP Framework Types and Footprint

Current QP framework types are: QP/C and QP/C++, which require about 4KB of code space (ROM
Rom
ROM, Rom, or rom is an abbreviation and name that may refer to:-In computers and mathematics:* Read-only memory, a type of storage media which is used in computers and other electronic devices....

) and a few hundred bytes of RAM
Ram
-Animals:*Ram, an uncastrated male sheep*Ram cichlid, a species of freshwater fish endemic to Colombia and Venezuela-Military:*Battering ram*Ramming, a military tactic in which one vehicle runs into another...

, and the ultra-lightweight QP-nano, which requires only 1-2KB of ROM
Rom
ROM, Rom, or rom is an abbreviation and name that may refer to:-In computers and mathematics:* Read-only memory, a type of storage media which is used in computers and other electronic devices....

 and just several bytes of RAM
Ram
-Animals:*Ram, an uncastrated male sheep*Ram cichlid, a species of freshwater fish endemic to Colombia and Venezuela-Military:*Battering ram*Ramming, a military tactic in which one vehicle runs into another...

. The memory footprint of QP/C and QP/C++ is comparable with the smallest, bare-bones RTOS, while the footprint (especially RAM) of QP-nano is far below any conventional RTOS.

QP Architecture and Components

QP consists of a universal UML-compliant event processor (QEP), a portable, event-driven, real-time framework (QF), a tiny run-to-completion kernel (QK), and software tracing system (QS).
QEP (Quantum Event Processor) is a universal UML-compliant event processor that enables direct coding of UML state machine
UML state machine
UML state machine is a significantly enhanced realization of the mathematical concept of a finite automaton in Computer Science applications as expressed in the Unified Modeling Language notation....

s (UML statecharts) in highly maintainable C or C++, in which every state machine element is mapped to code precisely, unambiguously, and exactly once (traceability
Traceability
Traceability refers to the completeness of the information about every step in a process chain.The formal definition: Traceability is the ability to chronologically interrelate uniquely identifiable entities in a way that is verifiable....

). QEP fully supports hierarchical state nesting, which enables reusing behavior across many states instead of repeating the same actions and transitions over and over again.

QF (Quantum Framework) is a highly portable, event-driven, real-time application framework
Application framework
In computer programming, an application framework consists of a software framework used by software developers to implement the standard structure of an application for a specific development environment ....

 for concurrent execution of state machines specifically designed for real-time embedded system
Embedded system
An embedded system is a computer system designed for specific control functions within a larger system. often with real-time computing constraints. It is embedded as part of a complete device often including hardware and mechanical parts. By contrast, a general-purpose computer, such as a personal...

s.

QK (Quantum Kernel) is a tiny preemptive non-blocking run-to-completion kernel designed specifically for executing state machines in a run-to-completion (RTC) fashion.

QS (Quantum Spy) is a software tracing
Tracing (software)
In software engineering, tracing is a specialized use of logging to record information about a program's execution. This information is typically used by programmers for debugging purposes, and additionally, depending on the type and detail of information contained in a trace log, by experienced...

 system that enables live monitoring of event-driven QP applications with minimal target system resources and without stopping or significantly slowing down the code.

Supported Processors

All types of QP frameworks (QP/C, QP/C++, and QP-nano) can be easily adapted to various microprocessor architectures and compilers. Adapting the QP software is called porting and all QP frameworks have been designed from ground up to make the porting easy.

Currently, bare-metal QP ports exist for the following processor architectures:
  • ARM
    ARM architecture
    ARM is a 32-bit reduced instruction set computer instruction set architecture developed by ARM Holdings. It was named the Advanced RISC Machine, and before that, the Acorn RISC Machine. The ARM architecture is the most widely used 32-bit ISA in numbers produced...

     Cortex-M3 (TI Stellaris, ST STM32
    STM32
    STM32 is a family of multiple series of microcontroller ICs, by STMicroelectronics , based on the 32-bit RISC Cortex-M3 and Cortex-M4F cores from ARM Holdings...

    , NXP LPC)
  • ARM
    ARM architecture
    ARM is a 32-bit reduced instruction set computer instruction set architecture developed by ARM Holdings. It was named the Advanced RISC Machine, and before that, the Acorn RISC Machine. The ARM architecture is the most widely used 32-bit ISA in numbers produced...

     Cortex-M0 (NXP LPC1114)
  • ARM
    ARM architecture
    ARM is a 32-bit reduced instruction set computer instruction set architecture developed by ARM Holdings. It was named the Advanced RISC Machine, and before that, the Acorn RISC Machine. The ARM architecture is the most widely used 32-bit ISA in numbers produced...

    7/9 (Atmel AT91R4x, AT91SAM7, NXP LPC, ST STR912)
  • Atmel AVR
    Atmel AVR
    The AVR is a modified Harvard architecture 8-bit RISC single chip microcontroller which was developed by Atmel in 1996. The AVR was one of the first microcontroller families to use on-chip flash memory for program storage, as opposed to one-time programmable ROM, EPROM, or EEPROM used by other...

     Mega/Xmega
  • TI MSP430
    TI MSP430
    The MSP430 is a mixed-signal microcontroller family from Texas Instruments. Built around a 16-bit CPU, the MSP430 is designed for low cost, and specifically, low power consumption embedded applications. The architecture dates from the 1990s and is reminiscent of the DEC PDP-11.-Applications:The...

  • TI TMS320C28x
    Texas Instruments TMS320
    Texas Instruments TMS320 is a blanket name for a series of digital signal processors from Texas Instruments. It was introduced on April 8, 1983 through the TMS32010 processor, which was then the fastest DSP on the market....

  • Renesas M32C/M16C/R8C
    Renesas Electronics
    is a Japanese semiconductor manufacturer. It is based in Tokyo and has manufacturing, design and sales operations in around 20 countries. Renesas is one of the world's largest manufacturers of semiconductor systems for mobile phones and automotive applications. It is the world's largest...

  • Renesas H8
    Renesas Electronics
    is a Japanese semiconductor manufacturer. It is based in Tokyo and has manufacturing, design and sales operations in around 20 countries. Renesas is one of the world's largest manufacturers of semiconductor systems for mobile phones and automotive applications. It is the world's largest...

  • Freescale Coldfire
    Freescale ColdFire
    The Freescale ColdFire is a microprocessor that derives from the Motorola 68000 family architecture, manufactured for embedded systems development by Freescale Semiconductor .-Instruction set:...

  • Freescale 68HC08
    Freescale 68HC08
    The 68HC08 is a broad family of 8-bit microcontrollers from Freescale Semiconductor .HC08's are fully code-compatible with their predecessors, the Motorola 68HC05. Like all Motorola processors that share lineage from the 6800, they use the von Neumann architecture as well as memory-mapped I/O...

  • Altera Nios II
    Nios II
    Nios II is a 32-bit embedded-processor architecture designed specifically for the Altera family of FPGAs. Nios II incorporates many enhancements over the original Nios architecture, making it more suitable for a wider range of embedded computing applications, from DSP to system-control.Nios II is...

  • 8051
    Intel MCS-51
    The Intel MCS-51 is a Harvard architecture, single chip microcontroller series which was developed by Intel in 1980 for use in embedded systems. Intel's original versions were popular in the 1980s and early 1990s. While Intel no longer manufactures the MCS-51, binary compatible derivatives remain...

     (Silicon Labs)
  • 80251
    Intel MCS-51
    The Intel MCS-51 is a Harvard architecture, single chip microcontroller series which was developed by Intel in 1980 for use in embedded systems. Intel's original versions were popular in the 1980s and early 1990s. While Intel no longer manufactures the MCS-51, binary compatible derivatives remain...

     (Atmel)
  • Microchip PIC18
    PIC microcontroller
    PIC is a family of Harvard architecture microcontrollers made by Microchip Technology, derived from the PIC1650 originally developed by General Instrument's Microelectronics Division...

  • Microchip PIC24/dsPIC
    PIC microcontroller
    PIC is a family of Harvard architecture microcontrollers made by Microchip Technology, derived from the PIC1650 originally developed by General Instrument's Microelectronics Division...

  • Cypress PSoC1
    PSoC
    PSoC is a family of integrated circuits made by Cypress Semiconductor. These chips include a CPU and mixed-signal arrays of configurable integrated analog and digital peripherals.- History :...

  • 80x86 real mode

Supported Operating Systems

The QP/C and QP/C++ frameworks can also work with the traditional operating systems and RTOSes.

Currently, QP ports exist for the following OSes/RTOSes:
  • Linux
    Linux
    Linux is a Unix-like computer operating system assembled under the model of free and open source software development and distribution. The defining component of any Linux system is the Linux kernel, an operating system kernel first released October 5, 1991 by Linus Torvalds...

     (POSIX)
  • Win32
    Microsoft Windows
    Microsoft Windows is a series of operating systems produced by Microsoft.Microsoft introduced an operating environment named Windows on November 20, 1985 as an add-on to MS-DOS in response to the growing interest in graphical user interfaces . Microsoft Windows came to dominate the world's personal...

     (all desktop Windows and WindowsCE)
  • VxWorks
    VxWorks
    VxWorks is a real-time operating system developed as proprietary software by Wind River Systems of Alameda, California, USA. First released in 1987, VxWorks is designed for use in embedded systems.- History :...

  • ThreadX
    ThreadX
    ThreadX, developed and marketed by Express Logic, Inc. of San Diego, California, USA, is a real-time operating system . Similar RTOSes are available from other vendors such as VxWorks, Nucleus RTOS, OSE, QNX, LynxOS, etc...

  • FreeRTOS
    FreeRTOS
    FreeRTOS is a real-time operating system for embedded devices, being ported to several microcontrollers. It is distributed under the GPL with an optional exception...

  • MicroC/OS-II
    MicroC/OS-II
    MicroC/OS-II , is a low-cost priority-based pre-emptive real-time multitasking operating system kernel for microprocessors, written mainly in the C programming language...

  • QNX
    QNX
    QNX is a commercial Unix-like real-time operating system, aimed primarily at the embedded systems market. The product was originally developed by Canadian company, QNX Software Systems, which was later acquired by Canadian BlackBerry-producer Research In Motion.-Description:As a microkernel-based...

     (POSIX)
  • Integrity
    Integrity (operating system)
    INTEGRITY is a real-time operating system produced and marketed by Green Hills Software. It is royalty-free, POSIX-certified, and intended for use in embedded systems needing reliability, availability, and fault tolerance. It is built atop the velOSity microkernel and is intended mainly for modern...

     (POSIX)

Licensing

All QP framework types are licensed under the increasingly popular dual licensing model, in which both the open source
Open source
The term open source describes practices in production and development that promote access to the end product's source materials. Some consider open source a philosophy, others consider it a pragmatic methodology...

 software distribution mechanism and traditional closed source
Proprietary software
Proprietary software is computer software licensed under exclusive legal right of the copyright holder. The licensee is given the right to use the software under certain conditions, while restricted from other uses, such as modification, further distribution, or reverse engineering.Complementary...

 software distribution models are combined.

For users developing and distributing open source
Open source
The term open source describes practices in production and development that promote access to the end product's source materials. Some consider open source a philosophy, others consider it a pragmatic methodology...

 applications, or users just learning and evaluating the software (but not distributing it), QP is available under the GNU General Public License
GNU General Public License
The GNU General Public License is the most widely used free software license, originally written by Richard Stallman for the GNU Project....

version 2 (GPL).

Users, who want to distribute QP (e.g., embedded inside devices) can retain the proprietary status of their code by licensing QP under a traditional, closed-source license issued by Quantum Leaps. Several types of commercial, royalty-free, closed-source licenses are available.

External links

The source of this article is wikipedia, the free encyclopedia.  The text of this article is licensed under the GFDL.
 
x
OK