From 7cd2484c4cf9fc759b7205ed6d8adcc6d2c28ff6 Mon Sep 17 00:00:00 2001 From: Alexander Krutwig Date: Tue, 12 May 2015 14:32:47 +0200 Subject: timecounter: Use in RTEMS Replace timestamp implementation with FreeBSD bintime and timecounters. New test sptests/sptimecounter02. Update #2271. --- testsuites/sptests/Makefile.am | 1 + testsuites/sptests/configure.ac | 1 + testsuites/sptests/spclock_err01/init.c | 8 - testsuites/sptests/spsize/size.c | 3 - testsuites/sptests/sptimecounter02/Makefile.am | 20 ++ testsuites/sptests/sptimecounter02/init.c | 268 +++++++++++++++++++++ .../sptests/sptimecounter02/sptimecounter02.doc | 12 + .../sptests/sptimecounter02/sptimecounter02.scn | 46 ++++ 8 files changed, 348 insertions(+), 11 deletions(-) create mode 100644 testsuites/sptests/sptimecounter02/Makefile.am create mode 100644 testsuites/sptests/sptimecounter02/init.c create mode 100644 testsuites/sptests/sptimecounter02/sptimecounter02.doc create mode 100644 testsuites/sptests/sptimecounter02/sptimecounter02.scn (limited to 'testsuites/sptests') diff --git a/testsuites/sptests/Makefile.am b/testsuites/sptests/Makefile.am index 8844436876..c3fc443da0 100644 --- a/testsuites/sptests/Makefile.am +++ b/testsuites/sptests/Makefile.am @@ -39,6 +39,7 @@ _SUBDIRS += sp29 endif _SUBDIRS += spintrcritical23 _SUBDIRS += sptimecounter01 +_SUBDIRS += sptimecounter02 _SUBDIRS += spatomic01 _SUBDIRS += spintrcritical22 _SUBDIRS += spsem03 diff --git a/testsuites/sptests/configure.ac b/testsuites/sptests/configure.ac index d463532124..b8287a4ea7 100644 --- a/testsuites/sptests/configure.ac +++ b/testsuites/sptests/configure.ac @@ -42,6 +42,7 @@ AM_CONDITIONAL(HAS_SMP,test "$rtems_cv_RTEMS_SMP" = "yes") AC_CONFIG_FILES([Makefile spintrcritical23/Makefile sptimecounter01/Makefile +sptimecounter02/Makefile spatomic01/Makefile spglobalcon01/Makefile spintrcritical22/Makefile diff --git a/testsuites/sptests/spclock_err01/init.c b/testsuites/sptests/spclock_err01/init.c index ab5c00ab1e..087c8d4a05 100644 --- a/testsuites/sptests/spclock_err01/init.c +++ b/testsuites/sptests/spclock_err01/init.c @@ -115,14 +115,6 @@ rtems_task Init( puts( "TA1 - rtems_clock_get_tod_timeval - RTEMS_NOT_DEFINED" ); } - puts( "TA1 - rtems_clock_set_nanoseconds_extension - RTEMS_INVALID_ADDRESS" ); - status = rtems_clock_set_nanoseconds_extension( NULL ); - fatal_directive_status( - status, - RTEMS_INVALID_ADDRESS, - "rtems_clock_set_nanoseconds_extension NULL param" - ); - /* NULL parameter */ status = rtems_clock_set( NULL ); fatal_directive_status( diff --git a/testsuites/sptests/spsize/size.c b/testsuites/sptests/spsize/size.c index 58bcc89312..657fa425de 100644 --- a/testsuites/sptests/spsize/size.c +++ b/testsuites/sptests/spsize/size.c @@ -390,9 +390,6 @@ uninitialized = /*timerimpl.h*/ (sizeof _Timer_Information) + -/*tod.h*/ (sizeof _TOD.now) + - (sizeof _TOD.uptime) + - /*tqdata.h*/ 0 + /*types.h*/ 0 + diff --git a/testsuites/sptests/sptimecounter02/Makefile.am b/testsuites/sptests/sptimecounter02/Makefile.am new file mode 100644 index 0000000000..badb647a14 --- /dev/null +++ b/testsuites/sptests/sptimecounter02/Makefile.am @@ -0,0 +1,20 @@ +rtems_tests_PROGRAMS = sptimecounter02 +sptimecounter02_SOURCES = init.c +sptimecounter02_SOURCES += ../../support/src/spin.c + +dist_rtems_tests_DATA = sptimecounter02.scn sptimecounter02.doc + +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)/../support/include + +LINK_OBJS = $(sptimecounter02_OBJECTS) +LINK_LIBS = $(sptimecounter02_LDLIBS) + +sptimecounter02$(EXEEXT): $(sptimecounter02_OBJECTS) $(sptimecounter02_DEPENDENCIES) + @rm -f sptimecounter02$(EXEEXT) + $(make-exe) + +include $(top_srcdir)/../automake/local.am diff --git a/testsuites/sptests/sptimecounter02/init.c b/testsuites/sptests/sptimecounter02/init.c new file mode 100644 index 0000000000..c7d72a8eb7 --- /dev/null +++ b/testsuites/sptests/sptimecounter02/init.c @@ -0,0 +1,268 @@ +/* + * Copyright (c) 2015 embedded brains GmbH. All rights reserved. + * + * embedded brains GmbH + * Dornierstr. 4 + * 82178 Puchheim + * Germany + * + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ + +#ifdef HAVE_CONFIG_H + #include "config.h" +#endif + +#define _KERNEL + +#include +#include + +#include +#include +#include +#include + +#include +#include +#include + +#include +#include +#include + +#include + +#include "tmacros.h" + +const char rtems_test_name[] = "SPTIMECOUNTER 2"; + +#define CPU_COUNT 32 + +#define DURATION_IN_SECONDS 1 + +typedef struct { + rtems_test_parallel_context base; + struct timecounter tc_null; + uint32_t binuptime_per_job[CPU_COUNT]; + sbintime_t duration_per_job[CPU_COUNT]; + uint32_t rtemsuptime_per_job[CPU_COUNT]; +} timecounter_context; + +static timecounter_context test_instance; + +static rtems_interval test_duration(void) +{ + return DURATION_IN_SECONDS * rtems_clock_get_ticks_per_second(); +} + +static uint32_t test_get_timecount_null(struct timecounter *tc) +{ + return 0; +} + +static void install_tc_null(timecounter_context *ctx) +{ + struct timecounter *tc_cpu = &ctx->tc_null; + + tc_cpu->tc_get_timecount = test_get_timecount_null; + tc_cpu->tc_counter_mask = 0xffffffff; + tc_cpu->tc_frequency = rtems_counter_nanoseconds_to_ticks(1000000000); + tc_cpu->tc_quality = 2000; + rtems_timecounter_install(tc_cpu); +} + +static rtems_interval test_bintime_init( + rtems_test_parallel_context *base, + void *arg, + size_t active_workers +) +{ + rtems_test_spin_until_next_tick(); + + return test_duration(); +} + +static void test_bintime_body( + rtems_test_parallel_context *base, + void *arg, + size_t active_workers, + size_t worker_index +) +{ + timecounter_context *ctx = (timecounter_context *) base; + uint32_t counter = 1; + struct bintime start; + struct bintime end; + + rtems_bsd_binuptime(&start); + + do { + ++counter; + rtems_bsd_binuptime(&end); + } while (!rtems_test_parallel_stop_job(&ctx->base)); + + ctx->binuptime_per_job[worker_index] = counter; + ctx->duration_per_job[worker_index] = bttosbt(end) - bttosbt(start); +} + +static void test_bintime_fini( + rtems_test_parallel_context *base, + void *arg, + size_t active_workers +) +{ + timecounter_context *ctx = (timecounter_context *) base; + size_t i; + + printf(" \n", active_workers); + + for (i = 0; i < active_workers; ++i) { + sbintime_t error; + + printf( + " %" PRIu32 "\n" + " %" PRId64 "\n", + i + 1, + ctx->binuptime_per_job[i], + i + 1, + ctx->duration_per_job[i] + ); + + error = DURATION_IN_SECONDS * SBT_1S - ctx->duration_per_job[i]; + rtems_test_assert(error * error < SBT_1MS * SBT_1MS); + } + + printf(" \n"); +} + +static rtems_interval test_bintime_null_init( + rtems_test_parallel_context *base, + void *arg, + size_t active_workers +) +{ + timecounter_context *ctx = &test_instance; + + install_tc_null(ctx); + + return test_duration(); +} + +static void test_bintime_null_body( + rtems_test_parallel_context *base, + void *arg, + size_t active_workers, + size_t worker_index +) +{ + timecounter_context *ctx = (timecounter_context *) base; + struct bintime bt; + uint32_t counter = 0; + + while (!rtems_test_parallel_stop_job(&ctx->base)) { + ++counter; + rtems_bsd_binuptime(&bt); + } + + ctx->binuptime_per_job[worker_index] = counter; +} + +static void test_bintime_null_fini( + rtems_test_parallel_context *base, + void *arg, + size_t active_workers +) +{ + timecounter_context *ctx = (timecounter_context *) base; + size_t i; + + printf(" \n", active_workers); + + for (i = 0; i < active_workers; ++i) { + printf( + " %" PRIu32 "\n", + i + 1, + ctx->binuptime_per_job[i] + ); + } + + printf(" \n"); +} + +static const rtems_test_parallel_job timecounter_jobs[] = { + { + .init = test_bintime_init, + .body = test_bintime_body, + .fini = test_bintime_fini, + .cascade = true + },{ + .init = test_bintime_null_init, + .body = test_bintime_null_body, + .fini = test_bintime_null_fini, + .cascade = true + } +}; + +static void Init(rtems_task_argument arg) +{ + timecounter_context *ctx = &test_instance; + struct bintime bt; + struct timespec ts; + struct timeval tv; + + TEST_BEGIN(); + + printf("\n"); + + rtems_test_parallel( + &ctx->base, + NULL, + &timecounter_jobs[0], + RTEMS_ARRAY_SIZE(timecounter_jobs) + ); + + /* Check for all functions available in the bsd.h user space */ + + rtems_bsd_bintime(&bt); + rtems_bsd_microtime(&tv); + rtems_bsd_nanotime(&ts); + rtems_bsd_binuptime(&bt); + rtems_bsd_microuptime(&tv); + rtems_bsd_nanouptime(&ts); + rtems_bsd_getbintime(&bt); + rtems_bsd_getmicrotime(&tv); + rtems_bsd_getnanotime(&ts); + rtems_bsd_getbinuptime(&bt); + rtems_bsd_getmicrouptime(&tv); + rtems_bsd_getnanouptime(&ts); + + printf("\n"); + + TEST_END(); + rtems_test_exit(0); +} + +#define CONFIGURE_MICROSECONDS_PER_TICK 1000 + +#define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER +#define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER + +#define CONFIGURE_MAXIMUM_TASKS (2 + CPU_COUNT - 1) +#define CONFIGURE_MAXIMUM_TIMERS 2 +#define CONFIGURE_MAXIMUM_PERIODS 1 + +#define CONFIGURE_SMP_APPLICATION + +#define CONFIGURE_SMP_MAXIMUM_PROCESSORS CPU_COUNT + +#define CONFIGURE_RTEMS_INIT_TASKS_TABLE + +#define CONFIGURE_INITIAL_EXTENSIONS RTEMS_TEST_INITIAL_EXTENSION + +#define CONFIGURE_INIT + +#include diff --git a/testsuites/sptests/sptimecounter02/sptimecounter02.doc b/testsuites/sptests/sptimecounter02/sptimecounter02.doc new file mode 100644 index 0000000000..9988ad067c --- /dev/null +++ b/testsuites/sptests/sptimecounter02/sptimecounter02.doc @@ -0,0 +1,12 @@ +This file describes the directives and concepts tested by this test set. + +test set name: sptimecounter02 + +directives: + + rtems_timecounter_install, rtems_bsd_binuptime. + +concepts: + + measurement of performance tests: how often per timeframe can FreeBSD time + routines be called in comparison to original rtems timing routines. diff --git a/testsuites/sptests/sptimecounter02/sptimecounter02.scn b/testsuites/sptests/sptimecounter02/sptimecounter02.scn new file mode 100644 index 0000000000..004c50e416 --- /dev/null +++ b/testsuites/sptests/sptimecounter02/sptimecounter02.scn @@ -0,0 +1,46 @@ +*** BEGIN OF TEST SPTIMECOUNTER_2 *** + + + 591457 + 4294787862 + + 587737 + 4294603178 + 587754 + 4294596307 + + 583602 + 4293605982 + 583643 + 4293602260 + 583659 + 4293604551 + + 583086 + 4291246232 + 583124 + 4291243178 + 583139 + 4291242796 + 565417 + 4291304930 + + 615571 + + + 615857 + 615856 + + + 615316 + 615328 + 615337 + + + 615495 + 615502 + 615509 + 597117 + + +*** END OF TEST SPTIMECOUNTER_2 *** -- cgit v1.2.3