Download FreeRTOS

Quality RTOS & Embedded Software

FreeRTOS website now available in Simplified Chinese
New FreeRTOS Long Term Support version now available.
FreeRTOS Extended Maintenance Program (EMP) registration now open.
FreeRTOS-Plus-TCP v3.0.0 released:
Featured FreeRTOS IoT Integrations:
NOTE: The POSIX library and documentation are in the FreeRTOS Labs.  The libraries in the FreeRTOS Labs download directory are fully functional, but undergoing optimizations or refactoring to improve memory usage, modularity, documentation, demo usability, or test coverage.  They are available as part of the FreeRTOS-Labs Download.

FreeRTOS-Plus-POSIX Pre-configured Example

[FreeRTOS-Plus-POSIX Overview]


The pre-configured example documented on this page uses the FreeRTOS Windows port. It demonstrates how FreeRTOS-Plus-POSIX can be used to port a simple POSIX threading compliant application (in this case, an implementation of the actor model) to the FreeRTOS kernel. To demonstrate the concept, the application is built for execution on both Linux (which uses POSIX threads) and FreeRTOS.

On this page:

  1. The demo application
  2. Building and running the demo on Linux
  3. Building and running the demo using the FreeRTOS Windows port


The Demo Application

This demo creates two types of actors: dispatcher and workers. Dispatchers tell workers what to do by sending different types of messages to the works. Each time a worker receives a message it performs a predefined routine that is dependent on the message it received. At the end of the demo the dispatcher notifies the workers that there is nothing more to do and all actors (dispatcher and worker) terminate.

Each actor is a thread that is created using the POSIX pthread_create() function. Messaging is performed through queues using the POSIX mq_open(), mq_send(), mq_timedsend() and mq_receive() functions.


Building and Executing the Demo on Linux

  1. Download the posix_demo.c source file.


  2. Open a command line window and cd to the directory that contains the downloaded posix_demo.c source file.


  3. Compiler using the following command line:
    gcc -Wall posix_demo.c -lpthread -lrt -o posix_demo


  4. Once built, execute the demo using the following command line.

Expected Output



Building and Executing the Demo using the FreeRTOS Windows Port

  1. Download the free 2017 (minimum) Community edition of Visual Studio for C/C++.


  2. Download and unzip the pre-configured example for Visual Studio.


  3. From within the Visual Studio IDE, open the solution file FreeRTOS_Plus_POSIX_with_actor.sln, which is located in the \FreeRTOS-Plus\Demo\FreeRTOS_Plus_POSIX_with_actor_Windows_Simulator folder of the unzipped files.


  4. From within the Visual Studio IDE, press F10 to build the project and start a debug session.


Note that FreeRTOS cannot return from main() without ending the entire application, so the native FreeRTOS API is used to create a task called vStartPOSIXDemo(), which then used to run the same actor demo as already demonstrated running on Linux.



Copyright (C) Amazon Web Services, Inc. or its affiliates. All rights reserved.