[rtems commit] score: Change Priority_Control to 64-bit

Sebastian Huber sebh at rtems.org
Tue Jun 28 13:18:46 UTC 2016


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

Author:    Sebastian Huber <sebastian.huber at embedded-brains.de>
Date:      Fri Jun 24 11:22:03 2016 +0200

score: Change Priority_Control to 64-bit

A 32-bit Priority_Control limits the uptime to 49 days with a 1ms clock
tick in case the EDF scheduler is used.  Increase it to 64-bit to enable
proper operation of the EDF scheduler,

Close 2173.

---

 cpukit/posix/include/rtems/posix/priorityimpl.h          | 9 ++++++++-
 cpukit/posix/src/killinfo.c                              | 2 +-
 cpukit/posix/src/psxpriorityisvalid.c                    | 9 ---------
 cpukit/rtems/include/rtems/rtems/tasks.h                 | 2 +-
 cpukit/score/include/rtems/score/priority.h              | 2 +-
 cpukit/score/include/rtems/score/scheduleredf.h          | 9 ++++++++-
 cpukit/score/include/rtems/score/scheduleredfimpl.h      | 2 +-
 cpukit/score/include/rtems/score/schedulerpriorityimpl.h | 4 ++--
 cpukit/score/src/schedulerprioritychangepriority.c       | 3 ++-
 cpukit/score/src/schedulerpriorityunblock.c              | 3 ++-
 testsuites/smptests/smpmrsp01/init.c                     | 2 +-
 11 files changed, 27 insertions(+), 20 deletions(-)

diff --git a/cpukit/posix/include/rtems/posix/priorityimpl.h b/cpukit/posix/include/rtems/posix/priorityimpl.h
index b986d64..eb2e3e0 100644
--- a/cpukit/posix/include/rtems/posix/priorityimpl.h
+++ b/cpukit/posix/include/rtems/posix/priorityimpl.h
@@ -20,6 +20,7 @@
 #define _RTEMS_POSIX_PRIORITYIMPL_H
 
 #include <rtems/score/scheduler.h>
+#include <rtems/score/assert.h>
 
 #ifdef __cplusplus
 extern "C" {
@@ -48,7 +49,13 @@ extern "C" {
  *
  * @return The maximum POSIX API priority for this scheduler instance.
  */
-int _POSIX_Priority_Get_maximum( const Scheduler_Control *scheduler );
+RTEMS_INLINE_ROUTINE int _POSIX_Priority_Get_maximum(
+  const Scheduler_Control *scheduler
+)
+{
+  _Assert( (int) scheduler->maximum_priority > 1 );
+  return (int) scheduler->maximum_priority - 1;
+}
 
 /**
  * @brief Converts the POSIX API priority to the corresponding SuperCore
diff --git a/cpukit/posix/src/killinfo.c b/cpukit/posix/src/killinfo.c
index 33754af..b7f0354 100644
--- a/cpukit/posix/src/killinfo.c
+++ b/cpukit/posix/src/killinfo.c
@@ -190,7 +190,7 @@ int _POSIX_signals_Send(
    *    + rtems internal threads do not receive signals.
    */
   interested = NULL;
-  interested_priority = PRIORITY_MAXIMUM + 1;
+  interested_priority = UINT64_MAX;
 
   for (the_api = OBJECTS_CLASSIC_API; the_api <= OBJECTS_APIS_LAST; the_api++) {
 
diff --git a/cpukit/posix/src/psxpriorityisvalid.c b/cpukit/posix/src/psxpriorityisvalid.c
index 7c2300b..5e687ac 100644
--- a/cpukit/posix/src/psxpriorityisvalid.c
+++ b/cpukit/posix/src/psxpriorityisvalid.c
@@ -21,15 +21,6 @@
 #include <rtems/posix/priorityimpl.h>
 #include <rtems/score/schedulerimpl.h>
 
-int _POSIX_Priority_Get_maximum( const Scheduler_Control *scheduler )
-{
-  if ( scheduler->maximum_priority < INT_MAX ) {
-    return (int) scheduler->maximum_priority - 1;
-  } else {
-    return INT_MAX;
-  }
-}
-
 Priority_Control _POSIX_Priority_To_core(
   const Scheduler_Control *scheduler,
   int                      posix_priority,
diff --git a/cpukit/rtems/include/rtems/rtems/tasks.h b/cpukit/rtems/include/rtems/rtems/tasks.h
index 84ea806..6273228 100644
--- a/cpukit/rtems/include/rtems/rtems/tasks.h
+++ b/cpukit/rtems/include/rtems/rtems/tasks.h
@@ -75,7 +75,7 @@ extern "C" {
 /**
  *  Define the type for an RTEMS API task priority.
  */
-typedef Priority_Control rtems_task_priority;
+typedef uint32_t rtems_task_priority;
 
 /**
  *  This is the constant used with the rtems_task_set_priority
diff --git a/cpukit/score/include/rtems/score/priority.h b/cpukit/score/include/rtems/score/priority.h
index 38f3995..842f017 100644
--- a/cpukit/score/include/rtems/score/priority.h
+++ b/cpukit/score/include/rtems/score/priority.h
@@ -53,7 +53,7 @@ extern "C" {
  *
  *  @note Priority 0 is reserved for internal threads only.
  */
-typedef uint32_t   Priority_Control;
+typedef uint64_t Priority_Control;
 
 /** This defines the highest (most important) thread priority. */
 #define PRIORITY_MINIMUM      0
diff --git a/cpukit/score/include/rtems/score/scheduleredf.h b/cpukit/score/include/rtems/score/scheduleredf.h
index c236bd5..66bc17e 100644
--- a/cpukit/score/include/rtems/score/scheduleredf.h
+++ b/cpukit/score/include/rtems/score/scheduleredf.h
@@ -24,6 +24,8 @@
 #include <rtems/score/schedulerpriority.h>
 #include <rtems/score/rbtree.h>
 
+#include <limits.h>
+
 #ifdef __cplusplus
 extern "C" {
 #endif
@@ -35,7 +37,12 @@ extern "C" {
  */
 /**@{*/
 
-#define SCHEDULER_EDF_MAXIMUM_PRIORITY 0x7fffffff
+/*
+ * Actually the EDF scheduler supports a maximum priority of
+ * 0x7fffffffffffffff, but the user API is limited to uint32_t or int for
+ * thread priorities.  Ignore ILP64 targets for now.
+ */
+#define SCHEDULER_EDF_MAXIMUM_PRIORITY INT_MAX
 
 /**
  *  Entry points for the Earliest Deadline First Scheduler.
diff --git a/cpukit/score/include/rtems/score/scheduleredfimpl.h b/cpukit/score/include/rtems/score/scheduleredfimpl.h
index 20a5f5c..204660e 100644
--- a/cpukit/score/include/rtems/score/scheduleredfimpl.h
+++ b/cpukit/score/include/rtems/score/scheduleredfimpl.h
@@ -38,7 +38,7 @@ extern "C" {
  * ones who do not have any deadlines and thus are considered background
  * tasks.
  */
-#define SCHEDULER_EDF_PRIO_MSB 0x80000000
+#define SCHEDULER_EDF_PRIO_MSB 0x8000000000000000
 
 RTEMS_INLINE_ROUTINE Scheduler_EDF_Context *
   _Scheduler_EDF_Get_context( const Scheduler_Control *scheduler )
diff --git a/cpukit/score/include/rtems/score/schedulerpriorityimpl.h b/cpukit/score/include/rtems/score/schedulerpriorityimpl.h
index 0f576b6..d03c8d3 100644
--- a/cpukit/score/include/rtems/score/schedulerpriorityimpl.h
+++ b/cpukit/score/include/rtems/score/schedulerpriorityimpl.h
@@ -210,13 +210,13 @@ RTEMS_INLINE_ROUTINE void _Scheduler_priority_Ready_queue_update(
   Chain_Control                  *ready_queues
 )
 {
-  ready_queue->current_priority = new_priority;
+  ready_queue->current_priority = (unsigned int) new_priority;
   ready_queue->ready_chain = &ready_queues[ new_priority ];
 
   _Priority_bit_map_Initialize_information(
     bit_map,
     &ready_queue->Priority_map,
-    new_priority
+    (unsigned int) new_priority
   );
 }
 
diff --git a/cpukit/score/src/schedulerprioritychangepriority.c b/cpukit/score/src/schedulerprioritychangepriority.c
index 04599f5..4fc46cf 100644
--- a/cpukit/score/src/schedulerprioritychangepriority.c
+++ b/cpukit/score/src/schedulerprioritychangepriority.c
@@ -37,7 +37,8 @@ Scheduler_Void_or_thread _Scheduler_priority_Update_priority(
   }
 
   node = _Scheduler_priority_Thread_get_node( the_thread );
-  priority = _Scheduler_Node_get_priority( &node->Base, &prepend_it );
+  priority = (unsigned int )
+    _Scheduler_Node_get_priority( &node->Base, &prepend_it );
 
   if ( priority == node->Ready_queue.current_priority ) {
     /* Nothing to do */
diff --git a/cpukit/score/src/schedulerpriorityunblock.c b/cpukit/score/src/schedulerpriorityunblock.c
index ba8501b..9fc266b 100644
--- a/cpukit/score/src/schedulerpriorityunblock.c
+++ b/cpukit/score/src/schedulerpriorityunblock.c
@@ -34,7 +34,8 @@ Scheduler_Void_or_thread _Scheduler_priority_Unblock (
 
   context = _Scheduler_priority_Get_context( scheduler );
   node = _Scheduler_priority_Thread_get_node( the_thread );
-  priority = _Scheduler_Node_get_priority( &node->Base, &prepend_it );
+  priority = (unsigned int )
+    _Scheduler_Node_get_priority( &node->Base, &prepend_it );
   (void) prepend_it;
 
   if ( priority != node->Ready_queue.current_priority ) {
diff --git a/testsuites/smptests/smpmrsp01/init.c b/testsuites/smptests/smpmrsp01/init.c
index dca8662..30fb577 100644
--- a/testsuites/smptests/smpmrsp01/init.c
+++ b/testsuites/smptests/smpmrsp01/init.c
@@ -204,7 +204,7 @@ static void print_switch_events(test_context *ctx)
     rtems_object_get_name(e->heir_node->Object.id, sizeof(hn), &hn[0]);
 
     printf(
-      "[%" PRIu32 "] %4s -> %4s (prio %3" PRIu32 ", node %4s)\n",
+      "[%" PRIu32 "] %4s -> %4s (prio %3" PRIu64 ", node %4s)\n",
       e->cpu_index,
       &ex[0],
       &hr[0],




More information about the vc mailing list