uCOS-II the Real-Time Kernel
uCOS-II x86 Win32 Simulation
Win32 port allows uCOS-II to run under Microsoft Windows 9x, ME, NT, 2000, and XP. The port relies on Windows' process and thread management features; the uCOS-II Win32 port does not turn Windows into a real-time operating system! It was developed for didactic purposes to teach the basics of real-time operating systems with an insight to OS internal implementation. This approach was chosen, because it is much easier access PCs rather than to proprietary embedded systems. Powerful PC-based development tools like Microsoft Visual Studio or Cygwin's GCC are available free of charge under appropriate university licenses or GPL as compared to costly embedded system cross-compilers and debuggers. Thus real-time system mechanisms can be studied with uCOS-II under Win32 providing a soft real-time-environment on PCs. If the basic functionality of the application is working correctly, the application can be easily ported to an embedded system later in the lab.
Figure 1 shows the relationship between the user application, uCOS-II the underlying Windows system.
Figure 1: Application / uCOS-II / Windows Vista Relationship
As a result of this hierarchy, µC/OS-II tasks are really Windows threads and their stacks are converted to Windows thread stacks. The system ticker is driven by the high resolution multi-media timer if
Critical sections are implemented using the Win32
Fortunately, the underlying architecture is transparent to the application programmer and all µC/OS-II application code can utilize various features using tradiational documented µC/OS-II function calls.
Since µC/OS-II is an infinite loop by nature, it should be noted that the processor utilization under windows will remain close to 100% while µC/OS-II is running. This is normal operating behavior for infinite loop consol based programs under Windows.
uCOS-II Win32 Simulation with Windows Vista
Most of the previous tests of the Win32 ports were never done, until writing this document, with Windows Vista. In this document, I will show how you can run a Win32 port used with Windows XP under Windows Vista.
To build this tutorial on your own, you need to download:
1. uCOS-II source code V2.86 from here
2. uCOS-II Win32 port from here
3. Open Watcom C-C++ 1.8 from here
Steps to Build the Tutorial
1. Install the Open Watcom C-C++ under the C drive
2. Extract uCOS-II source code and Win32 port
3. Build the following directory structure:
The first 3 file are copied from the application files found in the directories of Visual Studio 6 under Windows XP while the last file is copied from os_cfg_r.h and just renamed.
4. Make the following changes in the source:
a. In os_cfg.h, change OS_TMR_EN to 0
b. In app.c, change OS_IDLE_PRIO and OS_STAT_PRIO to OS_TASK_IDLE_PRIO and OS_TASK_STAT_PRIO respectively
5. Under the EX1-OS, create a new project using the Open Watcom IDE. The target should be a Win32 character mode executable.
6. After the project creation of the project, add the following sources as shown in Figure 2.
Figure 2: Open Watcom C-C++ 1.8 Project Structure
7. Under Options>C Compiler Switches>File Options Switches>Include directories>, modify the text box be "$(%watcom)/h;$(%watcom)/h/nt;.;../../../../../uCOS-II/Source;../../../../../uCOS-II/Ports/WIN32".
8. Under Options>Windows Linking Switches>Import, Export and Library Switches>Libraries>, modify the text box to be "winmm".
9. Click Make All, the tutorial should compile error free.
10. Click Run, you should get the output shown in Figure 3.