HEOsek Operating System Simulator for Windows

Copyright (C) Werner Zimmermann (wernerzimmermann.name)


HEOsek provides an operating system simulator which uses an OSEK/VDX-like API (application programming interface). Additionally, AUTOSAR OS - like schedule tables have been added. HEOsek implements task management including alarms, events as described in OSEK OS 2.2.3, internal messages as described in OSEK COM 3.0.3 and AUTOSAR-like schedule tables similar to AUTOSAR OS 4.0. You can download these specifications from www.osek-vdx.org and www.autosar.org. HEOsek tries to keep things simple and thus has some more or less severe restrictions:

Nevertheless, if you dare, please feel free to use it ...


HEOsek is distributed as a zip file. To install, unzip it into your desired installation directory. You'll get the following directory structure:

To run one of the samples, go to the samples subdirectory and run the respective Test...exe file. To recompile one of the samples, in a console window change to the the sample's directory and type 'nmake'. This assumes, that Visual C++ compiler, linker, resource editor and (n)make utility are available in the path of your console window.

To develop your own HEOsek applications, make a copy of one of the test...cpp files and start modifying it. To compile your new file, modify the makefile accordingly and type 'nmake'.

If you ever want to deinstall HEOsek again (why should you? :--)) ) simply delete the installation directory and all its subdirectories. HEOsek does not copy files into any other directory nor does it touch the registry.

Getting started

The first sample Test.cpp can be used to demonstrate HEOsek's basic usage. Test.cpp implements 3 tasks.

First you must declare and configure all tasks, alarms, events etc. All tasks must be listed in an enumeration, starting with a default task named IDLE_TASK, and then declared with DeclareTask():

#include "osek.h"

//----- List of tasks ---------------------------------------------------------
enum { IDLE_TASK, taskA, taskB, taskC };

Additionally, for each task you have to define a stack. Under Windows, you need not care about the stack size, so always use DEFAULTSTACKSIZE:
//----- Task stacks -----------------------------------------------------------
Task parameters must be set in function StartupHook(), which will be called automatically, before OSEK's multitasking begins. To configure the tasks, use function OSInitializeTask(), which among other values, specifies the task's priority, whether it is started automatically and if shall be scheduled full-preemptive or non-preemptive:
//----- Configuration (initialization functions not OSEK compatible -----------
void StartupHook(void) 
    OSInitializeTask(taskA, TASKFUNCTION(taskA), 2, TRUE,  FULL, stackA, sizeof(stackA), 1);
    OSInitializeTask(taskB, TASKFUNCTION(taskB), 6, FALSE, FULL, stackB, sizeof(stackB), 1);
    OSInitializeTask(taskC, TASKFUNCTION(taskC), 4, FALSE, FULL, stackC, sizeof(stackC), 1);
The rest of the program uses standard OSEK calls:
//------ Hook functions -------------------------------------------------------
//Must be provided, leave empty if you do not use it.
void ShutdownHook(StatusType status)
void PreTaskHook(void) 
void PostTaskHook(void)

//----- Variables -------------------------------------------------------------
volatile UINT8 taskCounter=1;

//----- First task ------------------------------------------------------------
{   printf("TASK  A %d - first Start\n", taskCounter); _flushall();
    {   printf("-TASK A %d\n", taskCounter++); _flushall();

//----- Second task -----------------------------------------------------------
{   printf("TASK  B %d\n", taskCounter++); _flushall();

//----- Third task ------------------------------------------------------------
{   printf("TASK  C %d\n", taskCounter); _flushall();

//----- Main ------------------------------------------------------------------
void main(void)
{   StartOS(OSDEFAULTAPPMODE);  //Start multitasking

To compile the sample's resource script and source code, do run the following commands from a console window (assuming Visual C++ is available via the Windows path in the console window):

        cl -Zi -I#installation directory#/inc -I#installation directory#/arch/x86/inc test.cpp #installation directory#/src/osek.cpp #installation directory#/arch/x86/src/cpu.cpp winmm.lib user32.lib
For #installation directory# insert the name of the directory, where you installed HEOsek.

Instead you can simply type 'nmake', using the makefile provided in the samples directory.

To get more detailed usage information, have a look at the examples below and look into the detailed functional documentation in file "HEOsek.chm" (generated by Doxygen from osek.h, included in HEOsek's doc subdirectory).


The package comes with some sample files:

More samples and additional programming tips may be added in later versions.

HEOsek compatibility

HEOsek was developed and tested with Microsoft Visual C++ 2003...2010 (English version) and tested under Windows XP/7. Other versions of Visual C++ and Windows should work, but have not been tested.

Release Notes

V0.9.0: First public beta release.

Disclaimer and copyright information

All files are provided in the hope, they might be useful, but without any warranty or support. You may use or modify them on your own risk in non-commercial applications. Even if this software is provided free of charge, it is no freeware. It is copyrighted by Werner.Zimmermann|AT|hs-esslingen.de, details see file 'Copying'.

If you want to use this software in commercial applications, contact the author.

The use of HEOsek in safety critical applications is strictly prohibited!

In case you have problems directly related to HEOsek, you may email a detailed description of the problem to Werner.Zimmermann|AT|hs-esslingen.de. But the author does not guarantuee, that he will answer your mail or solve the problem. But please: Don't send me general OSEK or AUTOSAR questions, unless you don't subscribe to my consultancy services.

Windows, Visual C++, OSEK/VDX, AUTOSAR and other product names mentioned here may be trademarks or registered trademarks of their respective owners.

Programming tips

None so far.

(C) wernerzimmermann.name