Rtems id question

Joel Sherrill <joel@OARcorp.com> joel.sherrill at OARcorp.com
Mon Apr 18 13:54:28 UTC 2005


Manuel Pedro Coutinho wrote:
> 
> Hi
> 
> I'm trying to use the partition and rate monotonic managers on different 
> tasks and I can't make them work properly
> 
> If I do (for the rate monotonic example)
> 
> Init(...)
> {
>  /* Task Start */
>  status = rtems_task_create( rtems_build_name( 'T', 'A', '1', ' ' ),   10,
>                    RTEMS_MINIMUM_STACK_SIZE , RTEMS_DEFAULT_MODES,
>                    RTEMS_FLOATING_POINT | RTEMS_GLOBAL, &id1);
> 
>  status = rtems_task_create( rtems_build_name( 'T', 'A', '2', ' ' ),   20,
>              RTEMS_MINIMUM_STACK_SIZE , RTEMS_DEFAULT_MODES,
>                   RTEMS_FLOATING_POINT | RTEMS_GLOBAL, &id2);
> 
>  status = rtems_task_create( rtems_build_name( 'T', 'A', '3', ' ' ),   30,
>              RTEMS_MINIMUM_STACK_SIZE , RTEMS_DEFAULT_MODES,
>                   RTEMS_FLOATING_POINT | RTEMS_GLOBAL, &id3);
> 
>  /* Rate monotonic Create*/
>  rtems_rate_monotonic_create(rtems_build_name( 'R' , 'T' , 'A' , 
> '1'),&period1);
>  rtems_rate_monotonic_create(rtems_build_name( 'R' , 'T' , 'A' , 
> '2'),&period2);
>  rtems_rate_monotonic_create(rtems_build_name( 'R' , 'T' , 'A' , 
> '3'),&period3);
> 
>  /* Rate monotonic start */
>  rtems_rate_monotonic_period(periodo1,100);
>  rtems_rate_monotonic_period(periodo2,200);
>  rtems_rate_monotonic_period(periodo3,300);
> 
>   /* Task Start */
>   status = rtems_task_start( id3, Task3 , 0 );
>   status = rtems_task_start( id2, Task2 , 0 );
>   status = rtems_task_start( id1, Task1 , 0 );
>   ...
> }
> 
> 
> 
> and then on each task do something like:
> 
> 
> 
> rtems_task Task1(rtems_task_argument arg)
> {
>  rtems_rate_monotonic_period_status status;
>  rtems_id period1;
>  rtems_status_code stat;
> 
>  stat = rtems_rate_monotonic_ident( rtems_build_name('R' , 'T' , 'A' , 
> '1' ) , &period1);
>  if( stat != RTEMS_SUCCESSFUL )
>     fatal_error("error\n");
> 
>  while(1)
>  {
>           /* PERFORM TASK1 */
>           .....
> 
> 
>           /* Wait for end of period */
>           if(rtems_rate_monotonic_period(period1,100) == RTEMS_TIMEOUT)
>     fatal_error("error!");
>  }
> }
> 
> 
> This task can't increment the tick count and stays blocked in the 
> rate_monotonic_period, but
> the RTEMS functions don't return error. The system.h is defined as follows
> 
> 
> 
> #define CONFIGURE_MAXIMUM_TASKS                        10
> #define CONFIGURE_MICROSECONDS_PER_TICK           100000/2
> #define CONFIGURE_TEST_NEEDS_CLOCK_DRIVER
> #define CONFIGURE_TEST_NEEDS_CONSOLE_DRIVER
> #define CONFIGURE_RTEMS_INIT_TASKS_TABLE
> #define CONFIGURE_MAXIMUM_PERIODS                     30
> #define CONFIGURE_INIT
> #define CONFIGURE_INIT_TASK_PRIORITY                  1
> #include <confdefs.h>
> 
> 
> if the rate monotonic is built on each task seperatly, the system works 
> so I guess this isn't a problem of bad configuration.
> Also, if instead of each searching for the rate monotonic name, it uses 
> its global id variable, the result is the same: the tick variable 
> doesn't change.

The periods are supposed to be started in the task that uses them.
There is bookkeeping assocated with a task if I remember right and
by starting it in another task, you may be messing that up.

> A similar error comes when I use the partition: It's created during 
> driver initialization and when used on a task (using its global id), the 
> partition_get function doesn't return an error but something "stupid" 
> happens: I do the following
> 
>  rtems_partition_get( partition_id, &pointer );
>  pointer->some_field = 10;
> 
> and when I print the pointer->some_field, it always returns 255, no 
> matter of what I try to put there! (by the way, the pointer->some_field 
> is an unsigned char)

Are you sure the managers are in the executable?

Are you declaring the appropriate variables as global?  If they are on 
the stack, they are private to a task and will disappear entirely when 
something falls otu of scope.

> Can anyone tell me what I'm doing wrong? I'm sure this must be something 
> very simple to workout, but I can't manage to figure this one out!
> 
> Many Thanks
> Manuel Coutinho
> 
> _________________________________________________________________
> MSN Hotmail, o maior webmail do Brasil. http://www.hotmail.com
> 


-- 
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 mailing list