Rtems id question

Manuel Pedro Coutinho manuelpedrocoutinho at hotmail.com
Fri Apr 22 07:38:51 UTC 2005



>From: "Manuel Pedro Coutinho" <manuelpedrocoutinho at hotmail.com>
>To: joel.sherrill at OARcorp.com
>CC: rtems-users at rtems.com
>Subject: Re: Rtems id question
>Date: Mon, 18 Apr 2005 16:23:07 +0100
>
>
>
>>From: "Joel Sherrill <joel at OARcorp.com>" <joel.sherrill at OARcorp.com>
>>Reply-To: joel.sherrill at OARcorp.com
>>To: Manuel Pedro Coutinho <manuelpedrocoutinho at hotmail.com>
>>CC: rtems-users at rtems.com
>>Subject: Re: Rtems id question
>>Date: Mon, 18 Apr 2005 08:54:28 -0500
>>
>>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.
>>
>
>(First of all, I apologize for sending this mail twice to joel sherrill)
>
>The managers are indeed in the executable (at least the application 
>Makefile has Managers = all)
>Has to declaring the variables as global... I'm sorry for the dumb 
>question, but one has to do more than the following:
>
>rtems_id   global_id;
>
>Init(...)
>{
>...
>}
>
>I thought that the problem was somehow related to the the task beeing 
>declared as global or local...
>
>Thanks again!
>Manuel Coutinho


I've discovered the error (or maybe it ins't an error). I created an 
partition during a driver initialization with the start address given by 
rtemsFreeMemStart. The problem was that this variable was already set to end 
of the RAM and there wasn't enough space to indeed allocate the desired 
memory. I've "corrected" this in the bspstart.c by decrising the _heap_size 
in the   bsp_pretasking_hook  function
It looked in the end something like this


      for(i=2048; i>=lowest; i--)
	{
	  topAddr = i*1024*1024 - 4;
	  *(volatile rtems_unsigned32 *)topAddr = topAddr;
	}

      for(i=lowest; i<=2048; i++)
	{
	  topAddr = i*1024*1024 - 4;
	  val =  *(rtems_unsigned32 *)topAddr;
	  if(val != topAddr)
	    {
	      break;
	    }
	}

      topAddr = (i-1)*1024*1024 - 4;

      _heap_size = topAddr - rtemsFreeMemStart;
    }
  _heap_size = _heap_size - 2 * 1024*1024;           /*  <<<<------ This is 
the line added--------*/
  bsp_libc_init((void *)rtemsFreeMemStart, _heap_size, 0);
  rtemsFreeMemStart += _heap_size;           /* HEAP_SIZE  in KBytes */


I simply removed 2 Mb from the heap destinated to the libc to place it to 
any partitions or regions that I needed to create

I guess this isn't very robust... I really don't know how one can configure 
this outside the RTEMS source tree... if anyone knows this, please let me 
know...

Thanks
Manuel Coutinho






>
>
>
>>>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
>>
>
>_________________________________________________________________
>MSN Hotmail, o maior webmail do Brasil. http://www.hotmail.com
>

_________________________________________________________________
MSN Busca: fácil, rápido, direto ao ponto.  http://search.msn.com.br




More information about the users mailing list