[rtems commit] posix: sched_get_priority_max()

Sebastian Huber sebh at rtems.org
Tue Jun 14 10:10:08 UTC 2016


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

Author:    Sebastian Huber <sebastian.huber at embedded-brains.de>
Date:      Tue Jun 14 11:13:22 2016 +0200

posix: sched_get_priority_max()

Enable for all configurations since it pulls in no additional
dependencies.  Return value of the scheduler instance of the executing
thread.

---

 cpukit/posix/Makefile.am                  |  3 ++-
 cpukit/posix/src/sched_getprioritymax.c   | 12 ++++++++++--
 testsuites/smptests/smpscheduler02/init.c |  8 ++++----
 3 files changed, 16 insertions(+), 7 deletions(-)

diff --git a/cpukit/posix/Makefile.am b/cpukit/posix/Makefile.am
index a119bd0..873ad11 100644
--- a/cpukit/posix/Makefile.am
+++ b/cpukit/posix/Makefile.am
@@ -207,13 +207,14 @@ libposix_a_SOURCES += src/psxnametoid.c
 
 EXTRA_DIST += src/README.mqueue
 
-libposix_a_SOURCES += src/sched_getparam.c src/sched_getprioritymax.c \
+libposix_a_SOURCES += src/sched_getparam.c \
     src/sched_getscheduler.c \
     src/sched_rr_get_interval.c src/sched_setparam.c \
     src/sched_setscheduler.c src/sched_yield.c
 endif
 
 libposix_a_SOURCES += src/sched_getprioritymin.c
+libposix_a_SOURCES += src/sched_getprioritymax.c
 
 include $(srcdir)/preinstall.am
 include $(top_srcdir)/automake/local.am
diff --git a/cpukit/posix/src/sched_getprioritymax.c b/cpukit/posix/src/sched_getprioritymax.c
index cde9eb9..94114e3 100644
--- a/cpukit/posix/src/sched_getprioritymax.c
+++ b/cpukit/posix/src/sched_getprioritymax.c
@@ -25,12 +25,14 @@
 
 #include <rtems/system.h>
 #include <rtems/seterr.h>
-#include <rtems/posix/priorityimpl.h>
+#include <rtems/score/schedulerimpl.h>
 
 int sched_get_priority_max(
   int  policy
 )
 {
+  const Scheduler_Control *scheduler;
+
   switch ( policy ) {
     case SCHED_OTHER:
     case SCHED_FIFO:
@@ -42,5 +44,11 @@ int sched_get_priority_max(
       rtems_set_errno_and_return_minus_one( EINVAL );
   }
 
-  return POSIX_SCHEDULER_MAXIMUM_PRIORITY;
+  scheduler = _Scheduler_Get_own( _Thread_Get_executing() );
+
+  if ( scheduler->maximum_priority > INT_MAX ) {
+    return INT_MAX;
+  }
+
+  return (int) scheduler->maximum_priority - 1;
 }
diff --git a/testsuites/smptests/smpscheduler02/init.c b/testsuites/smptests/smpscheduler02/init.c
index c7fe053..479e468 100644
--- a/testsuites/smptests/smpscheduler02/init.c
+++ b/testsuites/smptests/smpscheduler02/init.c
@@ -43,6 +43,7 @@ static void task(rtems_task_argument arg)
 
   rtems_test_assert(rtems_get_current_processor() == 1);
   rtems_test_assert(sched_get_priority_min(SCHED_RR) == 1);
+  rtems_test_assert(sched_get_priority_max(SCHED_RR) == 126);
 
   sc = rtems_event_transient_send(main_task_id);
   rtems_test_assert(sc == RTEMS_SUCCESSFUL);
@@ -134,6 +135,7 @@ static void test(void)
   rtems_test_assert(CPU_EQUAL(&cpuset, &first_cpu));
 
   rtems_test_assert(sched_get_priority_min(SCHED_RR) == 1);
+  rtems_test_assert(sched_get_priority_max(SCHED_RR) == 254);
 
   if (cpu_count > 1) {
     sc = rtems_task_set_scheduler(task_id, scheduler_b_id);
@@ -215,16 +217,14 @@ static void Init(rtems_task_argument arg)
 /* Lets see when the first RTEMS system hits this limit */
 #define CONFIGURE_SMP_MAXIMUM_PROCESSORS 64
 
-#define CONFIGURE_MAXIMUM_PRIORITY 255
-
 #define CONFIGURE_SCHEDULER_PRIORITY_SMP
 #define CONFIGURE_SCHEDULER_SIMPLE_SMP
 
 #include <rtems/scheduler.h>
 
-RTEMS_SCHEDULER_CONTEXT_PRIORITY_SMP(a, CONFIGURE_MAXIMUM_PRIORITY + 1);
+RTEMS_SCHEDULER_CONTEXT_PRIORITY_SMP(a, 256);
 
-RTEMS_SCHEDULER_CONTEXT_PRIORITY_SMP(b, CONFIGURE_MAXIMUM_PRIORITY + 1);
+RTEMS_SCHEDULER_CONTEXT_PRIORITY_SMP(b, 128);
 
 RTEMS_SCHEDULER_CONTEXT_SIMPLE_SMP(c);
 




More information about the vc mailing list