source: rtems/testsuites/sptests/sp20/task1.c @ 496274b6

4.104.114.84.95
Last change on this file since 496274b6 was 496274b6, checked in by Joel Sherrill <joel.sherrill@…>, on 06/20/07 at 21:43:28

2007-06-20 Joel Sherrill <joel.sherrill@…>

  • sp20/task1.c, sp34/changepri.c, sp35/priinv.c: Build when using buffered test IO.
  • Property mode set to 100644
File size: 4.4 KB
Line 
1/*  Task_1_through_5
2 *
3 *  This routine serves as a test task for the period capabilities of the
4 *  Rate Monotonic Manager.
5 *
6 *  Input parameters:
7 *    argument - task argument
8 *
9 *  Output parameters:  NONE
10 *
11 *  COPYRIGHT (c) 1989-1999.
12 *  On-Line Applications Research Corporation (OAR).
13 *
14 *  The license and distribution terms for this file may be
15 *  found in the file LICENSE in this distribution or at
16 *  http://www.rtems.com/license/LICENSE.
17 *
18 *  $Id$
19 */
20
21#include "system.h"
22
23/*
24 runtime of TA6 should be shorter than TA5
25 */
26#define TA6_ITERATIONS 10
27#define TA6_PERIOD_FACTOR 10
28
29uint32_t      Periods[7]    = { 0,   2,   2,   2,   2, 100, 0 };
30uint32_t      Iterations[7] = { 0,  50,  50,  50,  50,   1, TA6_ITERATIONS };
31rtems_task_priority Priorities[7] = { 0,   1,   1,   3,   4,   5, 1 };
32
33rtems_task Task_1_through_6(
34  rtems_task_argument argument
35)
36{
37  rtems_id          rmid;
38  rtems_id          test_rmid;
39  uint32_t    index;
40  uint32_t    pass;
41  uint32_t    failed;
42  rtems_status_code status;
43
44  status = rtems_rate_monotonic_create( argument, &rmid );
45  directive_failed( status, "rtems_rate_monotonic_create" );
46  put_name( Task_name[ argument ], FALSE );
47  printf( "- rtems_rate_monotonic_create id = 0x%08x\n", rmid );
48
49  status = rtems_rate_monotonic_ident( argument, &test_rmid );
50  directive_failed( status, "rtems_rate_monotonic_ident" );
51  put_name( Task_name[ argument ], FALSE );
52  printf( "- rtems_rate_monotonic_ident id = 0x%08x\n", test_rmid );
53
54  if ( rmid != test_rmid ) {
55     printf( "RMID's DO NOT MATCH (0x%x and 0x%x)\n", rmid, test_rmid );
56     rtems_test_exit( 0 );
57  }
58
59  put_name( Task_name[ argument ], FALSE );
60  printf( "- (0x%08x) period %d\n", rmid, Periods[ argument ] );
61
62  status = rtems_task_wake_after( 2 );
63  directive_failed( status, "rtems_task_wake_after" );
64
65  switch ( argument ) {
66    case 1:
67    case 2:
68    case 3:
69    case 4:
70      while ( FOREVER ) {
71        status = rtems_rate_monotonic_period( rmid, Periods[ argument ] );
72        directive_failed( status, "rtems_rate_monotonic_period" );
73
74        Count.count[ argument ]++;
75      }
76      break;
77    case 5:
78      pass   = 0;
79      failed = 0;
80
81      status = rtems_rate_monotonic_period( rmid, Periods[ argument ] );
82      directive_failed( status, "rtems_rate_monotonic_period 1 of TA5" );
83
84      Get_all_counters();
85
86      while ( FOREVER ) {
87
88        status = rtems_rate_monotonic_period( rmid, Periods[ argument ] );
89        directive_failed( status, "rtems_rate_monotonic_period 2 of TA5" );
90
91        Get_all_counters();
92
93        for( index = 1 ; index <= 4 ; index++ ) {
94          if ( Temporary_count.count[ index ] != Iterations[ index ] ) {
95            puts_nocr( "FAIL -- " );
96            put_name ( Task_name[ index ], FALSE );
97            printf   ( " Actual=%d, Expected=%d\n",
98                       Temporary_count.count[ index ],
99                       Iterations[ index ]
100                     );
101            failed += 1;
102          }
103        }
104
105        if ( failed == 5 )
106          rtems_test_exit( 0 );
107
108        pass += 1;
109
110        printf( "TA5 - PERIODS CHECK OK (%d)\n", pass );
111
112        fflush( stdout );
113
114        if ( pass == 10 ) {
115          puts( "*** END OF TEST 20 ***" );
116          rtems_test_exit( 0 );
117        }
118
119      }
120      break;
121    case 6:
122      /* test changing periods */
123      {
124        uint32_t   time[TA6_ITERATIONS+1];
125        rtems_interval period;
126
127        period = 1*TA6_PERIOD_FACTOR;
128        status = rtems_rate_monotonic_period( rmid, period);
129        directive_failed( status, "rtems_rate_monotonic_period of TA6" );
130        time[0] = _Watchdog_Ticks_since_boot; /* timestamp */
131        /*printf("%d - %d\n", period, time[0]);*/
132
133        for (index = 1; index <= TA6_ITERATIONS; index++)
134        {
135          period = (index+1)*TA6_PERIOD_FACTOR;
136          status = rtems_rate_monotonic_period( rmid,  period);
137          directive_failed( status, "rtems_rate_monotonic_period of TA6" );
138          time[index] = _Watchdog_Ticks_since_boot; /* timestamp */
139          /*printf("%d - %d\n", period, time[index]);*/
140        }
141
142        for (index = 1; index <= TA6_ITERATIONS; index++)
143        {
144          rtems_interval meas = time[index] - time[index-1];
145          period = index*TA6_PERIOD_FACTOR;
146          printf("TA6 - Actual: %d  Expected: %d", meas, period);
147          if (period == meas) printf(" - OK\n");
148          else printf(" - FAILED\n");
149        }
150      }
151      rtems_task_suspend(RTEMS_SELF);
152      break;
153  }
154}
Note: See TracBrowser for help on using the repository browser.