psxtmtests: added psxtmcond06 test

This commit is contained in:
Daniel Ramirez
2013-11-30 22:04:51 -06:00
committed by Joel Sherrill
parent 72ff7569b0
commit 972579d32b
6 changed files with 187 additions and 1 deletions

View File

@@ -12,6 +12,7 @@ SUBDIRS += psxtmcond02
SUBDIRS += psxtmcond03
SUBDIRS += psxtmcond04
SUBDIRS += psxtmcond05
SUBDIRS += psxtmcond06
SUBDIRS += psxtmcond08
SUBDIRS += psxtmcond09
SUBDIRS += psxtmcond10

View File

@@ -86,6 +86,7 @@ psxtmcond02/Makefile
psxtmcond03/Makefile
psxtmcond04/Makefile
psxtmcond05/Makefile
psxtmcond06/Makefile
psxtmcond08/Makefile
psxtmcond09/Makefile
psxtmcond10/Makefile

View File

@@ -0,0 +1,27 @@
MANAGERS = all
rtems_tests_PROGRAMS = psxtmcond06
psxtmcond06_SOURCES = init.c
psxtmcond06_SOURCES += ../../tmtests/include/timesys.h
psxtmcond06_SOURCES += ../../support/src/tmtests_empty_function.c
psxtmcond06_SOURCES += ../../support/src/tmtests_support.c
dist_rtems_tests_DATA = psxtmcond06.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 = $(psxtmcond06_OBJECTS) $(psxtmcond06_LDADD)
LINK_LIBS = $(psxtmcond06_LDLIBS)
psxtmcond06$(EXEEXT): $(psxtmcond06_OBJECTS) $(psxtmcond06_DEPENDENCIES)
@rm -f psxtmcond06$(EXEEXT)
$(make-exe)
include $(top_srcdir)/../automake/local.am

View File

@@ -0,0 +1,131 @@
/*
* COPYRIGHT (c) 1989-2012.
* 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>
#define N 5
/* 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
)
{
int status;
status = pthread_mutex_lock(&MutexID);
rtems_test_assert( status == 0 );
/* Unlock mutex, block, wait for CondID to be signaled */
pthread_cond_wait(&CondID,&MutexID);
/* should never return */
rtems_test_assert( FALSE );
return NULL;
}
void *POSIX_Init(
void *argument
)
{
long end_time;
int status;
int i;
pthread_t threadId;
pthread_attr_t attr;
struct sched_param param;
int policy;
puts( "\n\n*** POSIX TIME TEST PSXTMCOND06 ***" );
/* Setup variables */
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);
rtems_test_assert( status == 0 );
/* Setup so threads are created with a high enough priority to preempt
* as they get created.
*/
status = pthread_attr_init( &attr );
rtems_test_assert( status == 0 );
status = pthread_attr_setinheritsched( &attr, PTHREAD_EXPLICIT_SCHED );
rtems_test_assert( status == 0 );
status = pthread_attr_setschedpolicy( &attr, SCHED_FIFO );
rtems_test_assert( status == 0 );
param.sched_priority = sched_get_priority_max(SCHED_FIFO) / 2;
status = pthread_attr_setschedparam( &attr, &param );
rtems_test_assert( status == 0 );
for ( i=0 ; i < N ; i++) {
/* Threads will preempt as they are created, start up, and block */
status = pthread_create(&threadId, &attr, Blocker, NULL);
rtems_test_assert( status == 0 );
}
/* Now that all the threads have been created, adjust our priority
* so we don't get preempted on broadcast.
*/
status = pthread_getschedparam(pthread_self(), &policy, &param);
rtems_test_assert( status == 0 );
param.sched_priority = sched_get_priority_max(policy) - 1;
status = pthread_setschedparam(pthread_self(), policy, &param);
rtems_test_assert( status == 0 );
benchmark_timer_initialize();
status = pthread_cond_broadcast(&CondID);
end_time = benchmark_timer_read();
rtems_test_assert( status == 0 );
put_time(
"pthread_cond_broadcast - threads waiting, no preempt",
end_time,
1,
0,
0
);
puts( "*** END OF POSIX TIME TEST PSXTMCOND06 ***" );
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 2 + N
#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 */

View File

@@ -0,0 +1,26 @@
# 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_broadcast - threads waiting, no preempt
This file describes the directives and concepts tested by this test set.
test set name: psxtmcond
directives:
+ pthread_cond_broadcast
+ pthread_mutex_lock
+ pthread_mutex_init
+ pthread_cond_init
+ pthread_create
concepts:
+ Benchmark the call pthread_cond_broadcast to wake all other threads, with no
resulting preempt.

View File

@@ -19,7 +19,7 @@
"pthread_cond_signal - thread waiting: no preempt","psxtmcond03","psxtmtest_unblocking_nopreempt","Yes"
"pthread_cond_signal - thread waiting: preempt","psxtmcond04","psxtmtest_unblocking_preempt","Yes"
"pthread_cond_broadcast - no threads waiting","psxtmcond05","psxtmtest_single","Yes"
"pthread_cond_broadcast - threads waiting: no preempt","psxtmcond06","psxtmtest_unblocking_nopreempt","No"
"pthread_cond_broadcast - threads waiting: no preempt","psxtmcond06","psxtmtest_unblocking_nopreempt","Yes"
"pthread_cond_broadcast - threads waiting: preempt","psxtmcond07","psxtmtest_unblocking_preempt","No"
"pthread_cond_wait - blocks (mutex+condvar pattern)","psxtmcond08","psxtmtest_blocking","Yes"
1 Test Case Test Template Implemented
19 pthread_cond_signal - thread waiting: no preempt psxtmcond03 psxtmtest_unblocking_nopreempt Yes
20 pthread_cond_signal - thread waiting: preempt psxtmcond04 psxtmtest_unblocking_preempt Yes
21 pthread_cond_broadcast - no threads waiting psxtmcond05 psxtmtest_single Yes
22 pthread_cond_broadcast - threads waiting: no preempt psxtmcond06 psxtmtest_unblocking_nopreempt No Yes
23 pthread_cond_broadcast - threads waiting: preempt psxtmcond07 psxtmtest_unblocking_preempt No
24 pthread_cond_wait - blocks (mutex+condvar pattern) psxtmcond08 psxtmtest_blocking Yes
25 pthread_cond_timedwait(&time) - blocks (mutex+condvar pattern) psxtmcond09 psxtmtest_blocking No