From 72ff7569b096457332cd8de7fe0f00c16b87fb1b Mon Sep 17 00:00:00 2001 From: Daniel Ramirez Date: Sat, 30 Nov 2013 20:27:44 -0600 Subject: psxtmtests: added new psxtmcond04 test, fixed psxtmcond03 --- testsuites/psxtmtests/psxtmcond04/Makefile.am | 27 ++++++ testsuites/psxtmtests/psxtmcond04/init.c | 107 ++++++++++++++++++++++ testsuites/psxtmtests/psxtmcond04/psxtmcond04.doc | 25 +++++ 3 files changed, 159 insertions(+) create mode 100644 testsuites/psxtmtests/psxtmcond04/Makefile.am create mode 100644 testsuites/psxtmtests/psxtmcond04/init.c create mode 100644 testsuites/psxtmtests/psxtmcond04/psxtmcond04.doc (limited to 'testsuites/psxtmtests/psxtmcond04') diff --git a/testsuites/psxtmtests/psxtmcond04/Makefile.am b/testsuites/psxtmtests/psxtmcond04/Makefile.am new file mode 100644 index 0000000000..875b08c576 --- /dev/null +++ b/testsuites/psxtmtests/psxtmcond04/Makefile.am @@ -0,0 +1,27 @@ +MANAGERS = all + +rtems_tests_PROGRAMS = psxtmcond04 +psxtmcond04_SOURCES = init.c +psxtmcond04_SOURCES += ../../tmtests/include/timesys.h +psxtmcond04_SOURCES += ../../support/src/tmtests_empty_function.c +psxtmcond04_SOURCES += ../../support/src/tmtests_support.c + +dist_rtems_tests_DATA = psxtmcond04.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 = $(psxtmcond04_OBJECTS) $(psxtmcond04_LDADD) +LINK_LIBS = $(psxtmcond04_LDLIBS) + +psxtmcond04$(EXEEXT): $(psxtmcond04_OBJECTS) $(psxtmcond04_DEPENDENCIES) + @rm -f psxtmcond04$(EXEEXT) + $(make-exe) + +include $(top_srcdir)/../automake/local.am diff --git a/testsuites/psxtmtests/psxtmcond04/init.c b/testsuites/psxtmtests/psxtmcond04/init.c new file mode 100644 index 0000000000..676a3c84a8 --- /dev/null +++ b/testsuites/psxtmtests/psxtmcond04/init.c @@ -0,0 +1,107 @@ +/* + * COPYRIGHT (c) 2013. + * On-Line Applications Research Corporation (OAR). + * + * 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 "test_support.h" +#include +#include +#include + +/* forward declarations to avoid warnings */ +void *POSIX_Init(void *argument); +void *Blocker(void *argument); + +pthread_mutex_t MutexID; +pthread_cond_t CondID; + +void *Blocker( + void *argument +) +{ + + long end_time; + struct sched_param param; + int policy; + int status; + + status = pthread_mutex_lock(&MutexID); + rtems_test_assert( status == 0 ); + status = pthread_getschedparam(pthread_self(), &policy, ¶m); + rtems_test_assert( status == 0 ); + param.sched_priority = sched_get_priority_max(policy) - 1; + status = pthread_setschedparam(pthread_self(), policy, ¶m); + /* Thread blocks, unlocks mutex, waits for CondID to be signaled */ + pthread_cond_wait(&CondID,&MutexID); + + /* Once signaled, this thread preempts POSIX_Init thread */ + end_time = benchmark_timer_read(); + put_time( + "pthread_cond_signal - thread waiting, preempt", + end_time, + 1, + 0, + 0 + ); + puts( "*** END OF POSIX TIME TEST PSXTMCOND04 ***" ); + rtems_test_exit( 0 ); + return NULL; +} + +void *POSIX_Init( + void *argument +) +{ + int status; + pthread_t threadId; + + puts( "\n\n*** POSIX TIME TEST PSXTMCOND04 ***" ); + + status = pthread_create( &threadId, NULL, Blocker, NULL ); + rtems_test_assert( status == 0 ); + + status = pthread_mutex_init(&MutexID, NULL); + rtems_test_assert( status == 0 ); + + status = pthread_cond_init(&CondID, NULL); /* Create condition variable */ + rtems_test_assert( status == 0 ); + + /* + * Let the other thread start so the thread startup overhead, + * is accounted for. When we return, we can start the benchmark. + */ + sched_yield(); + /* let other thread run */ + + /* Other thread is blocked and waiting on condition to be signaled */ + benchmark_timer_initialize(); + status = pthread_cond_signal(&CondID); + rtems_test_assert ( status == 0 ); + return NULL; +} + +/* configuration information */ + +#define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER +#define CONFIGURE_APPLICATION_NEEDS_TIMER_DRIVER + +#define CONFIGURE_MAXIMUM_POSIX_THREADS 2 +#define CONFIGURE_MAXIMUM_POSIX_CONDITION_VARIABLES 2 +#define CONFIGURE_MAXIMUM_POSIX_MUTEXES 2 +#define CONFIGURE_POSIX_INIT_THREAD_TABLE + +#define CONFIGURE_INIT + +#include + /* end of file */ diff --git a/testsuites/psxtmtests/psxtmcond04/psxtmcond04.doc b/testsuites/psxtmtests/psxtmcond04/psxtmcond04.doc new file mode 100644 index 0000000000..eb260805a3 --- /dev/null +++ b/testsuites/psxtmtests/psxtmcond04/psxtmcond04.doc @@ -0,0 +1,25 @@ +# COPYRIGHT (c) 2013 +# On-Line Applications Research Corporation (OAR). +# +# 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_cond_signal - thread waiting: preempt + +This file describes the directives and concepts tested by this test set. + +test set name: psxtmcond + +directives: ++ pthread_cond_signal ++ pthread_mutex_lock ++ pthread_mutex_init ++ pthread_cond_init ++ pthread_create + +concepts: ++ Benchmark the call pthread_cond_signal to unlock a mutex, with a preempt. -- cgit v1.2.3