execute multiple tasks
Luca Cinquepalmi
cinquepalmi at planetek.it
Fri May 11 07:50:13 UTC 2012
Hi all,
I've developed the following C code with two tasks which execute a
simple printf, but
only the first printf is executed, and I don't understand why... Is
there an error in my code?
Thanks a lot.
Luca
/*
* multiTask.c
*
* Created on: May 10, 2012
* Author: Luca Cinquepalmi
*/
#include <rtems.h>
#define CONFIGURE_INIT
#include <bsp.h>
rtems_task Init (rtems_task_argument argument);
rtems_task task1 (rtems_task_argument argument);
rtems_task task2 (rtems_task_argument argument);
#define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
#define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
#define CONFIGURE_MAXIMUM_TASKS 4
#define CONFIGURE_RTEMS_INIT_TASKS_TABLE
#define CONFIGURE_EXTRA_TASK_STACKS (3 * RTEMS_MINIMUM_STACK_SIZE)
#include <rtems/confdefs.h>
#include <stdio.h>
#include <stdlib.h>
#include "leon.h"
#include "define.h"
rtems_id tid[3];
rtems_name name[3];
rtems_task Init(rtems_task_argument ignored)
{
rtems_status_code status;
name[1] = rtems_build_name('A','P','P','1');
name[2] = rtems_build_name('A','P','P','2');
status = rtems_task_create(
name[1], 1, RTEMS_MINIMUM_STACK_SIZE,
RTEMS_DEFAULT_MODES,
RTEMS_DEFAULT_ATTRIBUTES, &tid[1]);
if ( status != RTEMS_SUCCESSFUL ) {
printf( "rtems_task_create 1 failed with status of %d.\n\r",
status);
exit(1);
}
else
printf("task 1 create OK\n\r");
status = rtems_task_create(
name[2], 1, RTEMS_MINIMUM_STACK_SIZE,
RTEMS_DEFAULT_MODES,
RTEMS_DEFAULT_ATTRIBUTES, &tid[2]);
if ( status != RTEMS_SUCCESSFUL ) {
printf( "rtems_task_create 2 failed with status of %d.\n\r",
status);
exit(1);
}
else
printf("task 2 create OK\n\r");
printf("Print of Init task!\n\r");
status = rtems_task_start( tid[1], task1, 1 );
if ( status != RTEMS_SUCCESSFUL ) {
printf( "rtems_task_start 1 failed with status of
%d.\n\r", status);
exit(1);
}
else
printf("task 1 start OK\n\r");
status = rtems_task_start( tid[2], task2, 2 );
if ( status != RTEMS_SUCCESSFUL ) {
printf( "rtems_task_start 2 failed with status of %d.\n\r",
status);
exit(1);
}
else
printf("task 2 start OK\n\r");
status = rtems_task_delete( RTEMS_SELF );
exit(1);
}
rtems_task task1(rtems_task_argument ignored)
{
printf("Task 1 printing\n\r");
}
rtems_task task2(rtems_task_argument ignored)
{
printf("Task 2 printing\n\r");
}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.rtems.org/pipermail/users/attachments/20120511/c4b4246d/attachment.html>
More information about the users
mailing list