ChorusOS 5.0 Application Developer's Guide

Creating a Basic Application

When you build a standard ChorusOS sytem image on your target hardware system, a build directory is created in your work directory for each source component included in the system image. Each build directory contains the binary code for its associated component.


Note -

No directories are created for binary components.


Creating a Basic "Hello" Application

Create a src subdirectory on your host.

To create the basic "hello" application,

  1. Create the following files in the src directory:

    • hello.c, this source file will say "hello" and is written as follows:

      #include <stdio.h>
      
      int main()
      {
            /* Print the message */
        printf("Hello World\n");
        
        return 0;
      }

    • Imakefile. This file provides the rules to build the application and contains the following:

      UserActorTarget(hello_u,hello.o,)
      SupActorTarget(hello_s, hello.o,)

      The Imakefile declares:

      • The source files to be compiled (implicitly).

      • The libraries to be used (only standard libraries are used).

      • That you want to build both a user and a supervisor application called hello.

  2. Use the ChorusOSMkMf command to create a make file that will build your application:

    % ChorusOSMkMf build_dir
    

    The ChorusOSMkMf command should be located in your PATH. See "Setting Environment Variables" in the ChorusOS 5.0 Installation Guide for information on how to modify your PATH.

  3. Build your application:

    % make

Running the Application

Use the C_INIT loading facility to run the application dynamically, as follows:

ChorusOS operating system applications are loaded and locked in memory when they start. This means that physical memory for the application's text, data, and stack must be available at load time. The memstat command of C_INIT can be used to check if sufficient physical memory is available on the target system.