[rtems commit] posix: Fix pthread_getschedparam()

Sebastian Huber sebh at rtems.org
Mon Jun 13 12:59:34 UTC 2016


Module:    rtems
Branch:    master
Commit:    23b1bb38b208a6638747bb49b8184a5571e8f5e7
Changeset: http://git.rtems.org/rtems/commit/?id=23b1bb38b208a6638747bb49b8184a5571e8f5e7

Author:    Sebastian Huber <sebastian.huber at embedded-brains.de>
Date:      Mon Jun 13 06:53:27 2016 +0200

posix: Fix pthread_getschedparam()

Return the unmodified thread priority value according to POSIX.

Close #2736.

---

 cpukit/posix/src/pthreadgetschedparam.c |  2 +-
 testsuites/psxtests/psx05/init.c        | 46 +++++++++++++++++++++++++++++++++
 2 files changed, 47 insertions(+), 1 deletion(-)

diff --git a/cpukit/posix/src/pthreadgetschedparam.c b/cpukit/posix/src/pthreadgetschedparam.c
index 21908cb..9b6969c 100644
--- a/cpukit/posix/src/pthreadgetschedparam.c
+++ b/cpukit/posix/src/pthreadgetschedparam.c
@@ -54,7 +54,7 @@ int pthread_getschedparam(
   *policy = api->schedpolicy;
   *param  = api->schedparam;
   param->sched_priority = _POSIX_Priority_From_core(
-    the_thread->current_priority
+    the_thread->real_priority
   );
 
   _Thread_State_release( the_thread, &lock_context );
diff --git a/testsuites/psxtests/psx05/init.c b/testsuites/psxtests/psx05/init.c
index 51d2cc2..d3311fc 100644
--- a/testsuites/psxtests/psx05/init.c
+++ b/testsuites/psxtests/psx05/init.c
@@ -112,6 +112,50 @@ void calculate_abstimeout(
 
 }
 
+static void test_get_priority( void )
+{
+  int                 status;
+  pthread_mutexattr_t attr;
+  pthread_mutex_t     mutex;
+  int                 policy;
+  struct sched_param  param;
+  int                 real_priority;
+
+  status = pthread_getschedparam( pthread_self(), &policy, &param );
+  rtems_test_assert( status == 0 );
+
+  real_priority = param.sched_priority;
+
+  status = pthread_mutexattr_init( &attr );
+  rtems_test_assert( status == 0 );
+
+  status = pthread_mutexattr_setprotocol( &attr, PTHREAD_PRIO_PROTECT );
+  rtems_test_assert( !status );
+
+  status = pthread_mutexattr_setprioceiling( &attr, real_priority + 1 );
+  rtems_test_assert( status == 0 );
+
+  status = pthread_mutex_init( &mutex, &attr );
+  rtems_test_assert( status == 0 );
+
+  status = pthread_mutexattr_destroy( &attr );
+  rtems_test_assert( status == 0 );
+
+  status = pthread_mutex_lock( &mutex );
+  rtems_test_assert( status == 0 );
+
+  status = pthread_getschedparam( pthread_self(), &policy, &param );
+  rtems_test_assert( status == 0 );
+
+  rtems_test_assert( real_priority == param.sched_priority );
+
+  status = pthread_mutex_unlock( &mutex );
+  rtems_test_assert( status == 0 );
+
+  status = pthread_mutex_destroy( &mutex );
+  rtems_test_assert( status == 0 );
+}
+
 void *POSIX_Init(
   void *argument
 )
@@ -133,6 +177,8 @@ void *POSIX_Init(
 
   TEST_BEGIN();
 
+  test_get_priority();
+
   /* set the time of day, and print our buffer in multiple ways */
 
   set_time( TM_FRIDAY, TM_MAY, 24, 96, 11, 5, 0 );




More information about the vc mailing list