source: rtems/testsuites/libtests/rtmonuse/task1.c @ 43e3429

4.104.114.95
Last change on this file since 43e3429 was 43e3429, checked in by Glenn Humphrey <glenn.humphrey@…>, on 10/26/07 at 21:31:48

2007-10-26 Glenn Humphrey <glenn.humphrey@…>

  • cpuuse/task2.c, rtmonuse/rtmonuse.scn, rtmonuse/task1.c: Add new cases for untested routines.
  • Property mode set to 100644
File size: 3.7 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( "" );
110          rtems_rate_monotonic_report_statistics();
111
112          rtems_rate_monotonic_reset_statistics( rmid );
113          puts( "" );
114          puts( "TA5 - PERIOD STATISTICS RESET" );
115          puts( "" );
116          rtems_rate_monotonic_report_statistics();
117
118          rtems_rate_monotonic_reset_all_statistics();
119          puts( "" );
120          puts( "TA5 - ALL PERIOD STATISTICS RESET" );
121          puts( "" );
122          rtems_rate_monotonic_report_statistics();
123
124          puts( "" );
125          puts( "*** END OF RATE MONOTONIC PERIOD STATISTICS TEST ***" );
126
127          rtems_test_exit( 0 );
128        }
129
130      }
131      break;
132  }
133}
Note: See TracBrowser for help on using the repository browser.