2011-07-22 Ricardo Aguirre <el.mastin@ymail.com>

PR 1847/tests
	* Makefile.am, configure.ac, psxtmtests_plan.csv: Add benchmark of
	various non-blocking semaphore operations.
	* psxtmsem02/.cvsignore, psxtmsem02/Makefile.am, psxtmsem02/init.c,
	psxtmsem02/psxtmsem02.doc: New files.
This commit is contained in:
Joel Sherrill
2011-07-22 17:22:10 +00:00
parent f31fcd44e4
commit 8f376951c5
8 changed files with 230 additions and 5 deletions

View File

@@ -1,3 +1,11 @@
2011-07-22 Ricardo Aguirre <el.mastin@ymail.com>
PR 1847/tests
* Makefile.am, configure.ac, psxtmtests_plan.csv: Add benchmark of
various non-blocking semaphore operations.
* psxtmsem02/.cvsignore, psxtmsem02/Makefile.am, psxtmsem02/init.c,
psxtmsem02/psxtmsem02.doc: New files.
2011-07-22 Ricardo Aguirre <el.mastin@ymail.com>
PR 1846/tests

View File

@@ -19,6 +19,7 @@ SUBDIRS += psxtmmutex07
SUBDIRS += psxtmnanosleep01
SUBDIRS += psxtmnanosleep02
SUBDIRS += psxtmsem01
SUBDIRS += psxtmsem02
SUBDIRS += psxtmsleep01
SUBDIRS += psxtmsleep02
SUBDIRS += psxtmthread01

View File

@@ -91,6 +91,7 @@ psxtmmutex07/Makefile
psxtmnanosleep01/Makefile
psxtmnanosleep02/Makefile
psxtmsem01/Makefile
psxtmsem02/Makefile
psxtmsleep01/Makefile
psxtmsleep02/Makefile
psxtmthread01/Makefile

View File

@@ -0,0 +1,2 @@
Makefile
Makefile.in

View File

@@ -0,0 +1,30 @@
##
## $Id$
##
MANAGERS = all
rtems_tests_PROGRAMS = psxtmsem02
psxtmsem02_SOURCES = init.c ../../tmtests/include/timesys.h \
../../support/src/tmtests_empty_function.c \
../../support/src/tmtests_support.c
dist_rtems_tests_DATA = psxtmsem02.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 = $(psxtmsem02_OBJECTS) $(psxtmsem02_LDADD)
LINK_LIBS = $(psxtmsem02_LDLIBS)
psxtmsem02$(EXEEXT): $(psxtmsem02_OBJECTS) $(psxtmsem02_DEPENDENCIES)
@rm -f psxtmsem02$(EXEEXT)
$(make-exe)
include $(top_srcdir)/../automake/local.am

View File

@@ -0,0 +1,164 @@
/*
* 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 <errno.h>
#include <fcntl.h>
#include <semaphore.h>
#include <tmacros.h>
#include <timesys.h>
#include <rtems/timerdrv.h>
#include "test_support.h"
sem_t sem1;
sem_t *n_sem1;
void benchmark_sem_getvalue(void)
{
long end_time;
int status;
int value;
benchmark_timer_initialize();
status = sem_getvalue(&sem1, &value);
end_time = benchmark_timer_read();
rtems_test_assert( status == 0 );
put_time(
"sem_getvalue",
end_time,
1, /* Only executed once */
0,
0
);
}
void benchmark_sem_wait(void)
{
long end_time;
int status;
benchmark_timer_initialize();
status = sem_wait(&sem1);
end_time = benchmark_timer_read();
rtems_test_assert( status == 0 );
put_time(
"sem_wait available",
end_time,
1, /* Only executed once */
0,
0
);
}
void benchmark_sem_post(void)
{
long end_time;
int status;
benchmark_timer_initialize();
status = sem_post(&sem1);
end_time = benchmark_timer_read();
rtems_test_assert( status == 0 );
put_time(
"sem_post - no threads waiting",
end_time,
1, /* Only executed once */
0,
0
);
}
void benchmark_sem_trywait_available(void)
{
long end_time;
int status;
benchmark_timer_initialize();
status = sem_trywait(&sem1);
end_time = benchmark_timer_read();
rtems_test_assert( status == 0 );
put_time(
"sem_trywait - available",
end_time,
1, /* Only executed once */
0,
0
);
}
void benchmark_sem_trywait_not_available(void)
{
long end_time;
int status;
benchmark_timer_initialize();
status = sem_trywait(&sem1);
end_time = benchmark_timer_read();
/*it must be non avalible, so status should be non zero*/
rtems_test_assert( status != 0 );
put_time(
"sem_trywait - not available",
end_time,
1, /* Only executed once */
0,
0
);
}
void *POSIX_Init(void *argument)
{
int status;
puts( "\n\n*** POSIX TIME TEST PSXTMSEM02 ***" );
/* create the semaphore */
status = sem_init( &sem1, 0, 1 );
rtems_test_assert( status == 0 );
/* obtain the actual semaphore value */
benchmark_sem_getvalue();
/* lock the semaphore */
benchmark_sem_wait();
/* unlock the semaphore */
benchmark_sem_post();
/* try to lock the semaphore - available */
benchmark_sem_trywait_available();
/* try to lock the semaphore, not available */
benchmark_sem_trywait_not_available();
puts( "*** END OF POSIX TIME TEST PSXTMSEM02 ***" );
/*Destroying the semaphore*/
status = sem_destroy(&sem1);
rtems_test_assert( status == 0 );
rtems_test_exit(0);
}
/* configuration information */
#define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
#define CONFIGURE_APPLICATION_NEEDS_TIMER_DRIVER
#define CONFIGURE_MAXIMUM_POSIX_THREADS 1
#define CONFIGURE_MAXIMUM_POSIX_SEMAPHORES 2
#define CONFIGURE_POSIX_INIT_THREAD_TABLE
#define CONFIGURE_INIT
#include <rtems/confdefs.h>
/* end of file */

View File

@@ -0,0 +1,19 @@
#
# $Id$
#
# 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.
#
This test benchmarks the following operations:
+ sem_getvalue
+ sem_wait available
+ sem_post - no threads waiting
+ sem_trywait - available_
+ sem_trywait - not available

View File

@@ -106,14 +106,14 @@
"sem_unlink (does not delete)","psxtmsem01","psxtmtest_single","Yes"
"sem_close (named second close - removes)","psxtmsem01","psxtmtest_single","Yes"
"sem_unlink (deletes)","psxtmsem01","psxtmtest_single","Yes"
"sem_wait - available",,"psxtmtest_single",
"sem_wait - available","psxtmsem02","psxtmtest_single","Yes"
"sem_wait - not available, block",,"psxtmtest_blocking",
"sem_trywait - available",,"psxtmtest_single",
"sem_trywait - not available",,"psxtmtest_single",
"sem_post - no threads waiting",,"psxtmtest_single",
"sem_trywait - available","psxtmsem02","psxtmtest_single","Yes"
"sem_trywait - not available","psxtmsem02","psxtmtest_single","Yes"
"sem_post - no threads waiting","psxtmsem02","psxtmtest_single","Yes"
"sem_post - thread waiting, no preempt",,"psxtmtest_unblocking_nopreempt",
"sem_post - thread waiting, preempt",,"psxtmtest_unblocking_preempt",
"sem_getvalue",,"psxtmtest_single",
"sem_getvalue","psxtmsem02","psxtmtest_single","Yes"
,,,
"sleep - yield","psxtmsleep01","psxtmtest_single","Yes"
"sleep - blocking","psxtmsleep02","psxtmtest_blocking","Yes"
1 Test Case Test Template Implemented
106 sem_unlink (does not delete) psxtmsem01 psxtmtest_single Yes
107 sem_close (named second close - removes) psxtmsem01 psxtmtest_single Yes
108 sem_unlink (deletes) psxtmsem01 psxtmtest_single Yes
109 sem_wait - available psxtmsem02 psxtmtest_single Yes
110 sem_wait - not available, block psxtmtest_blocking
111 sem_trywait - available psxtmsem02 psxtmtest_single Yes
112 sem_trywait - not available psxtmsem02 psxtmtest_single Yes
113 sem_post - no threads waiting psxtmsem02 psxtmtest_single Yes
114 sem_post - thread waiting, no preempt psxtmtest_unblocking_nopreempt
115 sem_post - thread waiting, preempt psxtmtest_unblocking_preempt
116 sem_getvalue psxtmsem02 psxtmtest_single Yes
117
118 sleep - yield psxtmsleep01 psxtmtest_single Yes
119 sleep - blocking psxtmsleep02 psxtmtest_blocking Yes