From db08c3897f86f99d5a4259506d4463b0ec440762 Mon Sep 17 00:00:00 2001 From: Chirayu Desai Date: Sun, 24 Nov 2013 12:34:13 +0530 Subject: psxtmtests: Add psxtmthread05 for pthread_setschedparam New test psxtmthread 05 uses two tasks and times lowering the priority of one task plus the preemption and context switch to the other task. --- testsuites/psxtmtests/Makefile.am | 1 + testsuites/psxtmtests/configure.ac | 1 + testsuites/psxtmtests/psxtmthread05/Makefile.am | 27 ++++++ testsuites/psxtmtests/psxtmthread05/init.c | 98 ++++++++++++++++++++++ .../psxtmtests/psxtmthread05/psxtmthread05.doc | 26 ++++++ 5 files changed, 153 insertions(+) create mode 100644 testsuites/psxtmtests/psxtmthread05/Makefile.am create mode 100644 testsuites/psxtmtests/psxtmthread05/init.c create mode 100644 testsuites/psxtmtests/psxtmthread05/psxtmthread05.doc diff --git a/testsuites/psxtmtests/Makefile.am b/testsuites/psxtmtests/Makefile.am index be21fa286b..812c3adf26 100644 --- a/testsuites/psxtmtests/Makefile.am +++ b/testsuites/psxtmtests/Makefile.am @@ -42,6 +42,7 @@ SUBDIRS += psxtmsleep02 SUBDIRS += psxtmthread01 SUBDIRS += psxtmthread02 SUBDIRS += psxtmthread03 +SUBDIRS += psxtmthread05 endif DIST_SUBDIRS = $(SUBDIRS) diff --git a/testsuites/psxtmtests/configure.ac b/testsuites/psxtmtests/configure.ac index 9eedb89fa1..0e70274c74 100644 --- a/testsuites/psxtmtests/configure.ac +++ b/testsuites/psxtmtests/configure.ac @@ -116,5 +116,6 @@ psxtmsleep02/Makefile psxtmthread01/Makefile psxtmthread02/Makefile psxtmthread03/Makefile +psxtmthread05/Makefile ]) AC_OUTPUT diff --git a/testsuites/psxtmtests/psxtmthread05/Makefile.am b/testsuites/psxtmtests/psxtmthread05/Makefile.am new file mode 100644 index 0000000000..8c3cf66364 --- /dev/null +++ b/testsuites/psxtmtests/psxtmthread05/Makefile.am @@ -0,0 +1,27 @@ +MANAGERS = all + +rtems_tests_PROGRAMS = psxtmthread05 +psxtmthread05_SOURCES = init.c +psxtmthread05_SOURCES += ../../tmtests/include/timesys.h +psxtmthread05_SOURCES += ../../support/src/tmtests_empty_function.c +psxtmthread05_SOURCES += ../../support/src/tmtests_support.c + +dist_rtems_tests_DATA = psxtmthread05.doc + +include $(RTEMS_ROOT)/make/custom/@RTEMS_BSP@.cfg +include $(top_srcdir)/../automake/compile.am +include $(top_srcdir)/../automake/leaf.am + +OPERATION_COUNT = @OPERATION_COUNT@ +AM_CPPFLAGS += -I$(top_srcdir)/../tmtests/include +AM_CPPFLAGS += -DOPERATION_COUNT=$(OPERATION_COUNT) +AM_CPPFLAGS += -I$(top_srcdir)/../support/include + +LINK_OBJS = $(psxtmthread05_OBJECTS) $(psxtmthread05_LDADD) +LINK_LIBS = $(psxtmthread05_LDLIBS) + +psxtmthread05$(EXEEXT): $(psxtmthread05_OBJECTS) $(psxtmthread05_DEPENDENCIES) + @rm -f psxtmthread05$(EXEEXT) + $(make-exe) + +include $(top_srcdir)/../automake/local.am diff --git a/testsuites/psxtmtests/psxtmthread05/init.c b/testsuites/psxtmtests/psxtmthread05/init.c new file mode 100644 index 0000000000..78f0465c70 --- /dev/null +++ b/testsuites/psxtmtests/psxtmthread05/init.c @@ -0,0 +1,98 @@ +/* + * COPYRIGHT (c) 1989-2012. + * On-Line Applications Research Corporation (OAR). + * COPYRIGHT (c) 2013. + * Chirayu Desai (chirayudesai1@gmail.com). + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.com/license/LICENSE. + */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include +#include +#include +#include +#include "test_support.h" + +/* forward declarations to avoid warnings */ +void *POSIX_Init(void *argument); +void benchmark_pthread_create(void); +void benchmark_pthread_setschedparam(void); +void *test_thread(void *argument); + +void benchmark_pthread_setschedparam(void) +{ + int status; + int policy; + struct sched_param param; + pthread_t thread_ID; + + status = pthread_create(&thread_ID, NULL, test_thread, NULL); + rtems_test_assert( status == 0 ); + + /* make test_thread equal to POSIX_Init() */ + pthread_getschedparam(pthread_self(), &policy, ¶m); + pthread_setschedparam(thread_ID, policy, ¶m); + /* At this point, we've switched to test_thread */ + + /* Back from test_thread, switch to test_thread again */ + param.sched_priority = sched_get_priority_max(policy) - 1; + + benchmark_timer_initialize(); + pthread_setschedparam(thread_ID, policy, ¶m); +} + +void *test_thread( + void *argument +) +{ + long end_time; + + /* switch to POSIX_Init */ + sched_yield(); + + end_time = benchmark_timer_read(); + + put_time( + "pthread_setschedparam - lower own priority, preempt", + end_time, + 1, /* Only executed once */ + 0, + 0 + ); + + puts( "*** END OF POSIX TIME TEST PSXTMTHREAD05 ***" ); + rtems_test_exit(0); + //Empty thread used in pthread_create(). + return NULL; +} + +void *POSIX_Init( + void *argument +) +{ + + puts( "\n\n*** POSIX TIME TEST PSXTMTHREAD05 ***" ); + benchmark_pthread_setschedparam(); + + rtems_test_assert( 1 ); + return NULL; +} + +/* configuration information */ + +#define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER +#define CONFIGURE_APPLICATION_NEEDS_TIMER_DRIVER + +#define CONFIGURE_MAXIMUM_POSIX_THREADS 2 +#define CONFIGURE_POSIX_INIT_THREAD_TABLE + +#define CONFIGURE_INIT + +#include +/* end of file */ diff --git a/testsuites/psxtmtests/psxtmthread05/psxtmthread05.doc b/testsuites/psxtmtests/psxtmthread05/psxtmthread05.doc new file mode 100644 index 0000000000..95724d04df --- /dev/null +++ b/testsuites/psxtmtests/psxtmthread05/psxtmthread05.doc @@ -0,0 +1,26 @@ +# COPYRIGHT (c) 1989-2011. +# On-Line Applications Research Corporation (OAR). +# COPYRIGHT (c) 2013. +# Chirayu Desai (chirayudesai1@gmail.com). +# +# The license and distribution terms for this file may be +# found in the file LICENSE in this distribution or at +# http://www.rtems.com/license/LICENSE. +# + +This test benchmarks the following operations: + ++ pthread_setschedparam - lower own priority, preempt + +This file describes the directives and concepts tested by this test set. + +test set name: psxtmthread + +directives: ++ pthread_create ++ pthread_getschedparam ++ pthread_setschedparam + +concepts: + ++ Benchmark the call pthread_setschedparam while lowering the priority. -- cgit v1.2.3