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 8";
0043
0044 rtems_id Test_task_id;
0045
0046 rtems_task test_task(
0047 rtems_task_argument argument
0048 );
0049 rtems_task test_task1(
0050 rtems_task_argument argument
0051 );
0052 void test_init(void);
0053
0054 rtems_task Init(
0055 rtems_task_argument argument
0056 )
0057 {
0058 Print_Warning();
0059
0060 TEST_BEGIN();
0061
0062 test_init();
0063
0064 rtems_task_exit();
0065 }
0066
0067 void test_init(void)
0068 {
0069 rtems_status_code status;
0070
0071 status = rtems_task_create(
0072 1,
0073 (RTEMS_MAXIMUM_PRIORITY / 2u) + 1u,
0074 RTEMS_MINIMUM_STACK_SIZE,
0075 RTEMS_DEFAULT_MODES,
0076 RTEMS_DEFAULT_ATTRIBUTES,
0077 &Test_task_id
0078 );
0079 directive_failed( status, "rtems_task_create" );
0080
0081 status = rtems_task_start( Test_task_id, test_task, 0 );
0082 directive_failed( status, "rtems_task_start" );
0083
0084 status = rtems_task_create(
0085 1,
0086 RTEMS_MAXIMUM_PRIORITY - 1u,
0087 RTEMS_MINIMUM_STACK_SIZE,
0088 RTEMS_DEFAULT_MODES,
0089 RTEMS_DEFAULT_ATTRIBUTES,
0090 &Test_task_id
0091 );
0092 directive_failed( status, "rtems_task_create" );
0093
0094 status = rtems_task_start( Test_task_id, test_task1, 0 );
0095 directive_failed( status, "rtems_task_start" );
0096 }
0097
0098 rtems_task test_task(
0099 rtems_task_argument argument
0100 )
0101 {
0102 rtems_status_code status;
0103 uint32_t index;
0104 rtems_task_priority old_priority;
0105 rtems_time_of_day time;
0106 rtems_mode old_mode;
0107 rtems_mode desired_mode;
0108
0109 benchmark_timer_initialize();
0110 for ( index=1 ; index <= OPERATION_COUNT ; index++ )
0111 (void) benchmark_timer_empty_function();
0112 overhead = benchmark_timer_read();
0113
0114 benchmark_timer_initialize();
0115 for ( index=1 ; index <= OPERATION_COUNT ; index++ )
0116 (void) rtems_task_set_priority(
0117 Test_task_id,
0118 RTEMS_CURRENT_PRIORITY,
0119 &old_priority
0120 );
0121 end_time = benchmark_timer_read();
0122
0123 put_time(
0124 "rtems_task_set_priority: obtain current priority",
0125 end_time,
0126 OPERATION_COUNT,
0127 overhead,
0128 0
0129 );
0130
0131 benchmark_timer_initialize();
0132 for ( index=1 ; index <= OPERATION_COUNT ; index++ )
0133 (void) rtems_task_set_priority(
0134 Test_task_id,
0135 RTEMS_MAXIMUM_PRIORITY - 2u,
0136 &old_priority
0137 );
0138
0139 end_time = benchmark_timer_read();
0140
0141 put_time(
0142 "rtems_task_set_priority: returns to caller",
0143 end_time,
0144 OPERATION_COUNT,
0145 overhead,
0146 0
0147 );
0148
0149 benchmark_timer_initialize();
0150 for ( index=1 ; index <= OPERATION_COUNT ; index++ )
0151 (void) rtems_task_mode(
0152 RTEMS_CURRENT_MODE,
0153 RTEMS_CURRENT_MODE,
0154 &old_mode
0155 );
0156 end_time = benchmark_timer_read();
0157
0158 put_time(
0159 "rtems_task_mode: obtain current mode",
0160 end_time,
0161 OPERATION_COUNT,
0162 overhead,
0163 0
0164 );
0165
0166 desired_mode = old_mode;
0167
0168 benchmark_timer_initialize();
0169 for ( index=1 ; index <= OPERATION_COUNT ; index++ ) {
0170 (void) rtems_task_mode(
0171 RTEMS_TIMESLICE_MASK,
0172 desired_mode,
0173 &old_mode
0174 );
0175 (void) rtems_task_mode(
0176 RTEMS_TIMESLICE_MASK,
0177 desired_mode,
0178 &old_mode
0179 );
0180 }
0181 end_time = benchmark_timer_read();
0182
0183 put_time(
0184 "rtems_task_mode: no reschedule",
0185 end_time,
0186 OPERATION_COUNT * 2,
0187 overhead,
0188 0
0189 );
0190
0191 benchmark_timer_initialize();
0192 (void) rtems_task_mode( RTEMS_NO_ASR, RTEMS_ASR_MASK, &old_mode );
0193 end_time = benchmark_timer_read();
0194
0195 put_time(
0196 "rtems_task_mode: reschedule returns to caller",
0197 end_time,
0198 1,
0199 0,
0200 0
0201 );
0202
0203 status = rtems_task_mode( RTEMS_NO_PREEMPT, RTEMS_PREEMPT_MASK, &old_mode );
0204 directive_failed( status, "rtems_task_mode" );
0205
0206 status = rtems_task_set_priority( Test_task_id, 1, &old_priority );
0207 directive_failed( status, "rtems_task_set_priority" );
0208
0209
0210 benchmark_timer_initialize();
0211 (void) rtems_task_mode( RTEMS_PREEMPT, RTEMS_PREEMPT_MASK, &old_mode );
0212
0213 build_time( &time, 1, 1, 1988, 0, 0, 0, 0 );
0214
0215 benchmark_timer_initialize();
0216 for ( index=1 ; index <= OPERATION_COUNT ; index++ )
0217 (void) rtems_clock_set( &time );
0218 end_time = benchmark_timer_read();
0219
0220 put_time(
0221 "rtems_clock_set: only case",
0222 end_time,
0223 OPERATION_COUNT,
0224 overhead,
0225 0
0226 );
0227
0228 benchmark_timer_initialize();
0229 for ( index=1 ; index <= OPERATION_COUNT ; index++ )
0230 (void) rtems_clock_get_tod( &time );
0231 end_time = benchmark_timer_read();
0232
0233 put_time(
0234 "rtems_clock_get_tod: only case",
0235 end_time,
0236 OPERATION_COUNT,
0237 overhead,
0238 0
0239 );
0240
0241 TEST_END();
0242 rtems_test_exit( 0 );
0243 }
0244
0245 rtems_task test_task1(
0246 rtems_task_argument argument
0247 )
0248 {
0249 end_time = benchmark_timer_read();
0250
0251 put_time(
0252 "rtems_task_mode: reschedule -- preempts caller",
0253 end_time,
0254 1,
0255 0,
0256 0
0257 );
0258
0259 (void) rtems_task_suspend( RTEMS_SELF );
0260 }