Rate monotonic help
Gedare Bloom
gedare at gwmail.gwu.edu
Mon Jul 25 20:14:45 UTC 2011
Lee,
I have reproduced your problem.
Put this line at the end of your Init function:
status = rtems_task_delete( RTEMS_SELF );
That should fix it.
-Gedare
On Mon, Jul 25, 2011 at 4:08 PM, Joel Sherrill
<joel.sherrill at oarcorp.com> wrote:
> On 07/25/2011 02:51 PM, Matthews, Lee wrote:
>>
>> Hi Joel,
>>
>> Thanks for your reply. I set the clock tick using :
>>
>> #define CONFIGURE_MICROSECONDS_PER_TICK 8195
>>
>> Basically, I'm working on a digital filter and I need a function to
>> execute every 8.195ms (or 122Hz), hence the above value.
>>
>> I was indeed aiming for a tick to equal 1/122 of a second. Please excuse
>> my noob question, but why do you think that that can't be right? By setting
>> it to this value am I messing up the correct functioning of RTEMS?
>>
> It won't change the functioning but the clock tick is
> the basis for all timeouts and delays. So all of your
> timeouts will be in terms of 1/122 of a second.
>
> If that works as a reasonable common divisor for every
> timing loop or delay in the system, then all is OK. You just
> often see rates like 100Hz, 1000Hz, etc. and those are
> just match up nicely with this clock tick rate. :)
>
> But for rate monotonic periods, it should be OK since
> the task (assuming all preemptive and this is highest
> priority) will run first after each clock tick.
>
> *** This is all a balancing act of the timing ***
> *** granularity requirements of the set of tasks ***
> *** in your application. There is no universally ***
> *** right or wrong answer. ***
>
> FWIW Depending on RTEMS version, you will be able to
> get time of day down to the nanosecond though.
>
> --joel
>>
>> Best wishes,
>> Lee
>> ________________________________________
>> From: Joel Sherrill [joel.sherrill at oarcorp.com]
>> Sent: 25 July 2011 18:50
>> To: Matthews, Lee
>> Cc: 'rtems-users at rtems.org'
>> Subject: Re: Rate monotonic help
>>
>> What is your clock tick configured as? This is the
>> CONFIGURE_MICROSECONDS_PER_TICK configuration
>> parameter.
>>
>> FWIW your code assumes that 1 tick == 1/122 of
>> a second from what I can tell and that can't be
>> right.
>>
>> --joel
>>
>> On 07/25/2011 12:44 PM, Matthews, Lee wrote:
>>>
>>> Hi
>>>
>>> I’m developing some software that uses RTEMS on an Aeroflex Gaisler
>>> LEON3 processor that is running on a Pender GR-CPCI-AX2000 development
>>> board.
>>>
>>> I’d like to setup a task that is called 122 times per second. I’m
>>> currently trying to use the rtems rate_monotonic functions but I’m not
>>> having much luck.
>>>
>>> I have used the example code from the rtems_user_guide as a guide.
>>>
>>> My function looks like the following :
>>>
>>> rtems_task Periodic_task()
>>>
>>> {
>>>
>>> rtems_name name;
>>>
>>> rtems_id period;
>>>
>>> rtems_status_code status;
>>>
>>> unsigned int flag=0;
>>>
>>> unsigned long count=0;
>>>
>>> unsigned int i=0;
>>>
>>> printf( "Starting periodic function : 61Hz clock output.\n");
>>>
>>> printf( "Turning GPIO OFF.\n");
>>>
>>> gpiolib_set(port1,1,0); // Set GPIO0 to OFF
>>>
>>> for(count=0;count<1000000;count++) {}
>>>
>>> printf( "Exiting wait loop.\n");
>>>
>>> name = rtems_build_name( 'P', 'E', 'R', 'D' );
>>>
>>> status = rtems_rate_monotonic_create( name,&period );
>>>
>>> if ( status != RTEMS_SUCCESSFUL ) {
>>>
>>> printf( "rtems_monotonic_create failed with status of
>>> %d.\n", status );
>>>
>>> exit( 1 );
>>>
>>> }
>>>
>>> while ( 1 ) // RTEMS ticks per second set to 122.
>>>
>>> {
>>>
>>> if ( rtems_rate_monotonic_period( period, 1 ) ==
>>> RTEMS_TIMEOUT ) break;
>>>
>>> /* Perform some periodic actions */
>>>
>>> if(flag==0)
>>>
>>> {
>>>
>>> gpiolib_set(port1,1,1); // Set GPIO0 to ON
>>>
>>> flag=1;
>>>
>>> }
>>>
>>> else
>>>
>>> {
>>>
>>> gpiolib_set(port1,1,0); // Set GPIO0 to OFF
>>>
>>> flag=0;
>>>
>>> }
>>>
>>> }
>>>
>>> /* missed period so delete period and SELF */
>>>
>>> status = rtems_rate_monotonic_delete( period );
>>>
>>> if ( status != RTEMS_SUCCESSFUL ) {
>>>
>>> printf( "rate_monotonic_delete failed with status of
>>> %d.\n", status );
>>>
>>> exit( 1 );
>>>
>>> }
>>>
>>> status = rtems_task_delete( RTEMS_SELF );
>>>
>>> /* should not return */
>>>
>>> printf( "rtems_task_delete returned with status of %d.\n", status
>>> );
>>>
>>> exit(1);
>>>
>>> }
>>>
>>> I’d like for the function to turn one of the GPIO lines on and off
>>> repeatedly, but all that seems to happen is that the code within the
>>> while ( 1 ) loop executes once, then stops.
>>>
>>> The code that I use to create and start this task is the following :
>>>
>>> Task_name1 = rtems_build_name( 'P', 'E', 'R', 'D' ); // Set task name
>>> to 'PERD'
>>>
>>> status = rtems_task_create(Task_name1, 1,
>>> RTEMS_MINIMUM_STACK_SIZE * 2,
>>> RTEMS_DEFAULT_MODES,RTEMS_DEFAULT_ATTRIBUTES,&Task_id1);
>>>
>>> if(status!=RTEMS_SUCCESSFUL)
>>>
>>> {
>>>
>>> printf("rtems_task_create
>>> unsuccesful\n");
>>>
>>> exit( 0 ); // Exit
>>>
>>> }
>>>
>>> else
>>>
>>> printf("Created Periodic task\n");
>>>
>>> status = rtems_task_start( Task_id1, Periodic_task, 1
>>> ); // Start Periodic task
>>>
>>> if(status!=RTEMS_SUCCESSFUL)
>>>
>>> {
>>>
>>> printf("rtems_task_start unsuccesful\n");
>>>
>>> exit( 0 ); // Exit
>>>
>>> }
>>>
>>> Could anyone shed some light on what I’m doing wrong please?
>>>
>>> Thanks in advance,
>>>
>>> Lee
>>>
>>
>> --
>> Joel Sherrill, Ph.D. Director of Research& Development
>> joel.sherrill at OARcorp.com On-Line Applications Research
>> Ask me about RTEMS: a free RTOS Huntsville AL 35805
>> Support Available (256) 722-9985
>>
>>
>
>
> --
> Joel Sherrill, Ph.D. Director of Research& Development
> joel.sherrill at OARcorp.com On-Line Applications Research
> Ask me about RTEMS: a free RTOS Huntsville AL 35805
> Support Available (256) 722-9985
>
>
> _______________________________________________
> rtems-users mailing list
> rtems-users at rtems.org
> http://www.rtems.org/mailman/listinfo/rtems-users
>
More information about the users
mailing list