summaryrefslogtreecommitdiffstats
path: root/testsuites/psxtests/psx12
diff options
context:
space:
mode:
authorSebastian Huber <sebastian.huber@embedded-brains.de>2016-08-12 15:54:46 +0200
committerSebastian Huber <sebastian.huber@embedded-brains.de>2016-08-18 07:28:00 +0200
commit5d1fc66ce7b1afccb2537a7acb34ae7eace97f74 (patch)
tree3bec3ad97f00b73402e7ef522892c3a9eb601c23 /testsuites/psxtests/psx12
parentscore: Fix undefined behaviour (diff)
downloadrtems-5d1fc66ce7b1afccb2537a7acb34ae7eace97f74.tar.bz2
psxtests: Adjust sporadic server tests
According to POSIX priority value returned from pthread_getschedparam() shall be the value specified by the most recent pthread_setschedparam(), pthread_setschedprio(), or pthread_create() call affecting the target thread. Read this as though a temporary lower priority due to the sporadic server policy shall not be visible through pthread_getschedparam(). Thus, use rtems_task_set_priority() to get the current priority of the threads. Use a priority ceiling mutex to prevent sporadic server priority adjustments.
Diffstat (limited to 'testsuites/psxtests/psx12')
-rw-r--r--testsuites/psxtests/psx12/init.c25
1 files changed, 17 insertions, 8 deletions
diff --git a/testsuites/psxtests/psx12/init.c b/testsuites/psxtests/psx12/init.c
index d7218933ee..46fb0161b7 100644
--- a/testsuites/psxtests/psx12/init.c
+++ b/testsuites/psxtests/psx12/init.c
@@ -44,16 +44,25 @@ typedef struct {
static test_context test_instance;
+static int get_current_prio( pthread_t thread )
+{
+ rtems_status_code sc;
+ rtems_task_priority prio;
+ int max;
+
+ sc = rtems_task_set_priority( thread, RTEMS_CURRENT_PRIORITY, &prio );
+ rtems_test_assert( sc == RTEMS_SUCCESSFUL );
+
+ max = sched_get_priority_max( SCHED_FIFO );
+
+ return max + 1 - (int) prio;
+}
+
static void wait_for_prio( int prio )
{
- int status;
- int policy;
- struct sched_param param;
-
- do {
- status = pthread_getschedparam( pthread_self(), &policy, &param );
- rtems_test_assert( status == 0 );
- } while ( prio != param.sched_priority );
+ while ( prio != get_current_prio( pthread_self() ) ) {
+ /* Wait */
+ }
}
static uint64_t timeval_to_us( const struct timeval *tv )