diff options
author | Joel Sherrill <joel.sherrill@OARcorp.com> | 2011-07-20 20:48:26 +0000 |
---|---|---|
committer | Joel Sherrill <joel.sherrill@OARcorp.com> | 2011-07-20 20:48:26 +0000 |
commit | e264777d4286df776a5d33abcd2612b0082ea319 (patch) | |
tree | 090d2f7dbbbb345de6a3e83f8426efdf9967203e /rtems-test-template/psxtmtest_unblocking_nopreempt/init.c | |
parent | 0bf2f75b9902819cfa14e223f9f5c3223f78fce5 (diff) |
2011-07-20 Joel Sherrill <joel.sherrill@oarcorp.com>
* psxtmtest_blocking/init.c: Add template for POSIX timing test of
unblocking operation with no preemption.
* psxtmtest_unblocking_nopreempt/Makefile.am,
psxtmtest_unblocking_nopreempt/TEST.doc,
psxtmtest_unblocking_nopreempt/init.c: New files.
Diffstat (limited to '')
-rw-r--r-- | rtems-test-template/psxtmtest_unblocking_nopreempt/init.c | 113 |
1 files changed, 113 insertions, 0 deletions
diff --git a/rtems-test-template/psxtmtest_unblocking_nopreempt/init.c b/rtems-test-template/psxtmtest_unblocking_nopreempt/init.c new file mode 100644 index 0000000..39e6857 --- /dev/null +++ b/rtems-test-template/psxtmtest_unblocking_nopreempt/init.c @@ -0,0 +1,113 @@ +/* + * COPYRIGHT (c) 1989-2011. + * 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. + * + * $Id$ + */ + +#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> + +pthread_mutex_t MutexId; + +void *Blockers( + void *argument +) +{ + int status; + + /* + * Now we have finished the thread startup overhead, + * so let other threads run. When we return, we can + * finish the benchmark. + */ + sched_yield(); + /* let other threads run */ + + status = pthread_mutex_lock( &MutexId ); + rtems_test_assert( status == 0 ); + + return NULL; +} + +void *POSIX_Init( + void *argument +) +{ + int i; + int status; + pthread_t threadId; + long end_time; + + puts( "\n\n*** POSIX TIME TEST MUTEX @TESTNUM@ ***" ); + + for ( i=0 ; i < OPERATION_COUNT ; i++ ) { + status = pthread_create( &threadId, NULL, Blockers, NULL ); + rtems_test_assert( status == 0 ); + } + + /* + * Deliberately create the XXX after the threads. This way if the + * threads do run before we intend, they will get an error. + */ + status = 0; /* XXX create the resource */ + rtems_test_assert( status == 0 ); + + /* + * Ensure the mutex is unavailable so the other threads block. + */ + status = 0; /* XXX ensure the resource is unavailable so the threads block */ + rtems_test_assert( status == 0 ); + + /* + * Let the other threads start so the thread startup overhead, + * is accounted for. When we return, we can start the benchmark. + */ + sched_yield(); + /* let other threads run */ + + benchmark_timer_initialize(); + status = 0; /* XXX release the resource */ + end_time = benchmark_timer_read(); + rtems_test_assert( status == 0 ); + + put_time( + "@DESC@", + end_time, + OPERATION_COUNT, + 0, + 0 + ); + + puts( "*** END OF POSIX TIME TEST MUTEX @TESTNUM@ ***" ); + rtems_test_exit( 0 ); + + return NULL; +} + +/* configuration information */ + +#define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER +#define CONFIGURE_APPLICATION_NEEDS_TIMER_DRIVER + +#define CONFIGURE_MAXIMUM_POSIX_THREADS OPERATION_COUNT + 1 +/* XXX configure one of the resources */ +#define CONFIGURE_POSIX_INIT_THREAD_TABLE + +#define CONFIGURE_INIT + +#include <rtems/confdefs.h> + /* end of file */ |