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/rhtaskswitch | |
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/rhtaskswitch')
-rw-r--r-- | testsuites/rhealstone/rhtaskswitch/Makefile.am | 23 | ||||
-rw-r--r-- | testsuites/rhealstone/rhtaskswitch/rhtaskswitch.adoc | 27 | ||||
-rw-r--r-- | testsuites/rhealstone/rhtaskswitch/taskswitch.c | 118 |
3 files changed, 168 insertions, 0 deletions
diff --git a/testsuites/rhealstone/rhtaskswitch/Makefile.am b/testsuites/rhealstone/rhtaskswitch/Makefile.am new file mode 100644 index 0000000000..26ca733320 --- /dev/null +++ b/testsuites/rhealstone/rhtaskswitch/Makefile.am @@ -0,0 +1,23 @@ +MANAGERS = all + +rtems_tests_PROGRAMS = rhtaskswitch +rhtaskswitch_SOURCES = taskswitch.c +rhtaskswitch_SOURCES += ../../tmtests/include/timesys.h + +dist_rtems_tests_DATA = rhtaskswitch.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 = $(rhtaskswitch_OBJECTS) $(rhtaskswitch_LDADD) +LINK_LIBS = $(rhtaskswitch_LDLIBS) + +rhtaskswitch$(EXEEXT): $(rhtaskswitch_OBJECTS) $(rhtaskswitch_DEPENDENCIES) + @rm -f rhtaskswitch$(EXEEXT) + $(make-exe) + +include $(top_srcdir)/../automake/local.am diff --git a/testsuites/rhealstone/rhtaskswitch/rhtaskswitch.adoc b/testsuites/rhealstone/rhtaskswitch/rhtaskswitch.adoc new file mode 100644 index 0000000000..9b2d10a40c --- /dev/null +++ b/testsuites/rhealstone/rhtaskswitch/rhtaskswitch.adoc @@ -0,0 +1,27 @@ +== Task Switch Benchmark + +This benchmark measures the average time it takes the system to switch between +two independent and active tasks of equal priority. Task switching is synchronous +and non-preemptive. + +=== Directives + + * rtems_task_wake_after + + +=== Methodology + +This benchmark utilizes rtems_task_wake_after( RTEMS_YIELD_PROCESSOR ) to +achieve a synchronous, non-preemptive task switch. rtems_task_wake_after +used in this context is essentially just a yield. + +As this is an average, we structure the benchmark code in a way that results +in some overhead being included that inflates the total elapsed time. This +overhead includes: + * the time it takes to iterate through the for loops (minimal + * overhead code in rtems_task_wake_after + +We instantiate two tasks, and time how long it takes for them to switch back +and forth between themselves a total of BENCHMARKS * 2 times. We then use +the put_time call to divide this total elapsed time by BENCHMARKS * 2, giving +an average, and subtract out the overhead time we found earlier. diff --git a/testsuites/rhealstone/rhtaskswitch/taskswitch.c b/testsuites/rhealstone/rhtaskswitch/taskswitch.c new file mode 100644 index 0000000000..cb9030901a --- /dev/null +++ b/testsuites/rhealstone/rhtaskswitch/taskswitch.c @@ -0,0 +1,118 @@ +/* + * Copyright (c) 2014 Daniel Ramirez. (javamonn@gmail.com) + * + * This file's license is 2-clause BSD as in this distribution's LICENSE file. + */ + +#include <rtems/timerdrv.h> +#include <timesys.h> + +#define BENCHMARKS 50000 + +rtems_task Task01( rtems_task_argument ignored ); +rtems_task Task02( rtems_task_argument ignored ); +rtems_task Init( rtems_task_argument ignored ); + +rtems_id Task_id[2]; +rtems_name Task_name[2]; +uint32_t loop_overhead; +uint32_t dir_overhead; +unsigned long count1, count2; +rtems_status_code status; + +rtems_task Task02( rtems_task_argument ignored ) +{ + uint32_t telapsed; + + /* All overhead accounted for now, we can begin benchmark */ + benchmark_timer_initialize(); + + for ( count1 = 0; count1 < BENCHMARKS - 1; count1++ ) { + rtems_task_wake_after( RTEMS_YIELD_PROCESSOR ); + } + + telapsed = benchmark_timer_read(); + put_time( + "Rhealstone: Task switch", + telapsed, + ( BENCHMARKS * 2 ) - 1, /* ( BENCHMARKS * 2 ) - 1 total benchmarks */ + loop_overhead, /* Overhead of loop */ + dir_overhead /* Overhead of rtems_task_wake_after directive */ + ); + + rtems_test_exit( 0 ); +} + +rtems_task Task01( rtems_task_argument ignored ) +{ + status = rtems_task_start( Task_id[1], Task02, 0 ); + directive_failed( status, "rtems_task_start of TA02" ); + + /* Yield processor so second task can startup and run */ + rtems_task_wake_after( RTEMS_YIELD_PROCESSOR ); + + for ( count2 = 0; count2 < BENCHMARKS; count2++ ) { + rtems_task_wake_after( RTEMS_YIELD_PROCESSOR ); + } + + /* Should never reach here */ + rtems_test_assert( false ); + +} + +rtems_task Init( rtems_task_argument ignored ) +{ + Print_Warning(); + + Task_name[0] = rtems_build_name( 'T','A','0','1' ); + status = rtems_task_create( + Task_name[0], + 30, + 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], + 30, + RTEMS_MINIMUM_STACK_SIZE, + RTEMS_DEFAULT_MODES, + RTEMS_DEFAULT_ATTRIBUTES, + &Task_id[1] + ); + directive_failed( status, "rtems_task_create of TA02" ); + + /* find overhead of routine (no task switches) */ + benchmark_timer_initialize(); + for ( count1 = 0; count1 < BENCHMARKS - 1; count1++ ) { + /* rtems_task_wake_after( RTEMS_YIELD_PROCESSOR ) */ + } + for ( count2 = 0; count2 < BENCHMARKS; count2++ ) { + /* rtems_task_wake_after( RTEMS_YIELD_PROCESSOR ) */ + } + loop_overhead = benchmark_timer_read(); + + /* find overhead of rtems_task_wake_after call (no task switches) */ + benchmark_timer_initialize(); + rtems_task_wake_after( RTEMS_YIELD_PROCESSOR ); + dir_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 INIT" ); +} + +/* configuration information */ +#define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER +#define CONFIGURE_APPLICATION_NEEDS_TIMER_DRIVER +#define CONFIGURE_TICKS_PER_TIMESLICE 0 +#define CONFIGURE_RTEMS_INIT_TASKS_TABLE +#define CONFIGURE_MAXIMUM_TASKS 3 +#define CONFIGURE_INIT +#include <rtems/confdefs.h> |