forked from Imagelibrary/rtems
psxtmtests: copy psxtmthread05 to psxtmthread06, fix psxtmthread05
The psxtmthread05 test was testing the functionality meant for psxtmthread06. This patch copies the psxtmthread05 to psxtmthread06 and modifies psxtmthread05 to test the intended functionality.
This commit is contained in:
committed by
Gedare Bloom
parent
a9051de9e0
commit
e9a1c991fe
@@ -43,6 +43,7 @@ SUBDIRS += psxtmthread01
|
||||
SUBDIRS += psxtmthread02
|
||||
SUBDIRS += psxtmthread03
|
||||
SUBDIRS += psxtmthread05
|
||||
SUBDIRS += psxtmthread06
|
||||
endif
|
||||
|
||||
DIST_SUBDIRS = $(SUBDIRS)
|
||||
|
||||
@@ -117,5 +117,6 @@ psxtmthread01/Makefile
|
||||
psxtmthread02/Makefile
|
||||
psxtmthread03/Makefile
|
||||
psxtmthread05/Makefile
|
||||
psxtmthread06/Makefile
|
||||
])
|
||||
AC_OUTPUT
|
||||
|
||||
@@ -36,7 +36,7 @@
|
||||
"pthread_getschedparam","psxtmthread04","psxtmtest_single w/multiple timings","No"
|
||||
"pthread_setschedparam - no thread switch","psxtmthread04","psxtmtest_single w/multiple timings","No"
|
||||
"pthread_setschedparam - lower own priority, preempt","psxtmthread05","psxtmtest_single","Yes"
|
||||
"pthread_setschedparam - raise other priority, preempt","psxtmthread06","psxtmtest_single","No"
|
||||
"pthread_setschedparam - raise other priority, preempt","psxtmthread06","psxtmtest_single","Yes"
|
||||
,,,
|
||||
"pthread_once",,,
|
||||
,,,
|
||||
|
||||
|
2
testsuites/psxtmtests/psxtmthread05/.cvsignore
Normal file
2
testsuites/psxtmtests/psxtmthread05/.cvsignore
Normal file
@@ -0,0 +1,2 @@
|
||||
Makefile
|
||||
Makefile.in
|
||||
@@ -2,7 +2,6 @@
|
||||
* COPYRIGHT (c) 1989-2012.
|
||||
* On-Line Applications Research Corporation (OAR).
|
||||
* COPYRIGHT (c) 2013.
|
||||
* Chirayu Desai (chirayudesai1@gmail.com).
|
||||
*
|
||||
* The license and distribution terms for this file may be
|
||||
* found in the file LICENSE in this distribution or at
|
||||
@@ -37,14 +36,16 @@ void benchmark_pthread_setschedparam(void)
|
||||
|
||||
/* make test_thread equal to POSIX_Init() */
|
||||
pthread_getschedparam(pthread_self(), &policy, ¶m);
|
||||
|
||||
pthread_setschedparam(thread_ID, policy, ¶m);
|
||||
/* At this point, we've switched to test_thread */
|
||||
|
||||
/* Back from test_thread, switch to test_thread again */
|
||||
param.sched_priority = sched_get_priority_max(policy) - 1;
|
||||
param.sched_priority = sched_get_priority_min(policy);
|
||||
|
||||
benchmark_timer_initialize();
|
||||
pthread_setschedparam(thread_ID, policy, ¶m);
|
||||
//lower own priority to minimun, scheduler forces an involuntary context switch
|
||||
pthread_setschedparam(pthread_self(), policy, ¶m);
|
||||
}
|
||||
|
||||
void *test_thread(
|
||||
@@ -52,12 +53,9 @@ void *test_thread(
|
||||
)
|
||||
{
|
||||
long end_time;
|
||||
|
||||
/* switch to POSIX_Init */
|
||||
sched_yield();
|
||||
|
||||
end_time = benchmark_timer_read();
|
||||
|
||||
put_time(
|
||||
"pthread_setschedparam - lower own priority, preempt",
|
||||
end_time,
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
# COPYRIGHT (c) 1989-2011.
|
||||
# On-Line Applications Research Corporation (OAR).
|
||||
# COPYRIGHT (c) 2013.
|
||||
# Chirayu Desai (chirayudesai1@gmail.com).
|
||||
#
|
||||
# The license and distribution terms for this file may be
|
||||
# found in the file LICENSE in this distribution or at
|
||||
@@ -22,5 +20,5 @@ directives:
|
||||
+ pthread_setschedparam
|
||||
|
||||
concepts:
|
||||
|
||||
+ Benchmark the call pthread_setschedparam while lowering the priority.
|
||||
+ Benchmark the call pthread_setschedparam for lowering own priority and the
|
||||
resulting involuntary context switch.
|
||||
|
||||
27
testsuites/psxtmtests/psxtmthread06/Makefile.am
Normal file
27
testsuites/psxtmtests/psxtmthread06/Makefile.am
Normal file
@@ -0,0 +1,27 @@
|
||||
MANAGERS = all
|
||||
|
||||
rtems_tests_PROGRAMS = psxtmthread06
|
||||
psxtmthread06_SOURCES = init.c
|
||||
psxtmthread06_SOURCES += ../../tmtests/include/timesys.h
|
||||
psxtmthread06_SOURCES += ../../support/src/tmtests_empty_function.c
|
||||
psxtmthread06_SOURCES += ../../support/src/tmtests_support.c
|
||||
|
||||
dist_rtems_tests_DATA = psxtmthread06.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 = $(psxtmthread06_OBJECTS) $(psxtmthread06_LDADD)
|
||||
LINK_LIBS = $(psxtmthread06_LDLIBS)
|
||||
|
||||
psxtmthread06$(EXEEXT): $(psxtmthread06_OBJECTS) $(psxtmthread06_DEPENDENCIES)
|
||||
@rm -f psxtmthread06$(EXEEXT)
|
||||
$(make-exe)
|
||||
|
||||
include $(top_srcdir)/../automake/local.am
|
||||
98
testsuites/psxtmtests/psxtmthread06/init.c
Normal file
98
testsuites/psxtmtests/psxtmthread06/init.c
Normal file
@@ -0,0 +1,98 @@
|
||||
/*
|
||||
* COPYRIGHT (c) 1989-2012.
|
||||
* On-Line Applications Research Corporation (OAR).
|
||||
* COPYRIGHT (c) 2013.
|
||||
* Chirayu Desai (chirayudesai1@gmail.com).
|
||||
*
|
||||
* 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 <timesys.h>
|
||||
#include <pthread.h>
|
||||
#include <sched.h>
|
||||
#include <rtems/timerdrv.h>
|
||||
#include "test_support.h"
|
||||
|
||||
/* forward declarations to avoid warnings */
|
||||
void *POSIX_Init(void *argument);
|
||||
void benchmark_pthread_create(void);
|
||||
void benchmark_pthread_setschedparam(void);
|
||||
void *test_thread(void *argument);
|
||||
|
||||
void benchmark_pthread_setschedparam(void)
|
||||
{
|
||||
int status;
|
||||
int policy;
|
||||
struct sched_param param;
|
||||
pthread_t thread_ID;
|
||||
|
||||
status = pthread_create(&thread_ID, NULL, test_thread, NULL);
|
||||
rtems_test_assert( status == 0 );
|
||||
|
||||
/* make test_thread equal to POSIX_Init() */
|
||||
pthread_getschedparam(pthread_self(), &policy, ¶m);
|
||||
pthread_setschedparam(thread_ID, policy, ¶m);
|
||||
/* At this point, we've switched to test_thread */
|
||||
|
||||
/* Back from test_thread, switch to test_thread again */
|
||||
param.sched_priority = sched_get_priority_max(policy) - 1;
|
||||
|
||||
benchmark_timer_initialize();
|
||||
pthread_setschedparam(thread_ID, policy, ¶m);
|
||||
}
|
||||
|
||||
void *test_thread(
|
||||
void *argument
|
||||
)
|
||||
{
|
||||
long end_time;
|
||||
|
||||
/* switch to POSIX_Init */
|
||||
sched_yield();
|
||||
|
||||
end_time = benchmark_timer_read();
|
||||
|
||||
put_time(
|
||||
"pthread_setschedparam - raise other priority, preempt",
|
||||
end_time,
|
||||
1, /* Only executed once */
|
||||
0,
|
||||
0
|
||||
);
|
||||
|
||||
puts( "*** END OF POSIX TIME TEST PSXTMTHREAD06 ***" );
|
||||
rtems_test_exit(0);
|
||||
//Empty thread used in pthread_create().
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void *POSIX_Init(
|
||||
void *argument
|
||||
)
|
||||
{
|
||||
|
||||
puts( "\n\n*** POSIX TIME TEST PSXTMTHREAD06 ***" );
|
||||
benchmark_pthread_setschedparam();
|
||||
|
||||
rtems_test_assert( 1 );
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* configuration information */
|
||||
|
||||
#define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
|
||||
#define CONFIGURE_APPLICATION_NEEDS_TIMER_DRIVER
|
||||
|
||||
#define CONFIGURE_MAXIMUM_POSIX_THREADS 2
|
||||
#define CONFIGURE_POSIX_INIT_THREAD_TABLE
|
||||
|
||||
#define CONFIGURE_INIT
|
||||
|
||||
#include <rtems/confdefs.h>
|
||||
/* end of file */
|
||||
26
testsuites/psxtmtests/psxtmthread06/psxtmthread06.doc
Normal file
26
testsuites/psxtmtests/psxtmthread06/psxtmthread06.doc
Normal file
@@ -0,0 +1,26 @@
|
||||
# COPYRIGHT (c) 1989-2011.
|
||||
# On-Line Applications Research Corporation (OAR).
|
||||
# COPYRIGHT (c) 2013.
|
||||
# Chirayu Desai (chirayudesai1@gmail.com).
|
||||
#
|
||||
# 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_setschedparam - raise other priority, preempt
|
||||
|
||||
This file describes the directives and concepts tested by this test set.
|
||||
|
||||
test set name: psxtmthread
|
||||
|
||||
directives:
|
||||
+ pthread_create
|
||||
+ pthread_getschedparam
|
||||
+ pthread_setschedparam
|
||||
|
||||
concepts:
|
||||
+ Benchmark the call pthread_setschedparam for raising another thread's
|
||||
priority and the resulting context switch.
|
||||
Reference in New Issue
Block a user