diff options
author | Daniel Ramirez <javamonn@gmail.com> | 2013-11-30 20:27:44 -0600 |
---|---|---|
committer | Gedare Bloom <gedare@rtems.org> | 2013-11-30 21:31:30 -0500 |
commit | 72ff7569b096457332cd8de7fe0f00c16b87fb1b (patch) | |
tree | 19e10619f87748ee153e3b38e00ad1d7c253144c /testsuites/psxtmtests/psxtmcond04 | |
parent | psx07.doc: New file (diff) | |
download | rtems-72ff7569b096457332cd8de7fe0f00c16b87fb1b.tar.bz2 |
psxtmtests: added new psxtmcond04 test, fixed psxtmcond03
Diffstat (limited to 'testsuites/psxtmtests/psxtmcond04')
-rw-r--r-- | testsuites/psxtmtests/psxtmcond04/Makefile.am | 27 | ||||
-rw-r--r-- | testsuites/psxtmtests/psxtmcond04/init.c | 107 | ||||
-rw-r--r-- | testsuites/psxtmtests/psxtmcond04/psxtmcond04.doc | 25 |
3 files changed, 159 insertions, 0 deletions
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 <coverhd.h> +#include <tmacros.h> +#include <timesys.h> +#include "test_support.h" +#include <pthread.h> +#include <sched.h> +#include <rtems/timerdrv.h> + +/* 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 <rtems/confdefs.h> + /* 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. |