File indexing completed on 2025-05-11 08:24:50
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029 #if !defined(OPERATION_COUNT)
0030 #define OPERATION_COUNT 100
0031 #endif
0032
0033 #ifdef HAVE_CONFIG_H
0034 #include "config.h"
0035 #endif
0036
0037 #include <rtems/btimer.h>
0038
0039 #define CONFIGURE_INIT
0040 #include "system.h"
0041
0042 const char rtems_test_name[] = "TIME TEST 29";
0043
0044 rtems_name Period_name;
0045
0046 rtems_task Tasks(
0047 rtems_task_argument argument
0048 );
0049
0050 rtems_task Low_task(
0051 rtems_task_argument argument
0052 );
0053
0054 uint32_t Task_count;
0055
0056 rtems_task Init(
0057 rtems_task_argument argument
0058 )
0059 {
0060 rtems_id id;
0061 uint32_t index;
0062 rtems_status_code status;
0063
0064 Print_Warning();
0065
0066 TEST_BEGIN();
0067
0068 Period_name = rtems_build_name( 'P', 'R', 'D', ' ' );
0069
0070 benchmark_timer_initialize();
0071 (void) rtems_rate_monotonic_create( Period_name, &id );
0072 end_time = benchmark_timer_read();
0073
0074 put_time(
0075 "rtems_rate_monotonic_create: only case",
0076 end_time,
0077 1,
0078 0,
0079 0
0080 );
0081
0082 benchmark_timer_initialize();
0083 (void) rtems_rate_monotonic_period( id, 10 );
0084 end_time = benchmark_timer_read();
0085
0086 put_time(
0087 "rtems_rate_monotonic_period: initiate period returns to caller",
0088 end_time,
0089 1,
0090 0,
0091 0
0092 );
0093
0094 benchmark_timer_initialize();
0095 (void) rtems_rate_monotonic_period( id, RTEMS_PERIOD_STATUS );
0096 end_time = benchmark_timer_read();
0097
0098 put_time(
0099 "rtems_rate_monotonic_period: obtain status",
0100 end_time,
0101 1,
0102 0,
0103 0
0104 );
0105
0106 benchmark_timer_initialize();
0107 (void) rtems_rate_monotonic_cancel( id );
0108 end_time = benchmark_timer_read();
0109
0110 put_time(
0111 "rtems_rate_monotonic_cancel: only case",
0112 end_time,
0113 1,
0114 0,
0115 0
0116 );
0117
0118 benchmark_timer_initialize();
0119 (void) rtems_rate_monotonic_delete( id );
0120 end_time = benchmark_timer_read();
0121
0122 put_time(
0123 "rtems_rate_monotonic_delete: inactive",
0124 end_time,
0125 1,
0126 0,
0127 0
0128 );
0129
0130 status = rtems_rate_monotonic_create( Period_name, &id );
0131 directive_failed( status, "rtems_rate_monotonic_create" );
0132
0133 status = rtems_rate_monotonic_period( id, 10 );
0134 directive_failed( status, "rtems_rate_monotonic_period" );
0135
0136 benchmark_timer_initialize();
0137 rtems_rate_monotonic_delete( id );
0138 end_time = benchmark_timer_read();
0139
0140 put_time(
0141 "rtems_rate_monotonic_delete: active",
0142 end_time,
0143 1,
0144 0,
0145 0
0146 );
0147
0148 #define LOOP_TASK_PRIORITY ((RTEMS_MAXIMUM_PRIORITY / 2u) + 1u)
0149 for ( index=1 ; index <= OPERATION_COUNT ; index++ ) {
0150 status = rtems_task_create(
0151 rtems_build_name( 'T', 'E', 'S', 'T' ),
0152 LOOP_TASK_PRIORITY,
0153 RTEMS_MINIMUM_STACK_SIZE,
0154 RTEMS_DEFAULT_MODES,
0155 RTEMS_DEFAULT_ATTRIBUTES,
0156 &id
0157 );
0158 directive_failed( status, "rtems_task_create LOOP" );
0159
0160 status = rtems_task_start( id, Tasks, 0 );
0161 directive_failed( status, "rtems_task_start LOOP" );
0162 }
0163
0164 #define MIDDLE_PRIORITY (RTEMS_MAXIMUM_PRIORITY - 2u)
0165 status = rtems_task_create(
0166 rtems_build_name( 'L', 'O', 'W', ' ' ),
0167 MIDDLE_PRIORITY,
0168 RTEMS_MINIMUM_STACK_SIZE,
0169 RTEMS_DEFAULT_MODES,
0170 RTEMS_DEFAULT_ATTRIBUTES,
0171 &id
0172 );
0173 directive_failed( status, "rtems_task_create LOW" );
0174
0175 status = rtems_task_start( id, Low_task, 0 );
0176 directive_failed( status, "rtems_task_start LOW" );
0177
0178 Task_count = 0;
0179
0180 rtems_task_exit();
0181 }
0182
0183 rtems_task Tasks(
0184 rtems_task_argument argument
0185 )
0186 {
0187 rtems_id id;
0188 rtems_status_code status;
0189
0190 status = rtems_rate_monotonic_create( 1, &id );
0191 directive_failed( status, "rtems_rate_monotonic_create" );
0192
0193 status = rtems_rate_monotonic_period( id, 100 );
0194 directive_failed( status, "rtems_rate_monotonic_period" );
0195
0196
0197
0198
0199
0200
0201
0202 (void) rtems_task_wake_after( RTEMS_YIELD_PROCESSOR );
0203
0204 Task_count++;
0205
0206 if ( Task_count == 1 )
0207 benchmark_timer_initialize();
0208
0209 (void) rtems_rate_monotonic_period( id, 100 );
0210 }
0211
0212 rtems_task Low_task(
0213 rtems_task_argument argument
0214 )
0215 {
0216 uint32_t index;
0217
0218 end_time = benchmark_timer_read();
0219
0220 benchmark_timer_initialize();
0221 for ( index=1 ; index <= OPERATION_COUNT ; index++ )
0222 (void) benchmark_timer_empty_function();
0223 overhead = benchmark_timer_read();
0224
0225 put_time(
0226 "rtems_rate_monotonic_period: conclude periods caller blocks",
0227 end_time,
0228 OPERATION_COUNT,
0229 overhead,
0230 0
0231 );
0232
0233 TEST_END();
0234 rtems_test_exit( 0 );
0235 }