source: rtems/testsuites/sptests/sp20/task1.c @ c87608f

4.104.114.84.9
Last change on this file since c87608f was c87608f, checked in by Ralf Corsepius <ralf.corsepius@…>, on Mar 30, 2004 at 11:15:35 AM

2004-03-30 Ralf Corsepius <ralf_corsepius@…>

  • sp02/task1.c, sp04/system.h, sp04/task1.c, sp04/tswitch.c, sp05/task1.c, sp06/task1.c, sp09/screen01.c, sp09/screen07.c, sp09/screen12.c, sp09/system.h, sp09/task3.c, sp11/task1.c, sp12/pridrv.c, sp12/pritask.c, sp12/system.h, sp13/task1.c, sp13/task2.c, sp13/task3.c, sp14/system.h, sp15/system.h, sp16/system.h, sp17/system.h, sp19/first.c, sp19/fptask.c, sp19/inttest.h, sp19/system.h, sp19/task1.c, sp20/init.c, sp20/system.h, sp20/task1.c, sp23/system.h, sp24/init.c, sp25/system.h, sp30/init.c, spfatal/fatal.c, spfatal/puterr.c, spfatal/system.h, spsize/size.c: Convert to using c99 fixed size types.
  • 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  uint32_t   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        Count.count[ argument ]++;
74      }
75      break;
76    case 5:
77      pass   = 0;
78      failed = 0;
79
80      status = rtems_rate_monotonic_period( rmid, Periods[ argument ] );
81      directive_failed( status, "rtems_rate_monotonic_period 1 of TA5" );
82
83      Get_all_counters();
84
85      while ( FOREVER ) {
86
87        status = rtems_rate_monotonic_period( rmid, Periods[ argument ] );
88        directive_failed( status, "rtems_rate_monotonic_period 2 of TA5" );
89
90        Get_all_counters();
91
92        for( index = 1 ; index <= 4 ; index++ ) {
93          if ( Temporary_count.count[ index ] != Iterations[ index ] ) {
94            puts_nocr( "FAIL -- " );
95            put_name ( Task_name[ index ], FALSE );
96            printf   ( " Actual=%d, Expected=%d\n",
97                       Temporary_count.count[ index ],
98                       Iterations[ index ]
99                     );
100            failed += 1;
101          }
102        }
103
104        if ( failed == 5 )
105          rtems_test_exit( 0 );
106
107        pass += 1;
108
109        printf( "TA5 - PERIODS CHECK OK (%d)\n", pass );
110
111        fflush( stdout );
112
113        if ( pass == 10 ) {
114          puts( "*** END OF TEST 20 ***" );
115          rtems_test_exit( 0 );
116        }
117
118      }
119      break;
120    case 6:
121      /* test changing periods */
122      {
123        uint32_t   time[TA6_ITERATIONS+1];
124        rtems_interval period;
125
126        period = 1*TA6_PERIOD_FACTOR;
127        status = rtems_rate_monotonic_period( rmid, period);
128        directive_failed( status, "rtems_rate_monotonic_period of TA6" );
129        time[0] = _Watchdog_Ticks_since_boot; /* timestamp */
130        /*printf("%d - %d\n", period, time[0]);*/
131
132        for (index = 1; index <= TA6_ITERATIONS; index++)
133        {
134          period = (index+1)*TA6_PERIOD_FACTOR;
135          status = rtems_rate_monotonic_period( rmid,  period);
136          directive_failed( status, "rtems_rate_monotonic_period of TA6" );
137          time[index] = _Watchdog_Ticks_since_boot; /* timestamp */
138          /*printf("%d - %d\n", period, time[index]);*/
139        }
140
141        for (index = 1; index <= TA6_ITERATIONS; index++)
142        {
143          rtems_interval meas = time[index] - time[index-1];
144          period = index*TA6_PERIOD_FACTOR;
145          printf("TA6 - Actual: %d  Expected: %d", meas, period);
146          if (period == meas) printf(" - OK\n");
147          else printf(" - FAILED\n");
148        }
149      }
150      rtems_task_suspend(RTEMS_SELF);
151      break;
152  }
153}
Note: See TracBrowser for help on using the repository browser.