[rtems commit] score: Provide two thread pin/unpin defaults

Sebastian Huber sebh at rtems.org
Tue Sep 21 08:25:31 UTC 2021


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

Author:    Sebastian Huber <sebastian.huber at embedded-brains.de>
Date:      Fri Sep 17 08:12:35 2021 +0200

score: Provide two thread pin/unpin defaults

The uniprocessor schedulers do not support systems with more than more
processors.  So they rivially support thread pinning and thus the
SMP_FATAL_SCHEDULER_PIN_OR_UNPIN_NOT_SUPPORTED cannot happen.

Add a second default implementation for SMP schedulers which do not
support thread pinning.

Change license to BSD-2-Clause according to file history and re-licensing
agreement.

Update #3053.

---

 cpukit/include/rtems/score/scheduler.h             | 27 +++++++++--
 .../rtems/score/schedulerpriorityaffinitysmp.h     |  4 +-
 cpukit/include/rtems/score/schedulerprioritysmp.h  |  4 +-
 cpukit/include/rtems/score/schedulersimplesmp.h    |  4 +-
 cpukit/include/rtems/score/schedulerstrongapa.h    |  4 +-
 cpukit/score/src/schedulerdefaultpinunpin.c        | 31 ++++++++++---
 .../score/src/schedulerdefaultpinunpindonothing.c  | 54 ++++++++++++++++++++++
 spec/build/cpukit/objsmp.yml                       |  1 +
 8 files changed, 112 insertions(+), 17 deletions(-)

diff --git a/cpukit/include/rtems/score/scheduler.h b/cpukit/include/rtems/score/scheduler.h
index 6cb07c4..36fc1fd 100644
--- a/cpukit/include/rtems/score/scheduler.h
+++ b/cpukit/include/rtems/score/scheduler.h
@@ -444,15 +444,36 @@ Priority_Control _Scheduler_default_Unmap_priority(
   );
 
   /**
+   * @brief Does nothing.
+   *
+   * This default implementation for the thread pin or unpin operations should
+   * be used by uniprocessor schedulers if SMP support is enabled.
+   *
+   * @param scheduler This parameter is unused.
+   * @param the_thread This parameter is unused.
+   * @param node This parameter is unused.
+   * @param cpu This parameter is unused.
+   */
+  void _Scheduler_default_Pin_or_unpin_do_nothing(
+    const Scheduler_Control *scheduler,
+    Thread_Control          *the_thread,
+    Scheduler_Node          *node,
+    struct Per_CPU_Control  *cpu
+  );
+
+  /**
    * @brief Does nothing in a single processor system, otherwise a fatal error
    * is issued.
    *
+   * This default implementation for the thread pin or unpin operations should
+   * be used by SMP schedulers which do not support thread pinning.
+   *
    * @param scheduler This parameter is unused.
    * @param the_thread This parameter is unused.
    * @param node This parameter is unused.
    * @param cpu This parameter is unused.
    */
-  void _Scheduler_default_Pin_or_unpin(
+  void _Scheduler_default_Pin_or_unpin_not_supported(
     const Scheduler_Control *scheduler,
     Thread_Control          *the_thread,
     Scheduler_Node          *node,
@@ -474,8 +495,8 @@ Priority_Control _Scheduler_default_Unmap_priority(
     _Scheduler_default_Ask_for_help, \
     _Scheduler_default_Reconsider_help_request, \
     _Scheduler_default_Withdraw_node, \
-    _Scheduler_default_Pin_or_unpin, \
-    _Scheduler_default_Pin_or_unpin, \
+    _Scheduler_default_Pin_or_unpin_do_nothing, \
+    _Scheduler_default_Pin_or_unpin_do_nothing, \
     NULL, \
     NULL,
 #else
diff --git a/cpukit/include/rtems/score/schedulerpriorityaffinitysmp.h b/cpukit/include/rtems/score/schedulerpriorityaffinitysmp.h
index 772a83f..1b660fa 100644
--- a/cpukit/include/rtems/score/schedulerpriorityaffinitysmp.h
+++ b/cpukit/include/rtems/score/schedulerpriorityaffinitysmp.h
@@ -65,8 +65,8 @@ extern "C" {
     _Scheduler_priority_affinity_SMP_Ask_for_help, \
     _Scheduler_priority_affinity_SMP_Reconsider_help_request, \
     _Scheduler_priority_affinity_SMP_Withdraw_node, \
-    _Scheduler_default_Pin_or_unpin, \
-    _Scheduler_default_Pin_or_unpin, \
+    _Scheduler_default_Pin_or_unpin_not_supported, \
+    _Scheduler_default_Pin_or_unpin_not_supported, \
     _Scheduler_priority_affinity_SMP_Add_processor, \
     _Scheduler_priority_affinity_SMP_Remove_processor, \
     _Scheduler_priority_affinity_SMP_Node_initialize, \
diff --git a/cpukit/include/rtems/score/schedulerprioritysmp.h b/cpukit/include/rtems/score/schedulerprioritysmp.h
index 80979a3..56f4aa5 100644
--- a/cpukit/include/rtems/score/schedulerprioritysmp.h
+++ b/cpukit/include/rtems/score/schedulerprioritysmp.h
@@ -93,8 +93,8 @@ typedef struct {
     _Scheduler_priority_SMP_Ask_for_help, \
     _Scheduler_priority_SMP_Reconsider_help_request, \
     _Scheduler_priority_SMP_Withdraw_node, \
-    _Scheduler_default_Pin_or_unpin, \
-    _Scheduler_default_Pin_or_unpin, \
+    _Scheduler_default_Pin_or_unpin_not_supported, \
+    _Scheduler_default_Pin_or_unpin_not_supported, \
     _Scheduler_priority_SMP_Add_processor, \
     _Scheduler_priority_SMP_Remove_processor, \
     _Scheduler_priority_SMP_Node_initialize, \
diff --git a/cpukit/include/rtems/score/schedulersimplesmp.h b/cpukit/include/rtems/score/schedulersimplesmp.h
index 158bea7..961e60a 100644
--- a/cpukit/include/rtems/score/schedulersimplesmp.h
+++ b/cpukit/include/rtems/score/schedulersimplesmp.h
@@ -75,8 +75,8 @@ typedef struct {
     _Scheduler_simple_SMP_Ask_for_help, \
     _Scheduler_simple_SMP_Reconsider_help_request, \
     _Scheduler_simple_SMP_Withdraw_node, \
-    _Scheduler_default_Pin_or_unpin, \
-    _Scheduler_default_Pin_or_unpin, \
+    _Scheduler_default_Pin_or_unpin_not_supported, \
+    _Scheduler_default_Pin_or_unpin_not_supported, \
     _Scheduler_simple_SMP_Add_processor, \
     _Scheduler_simple_SMP_Remove_processor, \
     _Scheduler_simple_SMP_Node_initialize, \
diff --git a/cpukit/include/rtems/score/schedulerstrongapa.h b/cpukit/include/rtems/score/schedulerstrongapa.h
index 9ee922d..a3a19d8 100644
--- a/cpukit/include/rtems/score/schedulerstrongapa.h
+++ b/cpukit/include/rtems/score/schedulerstrongapa.h
@@ -161,8 +161,8 @@ typedef struct {
     _Scheduler_strong_APA_Ask_for_help, \
     _Scheduler_strong_APA_Reconsider_help_request, \
     _Scheduler_strong_APA_Withdraw_node, \
-    _Scheduler_default_Pin_or_unpin, \
-    _Scheduler_default_Pin_or_unpin, \
+    _Scheduler_default_Pin_or_unpin_not_supported, \
+    _Scheduler_default_Pin_or_unpin_not_supported, \
     _Scheduler_strong_APA_Add_processor, \
     _Scheduler_strong_APA_Remove_processor, \
     _Scheduler_strong_APA_Node_initialize, \
diff --git a/cpukit/score/src/schedulerdefaultpinunpin.c b/cpukit/score/src/schedulerdefaultpinunpin.c
index 4aa2169..df41a29 100644
--- a/cpukit/score/src/schedulerdefaultpinunpin.c
+++ b/cpukit/score/src/schedulerdefaultpinunpin.c
@@ -1,18 +1,37 @@
+/* SPDX-License-Identifier: BSD-2-Clause */
+
 /**
  * @file
  *
  * @ingroup RTEMSScoreScheduler
  *
  * @brief This source file contains the implementation of
- *   _Scheduler_default_Pin_or_unpin().
+ *   _Scheduler_default_Pin_or_unpin_not_supported().
  */
 
 /*
- * Copyright (c) 2018 embedded brains GmbH
+ * Copyright (C) 2018 embedded brains GmbH (http://www.embedded-brains.de)
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
  *
- * The license and distribution terms for this file may be
- * found in the file LICENSE in this distribution or at
- * http://www.rtems.org/license/LICENSE.
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
  */
 
 #ifdef HAVE_CONFIG_H
@@ -23,7 +42,7 @@
 #include <rtems/score/interr.h>
 #include <rtems/score/smpimpl.h>
 
-void _Scheduler_default_Pin_or_unpin(
+void _Scheduler_default_Pin_or_unpin_not_supported(
   const Scheduler_Control *scheduler,
   Thread_Control          *the_thread,
   Scheduler_Node          *node,
diff --git a/cpukit/score/src/schedulerdefaultpinunpindonothing.c b/cpukit/score/src/schedulerdefaultpinunpindonothing.c
new file mode 100644
index 0000000..f7bab4f
--- /dev/null
+++ b/cpukit/score/src/schedulerdefaultpinunpindonothing.c
@@ -0,0 +1,54 @@
+/* SPDX-License-Identifier: BSD-2-Clause */
+
+/**
+ * @file
+ *
+ * @ingroup RTEMSScoreScheduler
+ *
+ * @brief This source file contains the implementation of
+ *   _Scheduler_default_Pin_or_unpin_do_nothing().
+ */
+
+/*
+ * Copyright (C) 2018 embedded brains GmbH (http://www.embedded-brains.de)
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <rtems/score/scheduler.h>
+
+void _Scheduler_default_Pin_or_unpin_do_nothing(
+  const Scheduler_Control *scheduler,
+  Thread_Control          *the_thread,
+  Scheduler_Node          *node,
+  struct Per_CPU_Control  *cpu
+)
+{
+  (void) scheduler;
+  (void) the_thread;
+  (void) node;
+  (void) cpu;
+}
diff --git a/spec/build/cpukit/objsmp.yml b/spec/build/cpukit/objsmp.yml
index ef7b331..c1b0611 100644
--- a/spec/build/cpukit/objsmp.yml
+++ b/spec/build/cpukit/objsmp.yml
@@ -15,6 +15,7 @@ source:
 - cpukit/score/src/profilingsmplock.c
 - cpukit/score/src/schedulerdefaultaskforhelp.c
 - cpukit/score/src/schedulerdefaultpinunpin.c
+- cpukit/score/src/schedulerdefaultpinunpindonothing.c
 - cpukit/score/src/schedulerdefaultsetaffinity.c
 - cpukit/score/src/scheduleredfsmp.c
 - cpukit/score/src/schedulerpriorityaffinitysmp.c



More information about the vc mailing list