Back to home page

LXR

 
 

    


File indexing completed on 2025-05-11 08:24:50

0001 /* SPDX-License-Identifier: BSD-2-Clause */
0002 
0003 /*
0004  *  COPYRIGHT (c) 1989-2013.
0005  *  On-Line Applications Research Corporation (OAR).
0006  *
0007  * Redistribution and use in source and binary forms, with or without
0008  * modification, are permitted provided that the following conditions
0009  * are met:
0010  * 1. Redistributions of source code must retain the above copyright
0011  *    notice, this list of conditions and the following disclaimer.
0012  * 2. Redistributions in binary form must reproduce the above copyright
0013  *    notice, this list of conditions and the following disclaimer in the
0014  *    documentation and/or other materials provided with the distribution.
0015  *
0016  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
0017  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
0018  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
0019  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
0020  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
0021  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
0022  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
0023  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
0024  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
0025  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
0026  * POSSIBILITY OF SUCH DAMAGE.
0027  */
0028 
0029 #ifdef HAVE_CONFIG_H
0030 #include "config.h"
0031 #endif
0032 
0033 #include <rtems/btimer.h>
0034 
0035 #define CONFIGURE_INIT
0036 #include "system.h"
0037 
0038 const char rtems_test_name[] = "TIME TEST 19";
0039 
0040 rtems_asr Process_asr_for_pass_1(
0041   rtems_signal_set signals
0042 );
0043 
0044 rtems_asr Process_asr_for_pass_2(
0045   rtems_signal_set signals
0046 );
0047 
0048 rtems_task Task_1(
0049   rtems_task_argument argument
0050 );
0051 
0052 rtems_task Task_2(
0053   rtems_task_argument argument
0054 );
0055 
0056 rtems_task Task_3(
0057   rtems_task_argument argument
0058 );
0059 
0060 rtems_task Init(
0061   rtems_task_argument argument
0062 )
0063 {
0064   rtems_status_code status;
0065 
0066   Print_Warning();
0067 
0068   TEST_BEGIN();
0069 
0070   status = rtems_task_create(
0071     rtems_build_name( 'T', 'I', 'M', 'E' ),
0072     (RTEMS_MAXIMUM_PRIORITY / 2u) + 1u,
0073     RTEMS_MINIMUM_STACK_SIZE,
0074     RTEMS_DEFAULT_MODES,
0075     RTEMS_DEFAULT_ATTRIBUTES,
0076     &Task_id[ 1 ]
0077   );
0078   directive_failed( status, "rtems_task_create of TASK1" );
0079 
0080   status = rtems_task_start( Task_id[ 1 ], Task_1, 0 );
0081   directive_failed( status, "rtems_task_start of TASK1" );
0082 
0083   status = rtems_task_create(
0084     rtems_build_name( 'T', 'I', 'M', 'E' ),
0085     (RTEMS_MAXIMUM_PRIORITY / 2),
0086     RTEMS_MINIMUM_STACK_SIZE,
0087     RTEMS_DEFAULT_MODES,
0088     RTEMS_DEFAULT_ATTRIBUTES,
0089     &Task_id[ 2 ]
0090   );
0091   directive_failed( status, "rtems_task_create of TASK2" );
0092 
0093   status = rtems_task_start( Task_id[ 2 ], Task_2, 0 );
0094   directive_failed( status, "rtems_task_start of TASK2" );
0095 
0096   status = rtems_task_create(
0097     rtems_build_name( 'T', 'I', 'M', 'E' ),
0098     (RTEMS_MAXIMUM_PRIORITY / 2u) - 1u,
0099     RTEMS_MINIMUM_STACK_SIZE,
0100     RTEMS_DEFAULT_MODES,
0101     RTEMS_DEFAULT_ATTRIBUTES,
0102     &Task_id[ 3 ]
0103   );
0104   directive_failed( status, "rtems_task_create of TASK3" );
0105 
0106   status = rtems_task_start( Task_id[ 3 ], Task_3, 0 );
0107   directive_failed( status, "rtems_task_start of TASK3" );
0108 
0109   rtems_task_exit();
0110 }
0111 
0112 rtems_asr Process_asr_for_pass_1(
0113   rtems_signal_set signals
0114 )
0115 {
0116   end_time = benchmark_timer_read();
0117 
0118   put_time(
0119     "rtems_signal_send: signal to self",
0120     end_time,
0121     1,
0122     0,
0123     0
0124   );
0125 
0126   benchmark_timer_initialize();
0127 }
0128 
0129 rtems_asr Process_asr_for_pass_2(
0130   rtems_signal_set signals
0131 )
0132 {
0133   rtems_status_code status;
0134 
0135   status = rtems_task_resume( Task_id[ 3 ] );
0136   directive_failed( status, "rtems_task_resume" );
0137 
0138   benchmark_timer_initialize();
0139 }
0140 
0141 rtems_task Task_1(
0142   rtems_task_argument argument
0143 )
0144 {
0145   rtems_status_code status;
0146 
0147   benchmark_timer_initialize();
0148     (void) rtems_signal_catch( Process_asr_for_pass_1, RTEMS_DEFAULT_MODES );
0149   end_time = benchmark_timer_read();
0150 
0151   put_time(
0152     "rtems_signal_catch: only case",
0153     end_time,
0154     1,
0155     0,
0156     0
0157   );
0158 
0159   benchmark_timer_initialize();
0160     rtems_signal_send( Task_id[ 2 ], 1 );
0161   end_time = benchmark_timer_read();
0162 
0163   put_time(
0164     "rtems_signal_send: returns to caller",
0165     end_time,
0166     1,
0167     0,
0168     0
0169   );
0170 
0171   benchmark_timer_initialize();
0172     (void) rtems_signal_send( RTEMS_SELF, RTEMS_SIGNAL_1 );
0173 
0174   /* end time is done is RTEMS_ASR */
0175 
0176   end_time = benchmark_timer_read();
0177 
0178   put_time(
0179     "rtems_signal: exit ASR overhead returns to calling task",
0180     end_time,
0181     1,
0182     0,
0183     0
0184   );
0185 
0186   status = rtems_signal_catch( Process_asr_for_pass_2, RTEMS_NO_PREEMPT );
0187   directive_failed( status, "rtems_signal_catch" );
0188 
0189   benchmark_timer_initialize();
0190     (void) rtems_signal_send( RTEMS_SELF, RTEMS_SIGNAL_1 );
0191 }
0192 
0193 /* avoid warnings for no prototype */
0194 rtems_asr Process_asr_for_task_2(
0195   rtems_signal_set signals
0196 );
0197 
0198 rtems_asr Process_asr_for_task_2(
0199   rtems_signal_set signals
0200 )
0201 {
0202   ;
0203 }
0204 
0205 rtems_task Task_2(
0206   rtems_task_argument argument
0207 )
0208 {
0209   rtems_status_code status;
0210 
0211   status = rtems_signal_catch( Process_asr_for_task_2, RTEMS_DEFAULT_MODES );
0212   directive_failed( status, "rtems_signal_catch" );
0213 
0214   (void) rtems_task_suspend( RTEMS_SELF );
0215 }
0216 
0217 rtems_task Task_3(
0218   rtems_task_argument argument
0219 )
0220 {
0221   (void) rtems_task_suspend( RTEMS_SELF );
0222 
0223   end_time = benchmark_timer_read();
0224 
0225   put_time(
0226     "rtems_signal: exit ASR overhead returns to preempting task",
0227     end_time,
0228     1,
0229     0,
0230     0
0231   );
0232 
0233   TEST_END();
0234   rtems_test_exit( 0 );
0235 }