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
0030 #if !defined(OPERATION_COUNT)
0031 #define OPERATION_COUNT 100
0032 #endif
0033
0034 #ifdef HAVE_CONFIG_H
0035 #include "config.h"
0036 #endif
0037
0038 #include <rtems/btimer.h>
0039
0040 #define CONFIGURE_INIT
0041 #include "system.h"
0042
0043 const char rtems_test_name[] = "TIME TEST 22";
0044
0045 rtems_id Queue_id;
0046
0047 long Buffer[4];
0048
0049 rtems_task Low_task(
0050 rtems_task_argument argument
0051 );
0052
0053 rtems_task High_task(
0054 rtems_task_argument argument
0055 );
0056
0057 rtems_task Preempt_task(
0058 rtems_task_argument argument
0059 );
0060
0061 rtems_task Init(
0062 rtems_task_argument argument
0063 )
0064 {
0065 rtems_id id;
0066 rtems_status_code status;
0067
0068 Print_Warning();
0069
0070 TEST_BEGIN();
0071
0072 status = rtems_message_queue_create(
0073 rtems_build_name( 'M', 'Q', '1', ' '),
0074 100,
0075 MESSAGE_SIZE,
0076 RTEMS_DEFAULT_ATTRIBUTES,
0077 &Queue_id
0078 );
0079 directive_failed( status, "rtems_message_queue_create" );
0080
0081 status = rtems_task_create(
0082 rtems_build_name( 'L', 'O', 'W', ' ' ),
0083 10,
0084 RTEMS_MINIMUM_STACK_SIZE,
0085 RTEMS_NO_PREEMPT,
0086 RTEMS_DEFAULT_ATTRIBUTES,
0087 &id
0088 );
0089 directive_failed( status, "rtems_task_create" );
0090
0091 status = rtems_task_start( id, Low_task, 0 );
0092 directive_failed( status, "rtems_task_start LOW" );
0093
0094 status = rtems_task_create(
0095 1,
0096 11,
0097 RTEMS_MINIMUM_STACK_SIZE,
0098 RTEMS_DEFAULT_MODES,
0099 RTEMS_DEFAULT_ATTRIBUTES,
0100 &id
0101 );
0102 directive_failed( status, "rtems_task_create RTEMS_PREEMPT" );
0103
0104 status = rtems_task_start( id, Preempt_task, 0 );
0105 directive_failed( status, "rtems_task_start RTEMS_PREEMPT" );
0106
0107 rtems_task_exit();
0108 }
0109
0110 rtems_task High_task(
0111 rtems_task_argument argument
0112 )
0113 {
0114 uint32_t count;
0115 rtems_status_code status;
0116
0117 benchmark_timer_initialize();
0118 (void) rtems_message_queue_broadcast(
0119 Queue_id,
0120 Buffer,
0121 MESSAGE_SIZE,
0122 &count
0123 );
0124 end_time = benchmark_timer_read();
0125
0126 put_time(
0127 "rtems_message_queue_broadcast: task readied returns to caller",
0128 end_time,
0129 1,
0130 0,
0131 0
0132 );
0133
0134 status = rtems_task_suspend(RTEMS_SELF);
0135 directive_failed( status, "rtems_task_suspend" );
0136 }
0137
0138 rtems_task Low_task(
0139 rtems_task_argument argument
0140 )
0141 {
0142 rtems_id id;
0143 uint32_t index;
0144 uint32_t count;
0145 size_t size;
0146 rtems_status_code status;
0147
0148 status = rtems_task_create(
0149 rtems_build_name( 'H', 'I', 'G', 'H' ),
0150 5,
0151 RTEMS_MINIMUM_STACK_SIZE,
0152 RTEMS_NO_PREEMPT,
0153 RTEMS_DEFAULT_ATTRIBUTES,
0154 &id
0155 );
0156 directive_failed( status, "rtems_task_create" );
0157
0158 status = rtems_task_start( id, High_task, 0 );
0159 directive_failed( status, "rtems_task_start HIGH" );
0160
0161 status = rtems_message_queue_receive(
0162 Queue_id,
0163 (long (*)[4]) Buffer,
0164 &size,
0165 RTEMS_DEFAULT_OPTIONS,
0166 RTEMS_NO_TIMEOUT
0167 );
0168 directive_failed( status, "message_queu_receive" );
0169
0170 benchmark_timer_initialize();
0171 for ( index=1 ; index <= OPERATION_COUNT ; index++ )
0172 (void) rtems_message_queue_broadcast(
0173 Queue_id,
0174 Buffer,
0175 MESSAGE_SIZE,
0176 &count
0177 );
0178 end_time = benchmark_timer_read();
0179
0180 put_time(
0181 "rtems_message_queue_broadcast: no waiting tasks",
0182 end_time,
0183 OPERATION_COUNT,
0184 1,
0185 0
0186 );
0187
0188 (void) rtems_message_queue_receive(
0189 Queue_id,
0190 (long (*)[4]) Buffer,
0191 &size,
0192 RTEMS_DEFAULT_OPTIONS,
0193 RTEMS_NO_TIMEOUT
0194 );
0195
0196
0197
0198 end_time = benchmark_timer_read();
0199
0200 put_time(
0201 "rtems_message_queue_broadcast: task readied -- preempts caller",
0202 end_time,
0203 1,
0204 0,
0205 0
0206 );
0207
0208 TEST_END();
0209 rtems_test_exit( 0 );
0210 }
0211
0212 rtems_task Preempt_task(
0213 rtems_task_argument argument
0214 )
0215 {
0216 uint32_t count;
0217
0218 benchmark_timer_initialize();
0219 (void) rtems_message_queue_broadcast(
0220 Queue_id,
0221 Buffer,
0222 MESSAGE_SIZE,
0223 &count
0224 );
0225
0226
0227 }