[19e9bf8] | 1 | /* |
---|
| 2 | * Copyright (c) 2014 Daniel Ramirez. (javamonn@gmail.com) |
---|
| 3 | * |
---|
| 4 | * This file's license is 2-clause BSD as in this distribution's LICENSE file. |
---|
| 5 | */ |
---|
| 6 | |
---|
| 7 | #ifdef HAVE_CONFIG_H |
---|
| 8 | #include "config.h" |
---|
| 9 | #endif |
---|
| 10 | |
---|
| 11 | #include <timesys.h> |
---|
| 12 | #include <rtems/timerdrv.h> |
---|
| 13 | |
---|
| 14 | #define MESSAGE_SIZE (sizeof(long) * 4) |
---|
| 15 | #define BENCHMARKS 50000 |
---|
| 16 | |
---|
| 17 | rtems_task Init( rtems_task_argument ignored ); |
---|
| 18 | rtems_task Task01( rtems_task_argument ignored ); |
---|
| 19 | rtems_task Task02( rtems_task_argument ignored ); |
---|
| 20 | |
---|
| 21 | uint32_t telapsed; |
---|
| 22 | uint32_t tloop_overhead; |
---|
| 23 | uint32_t treceive_overhead; |
---|
| 24 | uint32_t count; |
---|
| 25 | rtems_id Task_id[2]; |
---|
| 26 | rtems_name Task_name[2]; |
---|
| 27 | rtems_id Queue_id; |
---|
| 28 | long Buffer[4]; |
---|
| 29 | |
---|
| 30 | void Init( |
---|
| 31 | rtems_task_argument argument |
---|
| 32 | ) |
---|
| 33 | { |
---|
| 34 | rtems_status_code status; |
---|
| 35 | |
---|
[e8c7dbe7] | 36 | Print_Warning(); |
---|
| 37 | |
---|
[893aac16] | 38 | puts( "*** START OF RHMLATENCY ***" ); |
---|
| 39 | |
---|
[19e9bf8] | 40 | status = rtems_message_queue_create( |
---|
| 41 | rtems_build_name( 'M', 'Q', '1', ' ' ), |
---|
| 42 | 1, |
---|
| 43 | MESSAGE_SIZE, |
---|
| 44 | RTEMS_DEFAULT_ATTRIBUTES, |
---|
| 45 | &Queue_id |
---|
| 46 | ); |
---|
| 47 | directive_failed( status, "rtems_message_queue_create" ); |
---|
| 48 | |
---|
| 49 | Task_name[0] = rtems_build_name( 'T','A','0','1' ); |
---|
| 50 | status = rtems_task_create( |
---|
| 51 | Task_name[0], |
---|
| 52 | 30, /* TA01 is low priority task */ |
---|
| 53 | RTEMS_MINIMUM_STACK_SIZE, |
---|
| 54 | RTEMS_DEFAULT_MODES, |
---|
| 55 | RTEMS_DEFAULT_ATTRIBUTES, |
---|
| 56 | &Task_id[0] |
---|
| 57 | ); |
---|
| 58 | directive_failed( status, "rtems_task_create of TA01"); |
---|
| 59 | |
---|
| 60 | Task_name[1] = rtems_build_name( 'T','A','0','2' ); |
---|
| 61 | status = rtems_task_create( |
---|
| 62 | Task_name[1], |
---|
| 63 | 28, /* High priority task */ |
---|
| 64 | RTEMS_MINIMUM_STACK_SIZE, |
---|
| 65 | RTEMS_DEFAULT_MODES, |
---|
| 66 | RTEMS_DEFAULT_ATTRIBUTES, |
---|
| 67 | &Task_id[1] |
---|
| 68 | ); |
---|
| 69 | directive_failed( status, "rtems_task_create of TA01" ); |
---|
| 70 | |
---|
| 71 | benchmark_timer_initialize(); |
---|
| 72 | for ( count = 0; count < BENCHMARKS - 1; count++ ) { |
---|
| 73 | /* message send/recieve */ |
---|
| 74 | } |
---|
| 75 | tloop_overhead = benchmark_timer_read(); |
---|
| 76 | |
---|
| 77 | status = rtems_task_start( Task_id[0], Task01, 0 ); |
---|
| 78 | directive_failed( status, "rtems_task_start of TA01" ); |
---|
| 79 | |
---|
| 80 | status = rtems_task_delete( RTEMS_SELF ); |
---|
| 81 | directive_failed( status, "rtems_task_delete of RTEMS_SELF" ); |
---|
| 82 | } |
---|
| 83 | |
---|
| 84 | rtems_task Task01( rtems_task_argument ignored ) |
---|
| 85 | { |
---|
| 86 | rtems_status_code status; |
---|
| 87 | |
---|
| 88 | /* Put a message in the queue so recieve overhead can be found. */ |
---|
| 89 | (void) rtems_message_queue_send( Queue_id, Buffer, MESSAGE_SIZE ); |
---|
| 90 | |
---|
| 91 | /* Start up second task, get preempted */ |
---|
| 92 | status = rtems_task_start( Task_id[1], Task02, 0 ); |
---|
| 93 | directive_failed( status, "rtems_task_start" ); |
---|
| 94 | |
---|
| 95 | for ( ; count < BENCHMARKS; count++ ) { |
---|
| 96 | (void) rtems_message_queue_send( Queue_id, Buffer, MESSAGE_SIZE ); |
---|
| 97 | } |
---|
| 98 | |
---|
| 99 | /* Should never reach here */ |
---|
| 100 | rtems_test_assert( false ); |
---|
| 101 | |
---|
| 102 | } |
---|
| 103 | |
---|
| 104 | rtems_task Task02( rtems_task_argument ignored ) |
---|
| 105 | { |
---|
| 106 | size_t size; |
---|
| 107 | |
---|
| 108 | /* find recieve overhead - no preempt or task switch */ |
---|
| 109 | benchmark_timer_initialize(); |
---|
| 110 | (void) rtems_message_queue_receive( |
---|
| 111 | Queue_id, |
---|
| 112 | (long (*)[4]) Buffer, |
---|
| 113 | &size, |
---|
| 114 | RTEMS_DEFAULT_OPTIONS, |
---|
| 115 | RTEMS_NO_TIMEOUT |
---|
| 116 | ); |
---|
| 117 | treceive_overhead = benchmark_timer_read(); |
---|
| 118 | |
---|
| 119 | /* Benchmark code */ |
---|
| 120 | benchmark_timer_initialize(); |
---|
| 121 | for ( count = 0; count < BENCHMARKS - 1; count++ ) { |
---|
| 122 | (void) rtems_message_queue_receive( |
---|
| 123 | Queue_id, |
---|
| 124 | (long (*)[4]) Buffer, |
---|
| 125 | &size, |
---|
| 126 | RTEMS_DEFAULT_OPTIONS, |
---|
| 127 | RTEMS_NO_TIMEOUT |
---|
| 128 | ); |
---|
| 129 | } |
---|
| 130 | telapsed = benchmark_timer_read(); |
---|
| 131 | |
---|
| 132 | put_time( |
---|
[b6c1578] | 133 | "Rhealstone: Intertask Message Latency", |
---|
| 134 | telapsed, /* Total time of all benchmarks */ |
---|
| 135 | BENCHMARKS - 1, /* Total benchmarks */ |
---|
| 136 | tloop_overhead, /* Overhead of loops */ |
---|
| 137 | treceive_overhead /* Overhead of recieve call and task switch */ |
---|
[19e9bf8] | 138 | ); |
---|
| 139 | |
---|
[893aac16] | 140 | puts( "*** END OF RHMLATENCY ***" ); |
---|
[19e9bf8] | 141 | rtems_test_exit( 0 ); |
---|
| 142 | } |
---|
| 143 | |
---|
| 144 | /* configuration information */ |
---|
| 145 | |
---|
| 146 | #define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER |
---|
| 147 | #define CONFIGURE_APPLICATION_NEEDS_TIMER_DRIVER |
---|
| 148 | |
---|
| 149 | #define CONFIGURE_MAXIMUM_TASKS 3 |
---|
| 150 | #define CONFIGURE_MAXIMUM_MESSAGE_QUEUES 1 |
---|
| 151 | #define CONFIGURE_TICKS_PER_TIMESLICE 0 |
---|
| 152 | #define CONFIGURE_RTEMS_INIT_TASKS_TABLE |
---|
| 153 | |
---|
[b6c1578] | 154 | #define CONFIGURE_INIT |
---|
[19e9bf8] | 155 | #include <rtems/confdefs.h> |
---|