RTEMS simple example
Joel Sherrill <joel@OARcorp.com>
joel.sherrill at OARcorp.com
Thu Sep 29 18:14:46 UTC 2005
Aleix Conchillo Flaque wrote:
> 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
Neat. Would you mind if it got merged into RTEMS examples?
> 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.
You might want to consider adding a simple menu to the bottom of the
Init task which lets you print out the CPU usage or generate a stack
report if you have that turned on.
> I have copied below the README file so you don't have to open the file to
> see the idea.
The ERC32 specific addresses is easy to solve. We have this issue on
the RTEMS tests and solve it by declaring an array that is the memory
so the linker can easily account for it. It's just a test/demo so not
a problem. This is a hack at changing this.
static unsigned char partition_buffer[ 100000 ];
static void *partition_address = (void *) partition_buffer;
static unsigned int const partition_length = 100000;
static unsigned int const partition_buf_size = 10000;
static unsigned char region_buffer[ 20480 ];
static void *region_address = (void *) region_buffer;
static unsigned int const region_length = sizeof( region_buffer );
static unsigned int const region_page_size = 1024;
> 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>
Joel Sherrill, Ph.D. Director of Research & Development
joel at OARcorp.com On-Line Applications Research
Ask me about RTEMS: a free RTOS Huntsville AL 35805
Support Available (256) 722-9985
More information about the users