source: rtems/testsuites/libtests/rtmonuse/task1.c @ 838167e

4.104.114.84.95
Last change on this file since 838167e was 838167e, checked in by Joel Sherrill <joel.sherrill@…>, on 05/17/07 at 22:47:32

2007-05-17 Joel Sherrill <joel.sherrill@…>

  • ChangeLog?, rtmonuse/task1.c: Clean up output and use FLUSH_OUTPUT() macro instead of fflush() directly.
  • Property mode set to 100644
File size: 3.3 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-2007.
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#include <rtems/cpuuse.h>
24
25uint32_t      Periods[6]    = { 0,   2,   2,   2,   2, 100 };
26uint32_t      Iterations[6] = { 0,  50,  50,  50,  50,   1 };
27rtems_task_priority Priorities[6] = { 0,   1,   1,   3,   4,   5 };
28
29rtems_task Task_1_through_5(
30  rtems_task_argument argument
31)
32{
33  rtems_id          rmid;
34  rtems_id          test_rmid;
35  uint32_t    index;
36  uint32_t    pass;
37  uint32_t    failed;
38  rtems_status_code status;
39
40  status = rtems_rate_monotonic_create( argument, &rmid );
41  directive_failed( status, "rtems_rate_monotonic_create" );
42  put_name( Task_name[ argument ], FALSE );
43  printf( "- rtems_rate_monotonic_create id = 0x%08x\n", rmid );
44
45  status = rtems_rate_monotonic_ident( argument, &test_rmid );
46  directive_failed( status, "rtems_rate_monotonic_ident" );
47  put_name( Task_name[ argument ], FALSE );
48  printf( "- rtems_rate_monotonic_ident id = 0x%08x\n", test_rmid );
49
50  if ( rmid != test_rmid ) {
51     printf( "RMID's DO NOT MATCH (0x%x and 0x%x)\n", rmid, test_rmid );
52     rtems_test_exit( 0 );
53  }
54
55  put_name( Task_name[ argument ], FALSE );
56  printf( "- (0x%08x) period %d\n", rmid, Periods[ argument ] );
57
58  status = rtems_task_wake_after( 2 );
59  directive_failed( status, "rtems_task_wake_after" );
60
61  switch ( argument ) {
62    case 1:
63    case 2:
64    case 3:
65    case 4:
66      while ( FOREVER ) {
67        status = rtems_rate_monotonic_period( rmid, Periods[ argument ] );
68        directive_failed( status, "rtems_rate_monotonic_period" );
69        Count.count[ argument ]++;
70      }
71      break;
72    case 5:
73      pass   = 0;
74      failed = 0;
75
76      status = rtems_rate_monotonic_period( rmid, Periods[ argument ] );
77      directive_failed( status, "rtems_rate_monotonic_period 1 of TA5" );
78
79      Get_all_counters();
80
81      while ( FOREVER ) {
82        status = rtems_rate_monotonic_period( rmid, Periods[ argument ] );
83        directive_failed( status, "rtems_rate_monotonic_period 2 of TA5" );
84
85        Get_all_counters();
86
87        for( index = 1 ; index <= 4 ; index++ ) {
88          if ( Temporary_count.count[ index ] != Iterations[ index ] ) {
89            puts_nocr( "FAIL -- " );
90            put_name ( Task_name[ index ], FALSE );
91            printf   ( " Actual=%d, Expected=%d\n",
92                       Temporary_count.count[ index ],
93                       Iterations[ index ]
94                     );
95            failed += 1;
96          }
97        }
98
99        if ( failed == 5 )
100          rtems_test_exit( 0 );
101
102        pass += 1;
103
104        printf( "TA5 - PERIODS CHECK OK (%d)\n", pass );
105
106        FLUSH_OUTPUT();
107
108        if ( pass == 10 ) {
109          puts( "*** END OF RATE MONOTONIC PERIOD STATISTICS TEST ***" );
110          puts( "" );
111          rtems_cpu_usage_report();
112          puts( "" );
113          rtems_rate_monotonic_report_statistics();
114          puts( "" );
115
116          rtems_test_exit( 0 );
117        }
118
119      }
120      break;
121  }
122}
Note: See TracBrowser for help on using the repository browser.