source: rtems/c/src/tests/sptests/sp20/task1.c @ cf42c54c

4.104.114.84.95
Last change on this file since cf42c54c was cf42c54c, checked in by Joel Sherrill <joel.sherrill@…>, on 09/29/00 at 14:51:16

2000-09-29 Stephan Merker <merker@…>

  • sp20/getall.c, sp20/init.c, sp20/system.h, sp20/task1.c: Added new task to test sequence of altering a period's length while it is still active.
  • 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.OARcorp.com/rtems/license.html.
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
29rtems_unsigned32    Periods[7]    = { 0,   2,   2,   2,   2, 100, 0 };
30rtems_unsigned32    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_unsigned32 argument
35)
36{
37  rtems_id          rmid;
38  rtems_id          test_rmid;
39  rtems_unsigned32  index;
40  rtems_unsigned32  pass;
41  rtems_unsigned32  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     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          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          exit( 0 );
116        }
117
118      }
119      break;
120    case 6:
121      /* test changing periods */
122      {
123        unsigned32 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.