[PATCH 1/4] score: Add

2016-11-04 Thread Sebastian Huber
The aim of this file is to encapsulate CPU port implementation details.
This helps to hide implementation details from  which
indirectly includes .
---
 cpukit/score/cpu/arm/Makefile.am|  1 +
 cpukit/score/cpu/arm/preinstall.am  |  4 
 cpukit/score/cpu/arm/rtems/score/cpuimpl.h  | 30 +
 cpukit/score/cpu/bfin/Makefile.am   |  1 +
 cpukit/score/cpu/bfin/preinstall.am |  4 
 cpukit/score/cpu/bfin/rtems/score/cpuimpl.h | 30 +
 cpukit/score/cpu/epiphany/Makefile.am   |  1 +
 cpukit/score/cpu/epiphany/preinstall.am |  4 
 cpukit/score/cpu/epiphany/rtems/score/cpuimpl.h | 30 +
 cpukit/score/cpu/i386/Makefile.am   |  1 +
 cpukit/score/cpu/i386/preinstall.am |  4 
 cpukit/score/cpu/i386/rtems/score/cpuimpl.h | 30 +
 cpukit/score/cpu/lm32/Makefile.am   |  1 +
 cpukit/score/cpu/lm32/preinstall.am |  4 
 cpukit/score/cpu/lm32/rtems/score/cpuimpl.h | 30 +
 cpukit/score/cpu/m32c/Makefile.am   |  1 +
 cpukit/score/cpu/m32c/preinstall.am |  4 
 cpukit/score/cpu/m32c/rtems/score/cpuimpl.h | 30 +
 cpukit/score/cpu/m68k/Makefile.am   |  1 +
 cpukit/score/cpu/m68k/preinstall.am |  4 
 cpukit/score/cpu/m68k/rtems/score/cpuimpl.h | 30 +
 cpukit/score/cpu/mips/Makefile.am   |  1 +
 cpukit/score/cpu/mips/preinstall.am |  4 
 cpukit/score/cpu/mips/rtems/score/cpuimpl.h | 30 +
 cpukit/score/cpu/moxie/Makefile.am  |  1 +
 cpukit/score/cpu/moxie/preinstall.am|  4 
 cpukit/score/cpu/moxie/rtems/score/cpuimpl.h| 30 +
 cpukit/score/cpu/nios2/Makefile.am  |  1 +
 cpukit/score/cpu/nios2/preinstall.am|  4 
 cpukit/score/cpu/nios2/rtems/score/cpuimpl.h| 30 +
 cpukit/score/cpu/no_cpu/Makefile.am |  1 +
 cpukit/score/cpu/no_cpu/preinstall.am   |  4 
 cpukit/score/cpu/no_cpu/rtems/score/cpuimpl.h   | 30 +
 cpukit/score/cpu/or1k/Makefile.am   |  1 +
 cpukit/score/cpu/or1k/preinstall.am |  4 
 cpukit/score/cpu/or1k/rtems/score/cpuimpl.h | 30 +
 cpukit/score/cpu/powerpc/Makefile.am|  1 +
 cpukit/score/cpu/powerpc/preinstall.am  |  4 
 cpukit/score/cpu/powerpc/rtems/score/cpuimpl.h  | 30 +
 cpukit/score/cpu/sh/Makefile.am |  1 +
 cpukit/score/cpu/sh/preinstall.am   |  4 
 cpukit/score/cpu/sh/rtems/score/cpuimpl.h   | 30 +
 cpukit/score/cpu/sparc/Makefile.am  |  1 +
 cpukit/score/cpu/sparc/preinstall.am|  4 
 cpukit/score/cpu/sparc/rtems/score/cpuimpl.h| 30 +
 cpukit/score/cpu/sparc64/Makefile.am|  1 +
 cpukit/score/cpu/sparc64/preinstall.am  |  4 
 cpukit/score/cpu/sparc64/rtems/score/cpuimpl.h  | 30 +
 cpukit/score/cpu/v850/Makefile.am   |  1 +
 cpukit/score/cpu/v850/preinstall.am |  4 
 cpukit/score/cpu/v850/rtems/score/cpuimpl.h | 30 +
 51 files changed, 595 insertions(+)
 create mode 100644 cpukit/score/cpu/arm/rtems/score/cpuimpl.h
 create mode 100644 cpukit/score/cpu/bfin/rtems/score/cpuimpl.h
 create mode 100644 cpukit/score/cpu/epiphany/rtems/score/cpuimpl.h
 create mode 100644 cpukit/score/cpu/i386/rtems/score/cpuimpl.h
 create mode 100644 cpukit/score/cpu/lm32/rtems/score/cpuimpl.h
 create mode 100644 cpukit/score/cpu/m32c/rtems/score/cpuimpl.h
 create mode 100644 cpukit/score/cpu/m68k/rtems/score/cpuimpl.h
 create mode 100644 cpukit/score/cpu/mips/rtems/score/cpuimpl.h
 create mode 100644 cpukit/score/cpu/moxie/rtems/score/cpuimpl.h
 create mode 100644 cpukit/score/cpu/nios2/rtems/score/cpuimpl.h
 create mode 100644 cpukit/score/cpu/no_cpu/rtems/score/cpuimpl.h
 create mode 100644 cpukit/score/cpu/or1k/rtems/score/cpuimpl.h
 create mode 100644 cpukit/score/cpu/powerpc/rtems/score/cpuimpl.h
 create mode 100644 cpukit/score/cpu/sh/rtems/score/cpuimpl.h
 create mode 100644 cpukit/score/cpu/sparc/rtems/score/cpuimpl.h
 create mode 100644 cpukit/score/cpu/sparc64/rtems/score/cpuimpl.h
 create mode 100644 cpukit/score/cpu/v850/rtems/score/cpuimpl.h

diff --git a/cpukit/score/cpu/arm/Makefile.am b/cpukit/score/cpu/arm/Makefile.am
index 4b242f0..33372a2 100644
--- a/cpukit/score/cpu/arm/Makefile.am
+++ b/cpukit/score/cpu/arm/Makefile.am
@@ -4,6 +4,7 @@ include_rtems_HEADERS = rtems/asm.h
 
 include_rtems_scoredir = $(includedir)/rtems/score
 include_rtems_score_HEADERS = rtems/score/cpu.h
+include_rtems_score_HEADERS += rtems/score/cpuimp

[PATCH 4/4] sparc: Provide _CPU_Get_thread_executing()

2016-11-04 Thread Sebastian Huber
---
 cpukit/score/cpu/sparc/rtems/score/cpuimpl.h | 4 
 1 file changed, 4 insertions(+)

diff --git a/cpukit/score/cpu/sparc/rtems/score/cpuimpl.h 
b/cpukit/score/cpu/sparc/rtems/score/cpuimpl.h
index 6b8b601..5373db1 100644
--- a/cpukit/score/cpu/sparc/rtems/score/cpuimpl.h
+++ b/cpukit/score/cpu/sparc/rtems/score/cpuimpl.h
@@ -5,6 +5,8 @@
  */
 
 /*
+ * Copyright (c) 2016 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.
@@ -21,6 +23,8 @@
 extern "C" {
 #endif
 
+#define _CPU_Get_thread_executing() ( _SPARC_Per_CPU_current->executing )
+
 #ifdef __cplusplus
 }
 #endif
-- 
1.8.4.5

___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel


[PATCH 2/4] score: Prevent assignment to _Thread_Executing

2016-11-04 Thread Sebastian Huber
---
 cpukit/score/include/rtems/score/percpu.h |  2 +-
 testsuites/tmtests/tm26/task1.c   | 12 +---
 testsuites/tmtests/tm27/task1.c   | 15 +++
 3 files changed, 13 insertions(+), 16 deletions(-)

diff --git a/cpukit/score/include/rtems/score/percpu.h 
b/cpukit/score/include/rtems/score/percpu.h
index 066bf4c..1ccbc3b 100644
--- a/cpukit/score/include/rtems/score/percpu.h
+++ b/cpukit/score/include/rtems/score/percpu.h
@@ -688,7 +688,7 @@ bool _Per_CPU_State_wait_for_non_initial_state(
 #define _Thread_Heir \
   _Per_CPU_Get()->heir
 #define _Thread_Executing \
-  _Per_CPU_Get()->executing
+  _Per_CPU_Get_executing( _Per_CPU_Get() )
 #define _ISR_Nest_level \
   _Per_CPU_Get()->isr_nest_level
 #define _CPU_Interrupt_stack_low \
diff --git a/testsuites/tmtests/tm26/task1.c b/testsuites/tmtests/tm26/task1.c
index 173cf7f..9d157e9 100644
--- a/testsuites/tmtests/tm26/task1.c
+++ b/testsuites/tmtests/tm26/task1.c
@@ -123,17 +123,7 @@ static void set_thread_heir( Thread_Control *thread )
 
 static void set_thread_executing( Thread_Control *thread )
 {
-#if defined( PREVENT_SMP_ASSERT_FAILURES )
-  ISR_Level level;
-
-  _ISR_Local_disable( level );
-#endif
-
-  _Thread_Executing = thread;
-
-#if defined( PREVENT_SMP_ASSERT_FAILURES )
-  _ISR_Local_enable( level );
-#endif
+  _Per_CPU_Get_snapshot()->executing = thread;
 }
 
 static void thread_resume( Thread_Control *thread )
diff --git a/testsuites/tmtests/tm27/task1.c b/testsuites/tmtests/tm27/task1.c
index 9126391..c89c095 100644
--- a/testsuites/tmtests/tm27/task1.c
+++ b/testsuites/tmtests/tm27/task1.c
@@ -46,6 +46,11 @@ rtems_isr Isr_handler(
   rtems_vector_number vector
 );
 
+static void set_thread_executing( Thread_Control *thread )
+{
+  _Per_CPU_Get_snapshot()->executing = thread;
+}
+
 rtems_task Init(
   rtems_task_argument argument
 )
@@ -191,8 +196,9 @@ rtems_task Task_1(
   _ISR_Local_disable(level);
 #endif
 
-  _Thread_Executing =
-(Thread_Control *) 
_Chain_First(&scheduler_context->Ready[LOW_PRIORITY]);
+  set_thread_executing(
+(Thread_Control *) _Chain_First(&scheduler_context->Ready[LOW_PRIORITY])
+  );
 
   _Thread_Dispatch_necessary = 1;
 
@@ -265,8 +271,9 @@ rtems_task Task_2(
   _Thread_State_acquire( executing, &state_lock_context );
   _Scheduler_Acquire_critical( scheduler, &scheduler_lock_context );
 
-  _Thread_Executing =
-(Thread_Control *) 
_Chain_First(&scheduler_context->Ready[LOW_PRIORITY]);
+  set_thread_executing(
+(Thread_Control *) _Chain_First(&scheduler_context->Ready[LOW_PRIORITY])
+  );
 
   _Thread_Dispatch_necessary = 1;
 
-- 
1.8.4.5

___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel


[PATCH 3/4] score: Add optional _CPU_Get_thread_executing()

2016-11-04 Thread Sebastian Huber
---
 cpukit/score/cpu/no_cpu/rtems/score/cpuimpl.h | 12 
 cpukit/score/include/rtems/score/percpu.h | 18 +-
 cpukit/score/src/threadhandler.c  |  3 ++-
 3 files changed, 27 insertions(+), 6 deletions(-)

diff --git a/cpukit/score/cpu/no_cpu/rtems/score/cpuimpl.h 
b/cpukit/score/cpu/no_cpu/rtems/score/cpuimpl.h
index 6b8b601..7c7f71a 100644
--- a/cpukit/score/cpu/no_cpu/rtems/score/cpuimpl.h
+++ b/cpukit/score/cpu/no_cpu/rtems/score/cpuimpl.h
@@ -5,6 +5,8 @@
  */
 
 /*
+ * Copyright (c) 2016 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.
@@ -21,6 +23,16 @@
 extern "C" {
 #endif
 
+/**
+ * @brief Optional method to get the executing thread.
+ *
+ * This is optional.  Not every CPU port needs this.  It is only an optional
+ * optimization variant.  In case this macro is undefined, the default
+ * implementation using the per-CPU information and the current processor index
+ * will be used to get the executing thread.
+ */
+#define _CPU_Get_thread_executing() ( _CPU_Per_CPU_current->executing )
+
 #ifdef __cplusplus
 }
 #endif
diff --git a/cpukit/score/include/rtems/score/percpu.h 
b/cpukit/score/include/rtems/score/percpu.h
index 1ccbc3b..490a223 100644
--- a/cpukit/score/include/rtems/score/percpu.h
+++ b/cpukit/score/include/rtems/score/percpu.h
@@ -17,7 +17,7 @@
 #ifndef _RTEMS_PERCPU_H
 #define _RTEMS_PERCPU_H
 
-#include 
+#include 
 
 #if defined( ASM )
   #include 
@@ -687,8 +687,15 @@ bool _Per_CPU_State_wait_for_non_initial_state(
   _Per_CPU_Get()->thread_dispatch_disable_level
 #define _Thread_Heir \
   _Per_CPU_Get()->heir
+
+#if defined(_CPU_Get_thread_executing)
+#define _Thread_Executing \
+  _CPU_Get_thread_executing()
+#else
 #define _Thread_Executing \
   _Per_CPU_Get_executing( _Per_CPU_Get() )
+#endif
+
 #define _ISR_Nest_level \
   _Per_CPU_Get()->isr_nest_level
 #define _CPU_Interrupt_stack_low \
@@ -701,9 +708,10 @@ bool _Per_CPU_State_wait_for_non_initial_state(
 /**
  * @brief Returns the thread control block of the executing thread.
  *
- * This function can be called in any context.  On SMP configurations
+ * This function can be called in any thread context.  On SMP configurations,
  * interrupts are disabled to ensure that the processor index is used
- * consistently.
+ * consistently if no CPU port specific method is available to get the
+ * executing thread.
  *
  * @return The thread control block of the executing thread.
  */
@@ -711,7 +719,7 @@ RTEMS_INLINE_ROUTINE struct _Thread_Control 
*_Thread_Get_executing( void )
 {
   struct _Thread_Control *executing;
 
-  #if defined( RTEMS_SMP )
+  #if defined(RTEMS_SMP) && !defined(_CPU_Get_thread_executing)
 ISR_Level level;
 
 _ISR_Local_disable( level );
@@ -719,7 +727,7 @@ RTEMS_INLINE_ROUTINE struct _Thread_Control 
*_Thread_Get_executing( void )
 
   executing = _Thread_Executing;
 
-  #if defined( RTEMS_SMP )
+  #if defined(RTEMS_SMP) && !defined(_CPU_Get_thread_executing)
 _ISR_Local_enable( level );
   #endif
 
diff --git a/cpukit/score/src/threadhandler.c b/cpukit/score/src/threadhandler.c
index 5d33f43..397e0cf 100644
--- a/cpukit/score/src/threadhandler.c
+++ b/cpukit/score/src/threadhandler.c
@@ -26,7 +26,7 @@
 
 void _Thread_Handler( void )
 {
-  Thread_Control  *executing = _Thread_Executing;
+  Thread_Control  *executing;
   ISR_Levellevel;
   Per_CPU_Control *cpu_self;
 
@@ -36,6 +36,7 @@ void _Thread_Handler( void )
* hook point where the port gets a shot at doing whatever it requires.
*/
   _Context_Initialization_at_thread_begin();
+  executing = _Thread_Executing;
 
   /* On SMP we enter _Thread_Handler() with interrupts disabled */
   _SMP_Assert( _ISR_Get_level() != 0 );
-- 
1.8.4.5

___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel


Re: Building All Output Formats for RTEMS Docs

2016-11-04 Thread Joel Sherrill
On Fri, Nov 4, 2016 at 1:35 AM, Sebastian Huber <
sebastian.hu...@embedded-brains.de> wrote:

> Hello Chris,
>
> works fine on openSUSE 13.1. I installed a couple of texinfo packages and
> did a "pip install -U Sphinx".
>
> Chris was trying on one of our CentOS 7 machines. I tried on a Fedora 23
machine and it had the same issue. CentOS 6 appears to be the same.

I am happy to test if you put something together. The docs being
challenging to build is not good.

I checked and Fedora is only at 24. We usually alternate versions for Fedora
so we aren't on a treadmill. I don't expect any differences.

--joel


> --
> Sebastian Huber, embedded brains GmbH
>
> Address : Dornierstr. 4, D-82178 Puchheim, Germany
> Phone   : +49 89 189 47 41-16
> Fax : +49 89 189 47 41-09
> E-Mail  : sebastian.hu...@embedded-brains.de
> PGP : Public key available on request.
>
> Diese Nachricht ist keine geschäftliche Mitteilung im Sinne des EHUG.
>
>
> ___
> devel mailing list
> devel@rtems.org
> http://lists.rtems.org/mailman/listinfo/devel
>
___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel

Re: [PATCH 1/4] score: Add

2016-11-04 Thread Gedare Bloom
This will need mention in the porting guide.

On Fri, Nov 4, 2016 at 9:08 AM, Sebastian Huber
 wrote:
> The aim of this file is to encapsulate CPU port implementation details.
> This helps to hide implementation details from  which
> indirectly includes .
> ---
>  cpukit/score/cpu/arm/Makefile.am|  1 +
>  cpukit/score/cpu/arm/preinstall.am  |  4 
>  cpukit/score/cpu/arm/rtems/score/cpuimpl.h  | 30 
> +
>  cpukit/score/cpu/bfin/Makefile.am   |  1 +
>  cpukit/score/cpu/bfin/preinstall.am |  4 
>  cpukit/score/cpu/bfin/rtems/score/cpuimpl.h | 30 
> +
>  cpukit/score/cpu/epiphany/Makefile.am   |  1 +
>  cpukit/score/cpu/epiphany/preinstall.am |  4 
>  cpukit/score/cpu/epiphany/rtems/score/cpuimpl.h | 30 
> +
>  cpukit/score/cpu/i386/Makefile.am   |  1 +
>  cpukit/score/cpu/i386/preinstall.am |  4 
>  cpukit/score/cpu/i386/rtems/score/cpuimpl.h | 30 
> +
>  cpukit/score/cpu/lm32/Makefile.am   |  1 +
>  cpukit/score/cpu/lm32/preinstall.am |  4 
>  cpukit/score/cpu/lm32/rtems/score/cpuimpl.h | 30 
> +
>  cpukit/score/cpu/m32c/Makefile.am   |  1 +
>  cpukit/score/cpu/m32c/preinstall.am |  4 
>  cpukit/score/cpu/m32c/rtems/score/cpuimpl.h | 30 
> +
>  cpukit/score/cpu/m68k/Makefile.am   |  1 +
>  cpukit/score/cpu/m68k/preinstall.am |  4 
>  cpukit/score/cpu/m68k/rtems/score/cpuimpl.h | 30 
> +
>  cpukit/score/cpu/mips/Makefile.am   |  1 +
>  cpukit/score/cpu/mips/preinstall.am |  4 
>  cpukit/score/cpu/mips/rtems/score/cpuimpl.h | 30 
> +
>  cpukit/score/cpu/moxie/Makefile.am  |  1 +
>  cpukit/score/cpu/moxie/preinstall.am|  4 
>  cpukit/score/cpu/moxie/rtems/score/cpuimpl.h| 30 
> +
>  cpukit/score/cpu/nios2/Makefile.am  |  1 +
>  cpukit/score/cpu/nios2/preinstall.am|  4 
>  cpukit/score/cpu/nios2/rtems/score/cpuimpl.h| 30 
> +
>  cpukit/score/cpu/no_cpu/Makefile.am |  1 +
>  cpukit/score/cpu/no_cpu/preinstall.am   |  4 
>  cpukit/score/cpu/no_cpu/rtems/score/cpuimpl.h   | 30 
> +
>  cpukit/score/cpu/or1k/Makefile.am   |  1 +
>  cpukit/score/cpu/or1k/preinstall.am |  4 
>  cpukit/score/cpu/or1k/rtems/score/cpuimpl.h | 30 
> +
>  cpukit/score/cpu/powerpc/Makefile.am|  1 +
>  cpukit/score/cpu/powerpc/preinstall.am  |  4 
>  cpukit/score/cpu/powerpc/rtems/score/cpuimpl.h  | 30 
> +
>  cpukit/score/cpu/sh/Makefile.am |  1 +
>  cpukit/score/cpu/sh/preinstall.am   |  4 
>  cpukit/score/cpu/sh/rtems/score/cpuimpl.h   | 30 
> +
>  cpukit/score/cpu/sparc/Makefile.am  |  1 +
>  cpukit/score/cpu/sparc/preinstall.am|  4 
>  cpukit/score/cpu/sparc/rtems/score/cpuimpl.h| 30 
> +
>  cpukit/score/cpu/sparc64/Makefile.am|  1 +
>  cpukit/score/cpu/sparc64/preinstall.am  |  4 
>  cpukit/score/cpu/sparc64/rtems/score/cpuimpl.h  | 30 
> +
>  cpukit/score/cpu/v850/Makefile.am   |  1 +
>  cpukit/score/cpu/v850/preinstall.am |  4 
>  cpukit/score/cpu/v850/rtems/score/cpuimpl.h | 30 
> +
>  51 files changed, 595 insertions(+)
>  create mode 100644 cpukit/score/cpu/arm/rtems/score/cpuimpl.h
>  create mode 100644 cpukit/score/cpu/bfin/rtems/score/cpuimpl.h
>  create mode 100644 cpukit/score/cpu/epiphany/rtems/score/cpuimpl.h
>  create mode 100644 cpukit/score/cpu/i386/rtems/score/cpuimpl.h
>  create mode 100644 cpukit/score/cpu/lm32/rtems/score/cpuimpl.h
>  create mode 100644 cpukit/score/cpu/m32c/rtems/score/cpuimpl.h
>  create mode 100644 cpukit/score/cpu/m68k/rtems/score/cpuimpl.h
>  create mode 100644 cpukit/score/cpu/mips/rtems/score/cpuimpl.h
>  create mode 100644 cpukit/score/cpu/moxie/rtems/score/cpuimpl.h
>  create mode 100644 cpukit/score/cpu/nios2/rtems/score/cpuimpl.h
>  create mode 100644 cpukit/score/cpu/no_cpu/rtems/score/cpuimpl.h
>  create mode 100644 cpukit/score/cpu/or1k/rtems/score/cpuimpl.h
>  create mode 100644 cpukit/score/cpu/powerpc/rtems/score/cpuimpl.h
>  create mode 100644 cpukit/score/cpu/sh/rtems/score/cpuimpl.h
>  create mode 100644 cpukit/score/cpu/sparc/rtems/score/cpuimpl.h
>  create mode 100644 cpukit/score/cpu/sparc64/rtems/score/cpuimpl.h
>  create mode 100644 cpukit/score/cpu/v850/rtems/score/cpuimpl.h
>
> diff --git a/cpukit/score/cpu/arm/Makefile.am 
> b/cpukit/score/cpu/arm/Makefile.am
> index 

Re: [PATCH 2/4] score: Prevent assignment to _Thread_Executing

2016-11-04 Thread Gedare Bloom
On Fri, Nov 4, 2016 at 9:08 AM, Sebastian Huber
 wrote:
> ---
>  cpukit/score/include/rtems/score/percpu.h |  2 +-
>  testsuites/tmtests/tm26/task1.c   | 12 +---
>  testsuites/tmtests/tm27/task1.c   | 15 +++
>  3 files changed, 13 insertions(+), 16 deletions(-)
>
> diff --git a/cpukit/score/include/rtems/score/percpu.h 
> b/cpukit/score/include/rtems/score/percpu.h
> index 066bf4c..1ccbc3b 100644
> --- a/cpukit/score/include/rtems/score/percpu.h
> +++ b/cpukit/score/include/rtems/score/percpu.h
> @@ -688,7 +688,7 @@ bool _Per_CPU_State_wait_for_non_initial_state(
>  #define _Thread_Heir \
>_Per_CPU_Get()->heir
>  #define _Thread_Executing \
> -  _Per_CPU_Get()->executing
> +  _Per_CPU_Get_executing( _Per_CPU_Get() )
>  #define _ISR_Nest_level \
>_Per_CPU_Get()->isr_nest_level
>  #define _CPU_Interrupt_stack_low \
> diff --git a/testsuites/tmtests/tm26/task1.c b/testsuites/tmtests/tm26/task1.c
> index 173cf7f..9d157e9 100644
> --- a/testsuites/tmtests/tm26/task1.c
> +++ b/testsuites/tmtests/tm26/task1.c
> @@ -123,17 +123,7 @@ static void set_thread_heir( Thread_Control *thread )
>
>  static void set_thread_executing( Thread_Control *thread )
>  {
> -#if defined( PREVENT_SMP_ASSERT_FAILURES )
> -  ISR_Level level;
> -
> -  _ISR_Local_disable( level );
> -#endif
> -
> -  _Thread_Executing = thread;
> -
> -#if defined( PREVENT_SMP_ASSERT_FAILURES )
> -  _ISR_Local_enable( level );
> -#endif
> +  _Per_CPU_Get_snapshot()->executing = thread;
Normally one thinks of a snapshot as a read-only kind of thing, like a
picture. So I was a little confused by this terminology--for some
reason I hadn't noticed this _Per_CPU_Get_snapshot() before now.

>  }
>
>  static void thread_resume( Thread_Control *thread )
> diff --git a/testsuites/tmtests/tm27/task1.c b/testsuites/tmtests/tm27/task1.c
> index 9126391..c89c095 100644
> --- a/testsuites/tmtests/tm27/task1.c
> +++ b/testsuites/tmtests/tm27/task1.c
> @@ -46,6 +46,11 @@ rtems_isr Isr_handler(
>rtems_vector_number vector
>  );
>
> +static void set_thread_executing( Thread_Control *thread )
> +{
> +  _Per_CPU_Get_snapshot()->executing = thread;
> +}
> +
>  rtems_task Init(
>rtems_task_argument argument
>  )
> @@ -191,8 +196,9 @@ rtems_task Task_1(
>_ISR_Local_disable(level);
>  #endif
>
> -  _Thread_Executing =
> -(Thread_Control *) 
> _Chain_First(&scheduler_context->Ready[LOW_PRIORITY]);
> +  set_thread_executing(
> +(Thread_Control *) _Chain_First(&scheduler_context->Ready[LOW_PRIORITY])
> +  );
>
>_Thread_Dispatch_necessary = 1;
>
> @@ -265,8 +271,9 @@ rtems_task Task_2(
>_Thread_State_acquire( executing, &state_lock_context );
>_Scheduler_Acquire_critical( scheduler, &scheduler_lock_context );
>
> -  _Thread_Executing =
> -(Thread_Control *) 
> _Chain_First(&scheduler_context->Ready[LOW_PRIORITY]);
> +  set_thread_executing(
> +(Thread_Control *) _Chain_First(&scheduler_context->Ready[LOW_PRIORITY])
> +  );
>
>_Thread_Dispatch_necessary = 1;
>
> --
> 1.8.4.5
>
> ___
> devel mailing list
> devel@rtems.org
> http://lists.rtems.org/mailman/listinfo/devel
___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel


Re: [PATCH 2/4] score: Prevent assignment to _Thread_Executing

2016-11-04 Thread Sebastian Huber

- Gedare Bloom  schrieb:
> On Fri, Nov 4, 2016 at 9:08 AM, Sebastian Huber
>  wrote:
> > ---
> >  cpukit/score/include/rtems/score/percpu.h |  2 +-
> >  testsuites/tmtests/tm26/task1.c   | 12 +---
> >  testsuites/tmtests/tm27/task1.c   | 15 +++
> >  3 files changed, 13 insertions(+), 16 deletions(-)
> >
> > diff --git a/cpukit/score/include/rtems/score/percpu.h 
> > b/cpukit/score/include/rtems/score/percpu.h
> > index 066bf4c..1ccbc3b 100644
> > --- a/cpukit/score/include/rtems/score/percpu.h
> > +++ b/cpukit/score/include/rtems/score/percpu.h
> > @@ -688,7 +688,7 @@ bool _Per_CPU_State_wait_for_non_initial_state(
> >  #define _Thread_Heir \
> >_Per_CPU_Get()->heir
> >  #define _Thread_Executing \
> > -  _Per_CPU_Get()->executing
> > +  _Per_CPU_Get_executing( _Per_CPU_Get() )
> >  #define _ISR_Nest_level \
> >_Per_CPU_Get()->isr_nest_level
> >  #define _CPU_Interrupt_stack_low \
> > diff --git a/testsuites/tmtests/tm26/task1.c 
> > b/testsuites/tmtests/tm26/task1.c
> > index 173cf7f..9d157e9 100644
> > --- a/testsuites/tmtests/tm26/task1.c
> > +++ b/testsuites/tmtests/tm26/task1.c
> > @@ -123,17 +123,7 @@ static void set_thread_heir( Thread_Control *thread )
> >
> >  static void set_thread_executing( Thread_Control *thread )
> >  {
> > -#if defined( PREVENT_SMP_ASSERT_FAILURES )
> > -  ISR_Level level;
> > -
> > -  _ISR_Local_disable( level );
> > -#endif
> > -
> > -  _Thread_Executing = thread;
> > -
> > -#if defined( PREVENT_SMP_ASSERT_FAILURES )
> > -  _ISR_Local_enable( level );
> > -#endif
> > +  _Per_CPU_Get_snapshot()->executing = thread;
> Normally one thinks of a snapshot as a read-only kind of thing, like a
> picture. So I was a little confused by this terminology--for some
> reason I hadn't noticed this _Per_CPU_Get_snapshot() before now.

Its good that you didn't notice this before, since it should be rarely used:

/*
 * If we get the current processor index in a context which allows thread
 * dispatching, then we may already run on another processor right after the
 * read instruction.  There are very few cases in which this makes sense (here
 * we can use _Per_CPU_Get_snapshot()).  All other places must use
 * _Per_CPU_Get() so that we can add checks for RTEMS_DEBUG.
 */
#if defined( _CPU_Get_current_per_CPU_control )
  #define _Per_CPU_Get_snapshot() _CPU_Get_current_per_CPU_control()
#else
  #define _Per_CPU_Get_snapshot() \
( &_Per_CPU_Information[ _SMP_Get_current_processor() ].per_cpu )
#endif

-- 
Sebastian Huber, embedded brains GmbH

Address : Dornierstr. 4, D-82178 Puchheim, Germany
Phone   : +49 89 189 47 41-16
Fax : +49 89 189 47 41-09
E-Mail  : sebastian.huber at embedded-brains.de
PGP : Public key available on request.

Diese Nachricht ist keine geschäftliche Mitteilung im Sinne des EHUG.
___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel