Re: [PATCH v6 1/2] Update Strong APA Scheduler

2021-06-18 Thread Sebastian Huber

On 16/06/2021 08:00, Richi Dubey wrote:

This change allows for the migration of higher priority tasks on the
arrival of a lower priority task limited by affinity constraints.


Thanks, for the update. I will integrate this next week. If not, please 
send me a reminder.


--
embedded brains GmbH
Herr Sebastian HUBER
Dornierstr. 4
82178 Puchheim
Germany
email: sebastian.hu...@embedded-brains.de
phone: +49-89-18 94 741 - 16
fax:   +49-89-18 94 741 - 08

Registergericht: Amtsgericht München
Registernummer: HRB 157899
Vertretungsberechtigte Geschäftsführer: Peter Rasmussen, Thomas Dörfler
Unsere Datenschutzerklärung finden Sie hier:
https://embedded-brains.de/datenschutzerklaerung/
___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel

[PATCH v6 1/2] Update Strong APA Scheduler

2021-06-16 Thread Richi Dubey
This change allows for the migration of higher priority tasks on the
arrival of a lower priority task limited by affinity constraints.

Change license to BSD-2-Clause according to file history and
re-licensing agreement.
---
 cpukit/include/rtems/scheduler.h  |  10 +-
 .../include/rtems/score/schedulerstrongapa.h  | 162 ++-
 cpukit/score/src/schedulerstrongapa.c | 991 ++
 3 files changed, 929 insertions(+), 234 deletions(-)

diff --git a/cpukit/include/rtems/scheduler.h b/cpukit/include/rtems/scheduler.h
index 955a83cfb4..76d84fd787 100644
--- a/cpukit/include/rtems/scheduler.h
+++ b/cpukit/include/rtems/scheduler.h
@@ -251,22 +251,24 @@
 #ifdef CONFIGURE_SCHEDULER_STRONG_APA
   #include 
 
+  #ifndef CONFIGURE_MAXIMUM_PROCESSORS
+#error "CONFIGURE_MAXIMUM_PROCESSORS must be defined to configure the 
Strong APA scheduler"
+  #endif
+
   #define SCHEDULER_STRONG_APA_CONTEXT_NAME( name ) \
 SCHEDULER_CONTEXT_NAME( strong_APA_ ## name )
 
   #define RTEMS_SCHEDULER_STRONG_APA( name, prio_count ) \
 static struct { \
   Scheduler_strong_APA_Context Base; \
-  Chain_ControlReady[ ( prio_count ) ]; \
+  Scheduler_strong_APA_CPU CPU[ CONFIGURE_MAXIMUM_PROCESSORS ]; \
 } SCHEDULER_STRONG_APA_CONTEXT_NAME( name )
 
   #define RTEMS_SCHEDULER_TABLE_STRONG_APA( name, obj_name ) \
 { \
   _STRONG_APA_CONTEXT_NAME( name ).Base.Base.Base, \
   SCHEDULER_STRONG_APA_ENTRY_POINTS, \
-  RTEMS_ARRAY_SIZE( \
-SCHEDULER_STRONG_APA_CONTEXT_NAME( name ).Ready \
-  ) - 1, \
+  SCHEDULER_STRONG_APA_MAXIMUM_PRIORITY, \
   ( obj_name ) \
   SCHEDULER_CONTROL_IS_NON_PREEMPT_MODE_SUPPORTED( false ) \
 }
diff --git a/cpukit/include/rtems/score/schedulerstrongapa.h 
b/cpukit/include/rtems/score/schedulerstrongapa.h
index 530eadc279..acbeb7893a 100644
--- a/cpukit/include/rtems/score/schedulerstrongapa.h
+++ b/cpukit/include/rtems/score/schedulerstrongapa.h
@@ -8,30 +8,46 @@
  */
 
 /*
- * Copyright (c) 2013, 2018 embedded brains GmbH.  All rights reserved.
+ * SPDX-License-Identifier: BSD-2-Clause
  *
- *  embedded brains GmbH
- *  Dornierstr. 4
- *  82178 Puchheim
- *  Germany
- *  
+ * Copyright (C) 2020 Richi Dubey
+ * Copyright (c) 2013, 2018 embedded brains GmbH
  *
- * 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.
+ * 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.
  */
 
 #ifndef _RTEMS_SCORE_SCHEDULERSTRONGAPA_H
 #define _RTEMS_SCORE_SCHEDULERSTRONGAPA_H
 
 #include 
-#include 
 #include 
 
 #ifdef __cplusplus
 extern "C" {
 #endif /* __cplusplus */
 
+/* Forward Declaration of Per_CPU_Control */
+struct Per_CPU_Control;
+
 /**
  * @defgroup RTEMSScoreSchedulerStrongAPA Strong APA Scheduler
  *
@@ -39,42 +55,95 @@ extern "C" {
  *
  * @brief This group contains the Strong APA Scheduler implementation.
  *
- * This is an implementation of the global fixed priority scheduler (G-FP).  It
- * uses one ready chain per priority to ensure constant time insert operations.
- * The scheduled chain uses linear insert operations and has at most processor
- * count entries.  Since the processor and priority count are constants all
- * scheduler operations complete in a bounded execution time.
- *
- * The the_thread preempt mode will be ignored.
+ * This is an implementation of the Strong APA scheduler defined by
+ * Cerqueira et al. in Linux's Processor Affinity API, Refined:
+ * Shifting Real-Time Tasks Towards Higher Schedulability.
  *
+ * The scheduled and ready nodes are accessed via the
+ * Scheduler_strong_APA_Context::Ready which helps in backtracking when a
+