RTEMS simple example

Aleix Conchillo Flaque aconchillo at ieec.fcr.es
Thu Sep 29 16:34:38 UTC 2005


I've been playing a bit with RTEMS and thought that someone could be
interested in another example of RTEMS usage. I have taken the algorithms
found in a public file around called "stanford.c" and separated them into
tasks. The example uses quite a few features of RTEMS, such as semaphores,
message queues, events, memory regions and partitions and some other

This is my first attempt at using RTEMS so I'm sure a lot of things could be
done better and I would really appreciate if someone could point them
out, and  thus make the example better and useful for other people
wanting to learn RTEMS.

I have copied below the README file so you don't have to open the file to
see the idea.

The latest source tree can be found at:

>From there you can download a tarball. Or, you can download the tarball
directly from:

Thanks in advance for all the comments, critiques or whatever.


Aleix Conchillo Flaque   Software Engineer
aconchillo at ieec.fcr.es   Institut d'Estudis Espacials de Catalunya (IEEC)


RTEMS stanford example

This is a  simple example to show some of the  features of RTEMS.

The application is based on three kinds of tasks:

        - wait task: this task  waits for two events, RTEMS_EVENT_0 or
          RTEMS_EVENT_1 (see  RTEMS documentation for  event details).
          RTEMS_EVENT_0 is  sent by application  tasks indicating that
          they have finished.  RTEMS_EVENT_1 can only be sent from the
          error  task and indicates  a fatal  error causing  the whole
          application to stop. When RTEMS_EVENT_0 is received the wait
          task  also decrements the  counter of  running tasks  in the
          system. This counter is  controlled by a sempahore that with
          the current  implementation is not  needed at all (as  it is
          only used by  the wait task), but has been  kept to show the
          RTEMS semaphore API.

        - error task:  the error task  is in charge of  receving error
          messages  on a  queue. Two  types of  error messages  can be
          received,  normal or fatal  errors. When  a normal  error is
          received, the error tasks prints the acompanying description
          in the  message (only if  debug is activated). If  the error
          task  receives a fatal  error from  an application  task, it
          automatically sends an EVENT_1 to the wait task.

        - application  tasks:  these  tasks  perform some  well  known
          algorithms.   The  algorithms have  been  obtained from  the
          public file stanford.c (which  is also included in the 'etc'
          directory).   All of  the  application tasks  have the  same
          priority, this means that if a task have the RTEMS_TIMESLICE
          mode activated, it will share  the CPU with other tasks with
          the same priority and with RTEMS_TIMESLICE mode activated.

Note that  this example has only  been tested in  an ERC32 environment
and may not work in other  systems. For instance, the memory task uses
specific  ERC32  memory  addresses  which  should be  changed  to  the
specific ones in another system.


The stanford.c benchmarks were  gathered by John Hennessy and modified
by Peter Nye.

Aleix Conchillo Flaque <aconchillo at ieec.fcr.es>

More information about the users mailing list