diff options
author | Joel Sherrill <joel.sherrill@oarcorp.com> | 2014-01-05 11:17:08 -0600 |
---|---|---|
committer | Joel Sherrill <joel.sherrill@oarcorp.com> | 2014-01-05 11:17:08 -0600 |
commit | b6c1578bb91fb54c826141e0f8bbd9cb2009f3cf (patch) | |
tree | 6d4c9af3892de78428add886865bae7db15efbc1 /testsuites/rhealstone/rhmlatency | |
parent | rhealstone/*.c: Add Print_Warning() call to indicate debug enabled (diff) | |
download | rtems-b6c1578bb91fb54c826141e0f8bbd9cb2009f3cf.tar.bz2 |
rhealstone: Add rh prefix to all test names
This makes them easier to spot as a group in wildcard searches.
Diffstat (limited to 'testsuites/rhealstone/rhmlatency')
-rw-r--r-- | testsuites/rhealstone/rhmlatency/Makefile.am | 23 | ||||
-rw-r--r-- | testsuites/rhealstone/rhmlatency/mlatency.c | 152 | ||||
-rw-r--r-- | testsuites/rhealstone/rhmlatency/rhmlatency.adoc | 22 |
3 files changed, 197 insertions, 0 deletions
diff --git a/testsuites/rhealstone/rhmlatency/Makefile.am b/testsuites/rhealstone/rhmlatency/Makefile.am new file mode 100644 index 0000000000..c8d90095f8 --- /dev/null +++ b/testsuites/rhealstone/rhmlatency/Makefile.am @@ -0,0 +1,23 @@ +MANAGERS = all + +rtems_tests_PROGRAMS = rhmlatency +rhmlatency_SOURCES = mlatency.c +rhmlatency_SOURCES += ../../tmtests/include/timesys.h + +dist_rtems_tests_DATA = rhmlatency.adoc + +include $(RTEMS_ROOT)/make/custom/@RTEMS_BSP@.cfg +include $(top_srcdir)/../automake/compile.am +include $(top_srcdir)/../automake/leaf.am + +AM_CPPFLAGS += -I$(top_srcdir)/../tmtests/include +AM_CPPFLAGS += -I$(top_srcdir)/../support/include + +LINK_OBJS = $(rhmlatency_OBJECTS) $(rhmlatency_ldaDD) +LINK_LIBS = $(rhmlatency_LDLIBS) + +rhmlatency$(EXEEXT): $(rhmlatency_OBJECTS) $(rhmlatency_DEPENDENCIES) + @rm -f rhmlatency$(EXEEXT) + $(make-exe) + +include $(top_srcdir)/../automake/local.am diff --git a/testsuites/rhealstone/rhmlatency/mlatency.c b/testsuites/rhealstone/rhmlatency/mlatency.c new file mode 100644 index 0000000000..065d0f40af --- /dev/null +++ b/testsuites/rhealstone/rhmlatency/mlatency.c @@ -0,0 +1,152 @@ +/* + * Copyright (c) 2014 Daniel Ramirez. (javamonn@gmail.com) + * + * This file's license is 2-clause BSD as in this distribution's LICENSE file. + */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include <timesys.h> +#include <rtems/timerdrv.h> + +#define MESSAGE_SIZE (sizeof(long) * 4) +#define BENCHMARKS 50000 + +rtems_task Init( rtems_task_argument ignored ); +rtems_task Task01( rtems_task_argument ignored ); +rtems_task Task02( rtems_task_argument ignored ); + +uint32_t telapsed; +uint32_t tloop_overhead; +uint32_t treceive_overhead; +uint32_t count; +rtems_id Task_id[2]; +rtems_name Task_name[2]; +rtems_id Queue_id; +long Buffer[4]; + +void Init( + rtems_task_argument argument +) +{ + rtems_status_code status; + + Print_Warning(); + + status = rtems_message_queue_create( + rtems_build_name( 'M', 'Q', '1', ' ' ), + 1, + MESSAGE_SIZE, + RTEMS_DEFAULT_ATTRIBUTES, + &Queue_id + ); + directive_failed( status, "rtems_message_queue_create" ); + + Task_name[0] = rtems_build_name( 'T','A','0','1' ); + status = rtems_task_create( + Task_name[0], + 30, /* TA01 is low priority task */ + RTEMS_MINIMUM_STACK_SIZE, + RTEMS_DEFAULT_MODES, + RTEMS_DEFAULT_ATTRIBUTES, + &Task_id[0] + ); + directive_failed( status, "rtems_task_create of TA01"); + + Task_name[1] = rtems_build_name( 'T','A','0','2' ); + status = rtems_task_create( + Task_name[1], + 28, /* High priority task */ + RTEMS_MINIMUM_STACK_SIZE, + RTEMS_DEFAULT_MODES, + RTEMS_DEFAULT_ATTRIBUTES, + &Task_id[1] + ); + directive_failed( status, "rtems_task_create of TA01" ); + + benchmark_timer_initialize(); + for ( count = 0; count < BENCHMARKS - 1; count++ ) { + /* message send/recieve */ + } + tloop_overhead = benchmark_timer_read(); + + status = rtems_task_start( Task_id[0], Task01, 0 ); + directive_failed( status, "rtems_task_start of TA01" ); + + status = rtems_task_delete( RTEMS_SELF ); + directive_failed( status, "rtems_task_delete of RTEMS_SELF" ); +} + +rtems_task Task01( rtems_task_argument ignored ) +{ + rtems_status_code status; + + /* Put a message in the queue so recieve overhead can be found. */ + (void) rtems_message_queue_send( Queue_id, Buffer, MESSAGE_SIZE ); + + /* Start up second task, get preempted */ + status = rtems_task_start( Task_id[1], Task02, 0 ); + directive_failed( status, "rtems_task_start" ); + + for ( ; count < BENCHMARKS; count++ ) { + (void) rtems_message_queue_send( Queue_id, Buffer, MESSAGE_SIZE ); + } + + /* Should never reach here */ + rtems_test_assert( false ); + +} + +rtems_task Task02( rtems_task_argument ignored ) +{ + size_t size; + + /* find recieve overhead - no preempt or task switch */ + benchmark_timer_initialize(); + (void) rtems_message_queue_receive( + Queue_id, + (long (*)[4]) Buffer, + &size, + RTEMS_DEFAULT_OPTIONS, + RTEMS_NO_TIMEOUT + ); + treceive_overhead = benchmark_timer_read(); + + /* Benchmark code */ + benchmark_timer_initialize(); + for ( count = 0; count < BENCHMARKS - 1; count++ ) { + (void) rtems_message_queue_receive( + Queue_id, + (long (*)[4]) Buffer, + &size, + RTEMS_DEFAULT_OPTIONS, + RTEMS_NO_TIMEOUT + ); + } + telapsed = benchmark_timer_read(); + + put_time( + "Rhealstone: Intertask Message Latency", + telapsed, /* Total time of all benchmarks */ + BENCHMARKS - 1, /* Total benchmarks */ + tloop_overhead, /* Overhead of loops */ + treceive_overhead /* Overhead of recieve call and task switch */ + ); + + rtems_test_exit( 0 ); +} + +/* configuration information */ + +#define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER +#define CONFIGURE_APPLICATION_NEEDS_TIMER_DRIVER + +#define CONFIGURE_MAXIMUM_TASKS 3 +#define CONFIGURE_MAXIMUM_MESSAGE_QUEUES 1 +#define CONFIGURE_TICKS_PER_TIMESLICE 0 +#define CONFIGURE_RTEMS_INIT_TASKS_TABLE + +#define CONFIGURE_INIT +#include <rtems/confdefs.h> diff --git a/testsuites/rhealstone/rhmlatency/rhmlatency.adoc b/testsuites/rhealstone/rhmlatency/rhmlatency.adoc new file mode 100644 index 0000000000..fd445ca3ff --- /dev/null +++ b/testsuites/rhealstone/rhmlatency/rhmlatency.adoc @@ -0,0 +1,22 @@ += Message Latency Benchmark + +This benchmark measures the intertask message latency. This is the delay within +RTEMS between a running task using the rtems_message_queue to send a message to +a waiting task and that task waking up and receiving the message. + +== Directives + + * rtems_message_queue_send + * rtems_message_queue_receive + + +== Methodology + +This benchmark consists of a high priority task and a low priority task. The +benchmark starts in the high priority task, which blocks on a call to rtems_ +message_queue recieve. By accounting for the overhead of the task switch from +the high priority task to the low priority task, and the actual time to recieve +the message, the intertask message latency is found. + +The average is found and the overhead (the time of the first run) is subtracted +out in the call to put_time. |