[PATCH 09/10] score: Add and use Thread_Control::is_idle

2016-11-08 Thread Sebastian Huber
Update #2797.
---
 c/src/lib/libbsp/shared/clockdrv_shell.h | 4 +---
 c/src/lib/libbsp/sparc/shared/timer/tlib_ckinit.c| 3 +--
 c/src/lib/libcpu/bfin/clock/clock.c  | 6 +-
 c/src/lib/libcpu/powerpc/mpc6xx/clock/c_clock.c  | 6 +-
 cpukit/score/include/rtems/score/thread.h| 2 ++
 cpukit/score/src/threadcreateidle.c  | 1 +
 testsuites/sptests/spintrcritical_support/intrcritical.c | 8 +---
 7 files changed, 8 insertions(+), 22 deletions(-)

diff --git a/c/src/lib/libbsp/shared/clockdrv_shell.h 
b/c/src/lib/libbsp/shared/clockdrv_shell.h
index 4765873..2b90fe6 100644
--- a/c/src/lib/libbsp/shared/clockdrv_shell.h
+++ b/c/src/lib/libbsp/shared/clockdrv_shell.h
@@ -139,9 +139,7 @@ rtems_isr Clock_isr(
 
   if (!rtems_configuration_is_smp_enabled()) {
 while (
-  _Thread_Heir == _Thread_Executing
-&& _Thread_Executing->Start.Entry.Kinds.Idle.entry
-  == rtems_configuration_get_idle_task()
+  _Thread_Heir == _Thread_Executing && _Thread_Executing->is_idle
 ) {
   ISR_lock_Context lock_context;
 
diff --git a/c/src/lib/libbsp/sparc/shared/timer/tlib_ckinit.c 
b/c/src/lib/libbsp/sparc/shared/timer/tlib_ckinit.c
index 58e95d1..2848f4c 100644
--- a/c/src/lib/libbsp/sparc/shared/timer/tlib_ckinit.c
+++ b/c/src/lib/libbsp/sparc/shared/timer/tlib_ckinit.c
@@ -132,8 +132,7 @@ void Clock_isr(void *arg_unused)
 #ifdef CLOCK_DRIVER_USE_FAST_IDLE
   do {
 tlib_tc_tick();
-  } while ( _Thread_Executing == _Thread_Idle &&
-  _Thread_Heir == _Thread_Executing);
+  } while ( _Thread_Heir == _Thread_Executing && _Thread_Executing->is_idle );
 
   return;
 
diff --git a/c/src/lib/libcpu/bfin/clock/clock.c 
b/c/src/lib/libcpu/bfin/clock/clock.c
index e8c078f..d46ab35 100644
--- a/c/src/lib/libcpu/bfin/clock/clock.c
+++ b/c/src/lib/libcpu/bfin/clock/clock.c
@@ -37,11 +37,7 @@ static rtems_isr clockISR(rtems_vector_number vector) {
 #if CLOCK_DRIVER_USE_FAST_IDLE
   do {
 rtems_clock_tick();
-  } while (
-_Thread_Heir == _Thread_Executing
-  && _Thread_Executing->Start.Entry.Kinds.Idle.entry
-== rtems_configuration_get_idle_task()
-  );
+  } while ( _Thread_Heir == _Thread_Executing && _Thread_Executing->is_idle );
 #else
   rtems_clock_tick();
 #endif
diff --git a/c/src/lib/libcpu/powerpc/mpc6xx/clock/c_clock.c 
b/c/src/lib/libcpu/powerpc/mpc6xx/clock/c_clock.c
index 17a6653..c9bb16c 100644
--- a/c/src/lib/libcpu/powerpc/mpc6xx/clock/c_clock.c
+++ b/c/src/lib/libcpu/powerpc/mpc6xx/clock/c_clock.c
@@ -105,11 +105,7 @@ static void clockHandler(void)
 tb = ppc_time_base();
 rtems_timecounter_tick();
 
-while (
-  _Thread_Heir == _Thread_Executing
-&& _Thread_Executing->Start.Entry.Kinds.Idle.entry
-  == rtems_configuration_get_idle_task()
-) {
+while ( _Thread_Heir == _Thread_Executing && _Thread_Executing->is_idle ) {
   tb += Clock_Decrementer_value;
   ppc_set_time_base( tb );
   rtems_timecounter_tick();
diff --git a/cpukit/score/include/rtems/score/thread.h 
b/cpukit/score/include/rtems/score/thread.h
index 7711f70..95b977e 100644
--- a/cpukit/score/include/rtems/score/thread.h
+++ b/cpukit/score/include/rtems/score/thread.h
@@ -754,6 +754,8 @@ struct _Thread_Control {
   SMP_lock_Stats Potpourri_stats;
 #endif
 
+  /** This field is true if the thread is an idle thread. */
+  bool  is_idle;
 #if defined(RTEMS_MULTIPROCESSING)
   /** This field is true if the thread is offered globally */
   bool  is_global;
diff --git a/cpukit/score/src/threadcreateidle.c 
b/cpukit/score/src/threadcreateidle.c
index 89e5d60..d8dd2b4 100644
--- a/cpukit/score/src/threadcreateidle.c
+++ b/cpukit/score/src/threadcreateidle.c
@@ -72,6 +72,7 @@ static void _Thread_Create_idle_for_CPU( Per_CPU_Control *cpu 
)
   cpu->heir  =
   cpu->executing = idle;
 
+  idle->is_idle = true;
   idle->Start.Entry.adaptor = _Thread_Entry_adaptor_idle;
   idle->Start.Entry.Kinds.Idle.entry = rtems_configuration_get_idle_task();
 
diff --git a/testsuites/sptests/spintrcritical_support/intrcritical.c 
b/testsuites/sptests/spintrcritical_support/intrcritical.c
index b831cf1..a9fcdd2 100644
--- a/testsuites/sptests/spintrcritical_support/intrcritical.c
+++ b/testsuites/sptests/spintrcritical_support/intrcritical.c
@@ -173,18 +173,12 @@ bool interrupt_critical_section_test_support_delay(void)
   return interrupt_critical_busy_wait();
 }
 
-static bool is_idle( const Thread_Control *thread )
-{
-  return thread->Start.Entry.Kinds.Idle.entry
-== rtems_configuration_get_idle_task();
-}
-
 static void thread_switch( Thread_Control *executing, Thread_Control *heir )
 {
   (void) executing;
   (void) heir;
 
-  if ( interrupt_critical.t1 == 0 && is_idle( heir ) ) {
+  if ( interrupt_critical.t1 == 0 && heir->is_idle ) {
 interrupt_critical.t1 = rtems_clock_get_

[PATCH 02/10] mpci: Use the first scheduler for MPCI

2016-11-08 Thread Sebastian Huber
Avoid use of processor index 0 which may have no scheduler assigned.
---
 cpukit/score/src/mpci.c | 2 +-
 cpukit/score/src/threadmp.c | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/cpukit/score/src/mpci.c b/cpukit/score/src/mpci.c
index 315b33d..451592c 100644
--- a/cpukit/score/src/mpci.c
+++ b/cpukit/score/src/mpci.c
@@ -152,7 +152,7 @@ static void _MPCI_Create_server( void )
   _Thread_Initialize(
 &_Thread_Internal_information,
 _MPCI_Receive_server_tcb,
-_Scheduler_Get_by_CPU_index( _SMP_Get_current_processor() ),
+&_Scheduler_Table[ 0 ],
 NULL,/* allocate the stack */
 _Stack_Minimum() +
   CPU_MPCI_RECEIVE_SERVER_EXTRA_STACK +
diff --git a/cpukit/score/src/threadmp.c b/cpukit/score/src/threadmp.c
index 9b3a477..22078a7 100644
--- a/cpukit/score/src/threadmp.c
+++ b/cpukit/score/src/threadmp.c
@@ -77,7 +77,7 @@ void _Thread_MP_Handler_initialization (
 
 proxy->Scheduler.nodes = &proxy->Scheduler_node;
 _Scheduler_Node_do_initialize(
-  _Scheduler_Get_by_CPU_index( 0 ),
+  &_Scheduler_Table[ 0 ],
   &proxy->Scheduler_node,
   (Thread_Control *) proxy,
   0
-- 
1.8.4.5

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


Add scheduler processor add/remove

2016-11-08 Thread Sebastian Huber
This patch set adds the ability to add/remove processors to/from a scheduler
instance at run-time.

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


[PATCH 03/10] score: Fix _MRSP_Initialize()

2016-11-08 Thread Sebastian Huber
The ceiling priorities must be initialized by scheduler index.  Do not
confuse it with a processor index.
---
 cpukit/score/include/rtems/score/mrspimpl.h | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/cpukit/score/include/rtems/score/mrspimpl.h 
b/cpukit/score/include/rtems/score/mrspimpl.h
index 96d88ad..6b00af4 100644
--- a/cpukit/score/include/rtems/score/mrspimpl.h
+++ b/cpukit/score/include/rtems/score/mrspimpl.h
@@ -209,13 +209,13 @@ RTEMS_INLINE_ROUTINE Status_Control _MRSP_Initialize(
   }
 
   for ( i = 0 ; i < scheduler_count ; ++i ) {
-const Scheduler_Control *scheduler_of_cpu;
+const Scheduler_Control *scheduler_of_index;
 
-scheduler_of_cpu = _Scheduler_Get_by_CPU_index( i );
+scheduler_of_index = &_Scheduler_Table[ i ];
 
-if ( scheduler != scheduler_of_cpu ) {
+if ( scheduler != scheduler_of_index ) {
   mrsp->ceiling_priorities[ i ] =
-_Scheduler_Map_priority( scheduler_of_cpu, 0 );
+_Scheduler_Map_priority( scheduler_of_index, 0 );
 } else {
   mrsp->ceiling_priorities[ i ] = ceiling_priority;
 }
-- 
1.8.4.5

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


[PATCH 01/10] rtems: Fix rtems_task_create() scheduler selection

2016-11-08 Thread Sebastian Huber
Use the home scheduler of the executing thread for the created thread.
This is in line with pthread_create().  Using the current processor may
pick up an unexpected scheduler in case of a temporary migration, e.g.
due to locking protocols.
---
 cpukit/rtems/src/taskcreate.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/cpukit/rtems/src/taskcreate.c b/cpukit/rtems/src/taskcreate.c
index e231d4a..2695382 100644
--- a/cpukit/rtems/src/taskcreate.c
+++ b/cpukit/rtems/src/taskcreate.c
@@ -90,7 +90,7 @@ rtems_status_code rtems_task_create(
 }
   }
 
-  scheduler = _Scheduler_Get_by_CPU_index( _SMP_Get_current_processor() );
+  scheduler = _Thread_Scheduler_get_home( _Thread_Get_executing() );
 
   priority = _RTEMS_Priority_To_core( scheduler, initial_priority, &valid );
   if ( !valid ) {
-- 
1.8.4.5

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


[PATCH 04/10] score: Simplify _Scheduler_Get_by_id()

2016-11-08 Thread Sebastian Huber
Avoid dead code in non-SMP configurations.  Return scheduler identifier
independent of the current processor count of the scheduler via
rtems_scheduler_ident(), since this value may change during run-time.
Check the processor count in _Scheduler_Set() under scheduler lock
protection.

Update #2797.
---
 cpukit/rtems/include/rtems/rtems/tasks.h |   2 -
 cpukit/rtems/src/schedulergetprocessorset.c  |   3 +-
 cpukit/rtems/src/schedulerident.c|   8 +-
 cpukit/rtems/src/semsetpriority.c|   3 +-
 cpukit/rtems/src/taskgetpriority.c   |   3 +-
 cpukit/rtems/src/tasksetscheduler.c  |   3 +-
 cpukit/score/include/rtems/score/schedulerimpl.h | 110 ++-
 testsuites/smptests/smpscheduler02/init.c|  11 ++-
 8 files changed, 83 insertions(+), 60 deletions(-)

diff --git a/cpukit/rtems/include/rtems/rtems/tasks.h 
b/cpukit/rtems/include/rtems/rtems/tasks.h
index 180e50e..3a94e34 100644
--- a/cpukit/rtems/include/rtems/rtems/tasks.h
+++ b/cpukit/rtems/include/rtems/rtems/tasks.h
@@ -555,8 +555,6 @@ void rtems_task_iterate(
  * @retval RTEMS_SUCCESSFUL Successful operation.
  * @retval RTEMS_INVALID_ADDRESS The @a id parameter is @c NULL.
  * @retval RTEMS_INVALID_NAME Invalid scheduler name.
- * @retval RTEMS_UNSATISFIED A scheduler with this name exists, but the
- * processor set of this scheduler is empty.
  */
 rtems_status_code rtems_scheduler_ident(
   rtems_name  name,
diff --git a/cpukit/rtems/src/schedulergetprocessorset.c 
b/cpukit/rtems/src/schedulergetprocessorset.c
index 016c368..275c563 100644
--- a/cpukit/rtems/src/schedulergetprocessorset.c
+++ b/cpukit/rtems/src/schedulergetprocessorset.c
@@ -34,7 +34,8 @@ rtems_status_code rtems_scheduler_get_processor_set(
 return RTEMS_INVALID_ADDRESS;
   }
 
-  if ( !_Scheduler_Get_by_id( scheduler_id, &scheduler ) ) {
+  scheduler = _Scheduler_Get_by_id( scheduler_id );
+  if ( scheduler == NULL ) {
 return RTEMS_INVALID_ID;
   }
 
diff --git a/cpukit/rtems/src/schedulerident.c 
b/cpukit/rtems/src/schedulerident.c
index ee18af0..5bde8de 100644
--- a/cpukit/rtems/src/schedulerident.c
+++ b/cpukit/rtems/src/schedulerident.c
@@ -36,12 +36,8 @@ rtems_status_code rtems_scheduler_ident(
   const Scheduler_Control *scheduler = &_Scheduler_Table[ i ];
 
   if ( scheduler->name == name ) {
-if ( _Scheduler_Get_processor_count( scheduler ) > 0 ) {
-  *id = _Scheduler_Build_id( i );
-  sc = RTEMS_SUCCESSFUL;
-} else {
-  sc = RTEMS_UNSATISFIED;
-}
+*id = _Scheduler_Build_id( i );
+sc = RTEMS_SUCCESSFUL;
   }
 }
   } else {
diff --git a/cpukit/rtems/src/semsetpriority.c 
b/cpukit/rtems/src/semsetpriority.c
index 37dea5d..123f627 100644
--- a/cpukit/rtems/src/semsetpriority.c
+++ b/cpukit/rtems/src/semsetpriority.c
@@ -138,7 +138,8 @@ rtems_status_code rtems_semaphore_set_priority(
 return RTEMS_INVALID_ADDRESS;
   }
 
-  if ( !_Scheduler_Get_by_id( scheduler_id, &scheduler ) ) {
+  scheduler = _Scheduler_Get_by_id( scheduler_id );
+  if ( scheduler == NULL ) {
 return RTEMS_INVALID_ID;
   }
 
diff --git a/cpukit/rtems/src/taskgetpriority.c 
b/cpukit/rtems/src/taskgetpriority.c
index b6800e2..8fb8ad3 100644
--- a/cpukit/rtems/src/taskgetpriority.c
+++ b/cpukit/rtems/src/taskgetpriority.c
@@ -36,7 +36,8 @@ rtems_status_code rtems_task_get_priority(
 return RTEMS_INVALID_ADDRESS;
   }
 
-  if ( !_Scheduler_Get_by_id( scheduler_id, &scheduler ) ) {
+  scheduler = _Scheduler_Get_by_id( scheduler_id );
+  if ( scheduler == NULL ) {
 return RTEMS_INVALID_ID;
   }
 
diff --git a/cpukit/rtems/src/tasksetscheduler.c 
b/cpukit/rtems/src/tasksetscheduler.c
index 3a860a1..f3b7143 100644
--- a/cpukit/rtems/src/tasksetscheduler.c
+++ b/cpukit/rtems/src/tasksetscheduler.c
@@ -35,7 +35,8 @@ rtems_status_code rtems_task_set_scheduler(
   Priority_Control core_priority;
   Status_Control   status;
 
-  if ( !_Scheduler_Get_by_id( scheduler_id, &scheduler ) ) {
+  scheduler = _Scheduler_Get_by_id( scheduler_id );
+  if ( scheduler == NULL ) {
 return RTEMS_INVALID_ID;
   }
 
diff --git a/cpukit/score/include/rtems/score/schedulerimpl.h 
b/cpukit/score/include/rtems/score/schedulerimpl.h
index 0abc1a0..8d804bb 100644
--- a/cpukit/score/include/rtems/score/schedulerimpl.h
+++ b/cpukit/score/include/rtems/score/schedulerimpl.h
@@ -828,18 +828,19 @@ RTEMS_INLINE_ROUTINE uint32_t _Scheduler_Get_index_by_id( 
Objects_Id id )
   return id - minimum_id;
 }
 
-RTEMS_INLINE_ROUTINE bool _Scheduler_Get_by_id(
-  Objects_Idid,
-  const Scheduler_Control **scheduler_p
+RTEMS_INLINE_ROUTINE const Scheduler_Control *_Scheduler_Get_by_id(
+  Objects_Id id
 )
 {
-  uint32_t index = _Scheduler_Get_index_by_id( id );
-  const Scheduler_Control *scheduler = &_Scheduler_Table[ index ];
+  uint32_t index;
 
-  *scheduler_p = scheduler;
+  index = _Scheduler_Get_index_by_id( id );
 
-  return

[PATCH 06/10] score: Add scheduler to per-CPU information

2016-11-08 Thread Sebastian Huber
This makes it possible to adjust the scheduler of a processor at
run-time.

Update #2797.
---
 cpukit/score/include/rtems/score/percpu.h  | 21 ++---
 cpukit/score/include/rtems/score/schedulerimpl.h   | 36 ++
 .../score/include/rtems/score/schedulersmpimpl.h   |  2 +-
 cpukit/score/src/smp.c | 10 --
 4 files changed, 41 insertions(+), 28 deletions(-)

diff --git a/cpukit/score/include/rtems/score/percpu.h 
b/cpukit/score/include/rtems/score/percpu.h
index e3be0c8..94aef1d 100644
--- a/cpukit/score/include/rtems/score/percpu.h
+++ b/cpukit/score/include/rtems/score/percpu.h
@@ -410,10 +410,23 @@ typedef struct Per_CPU_Control {
  */
 Atomic_Ulong message;
 
-/**
- * @brief The scheduler context of the scheduler owning this processor.
- */
-const struct Scheduler_Context *scheduler_context;
+struct {
+  /**
+   * @brief The scheduler control of the scheduler owning this processor.
+   *
+   * This pointer is NULL in case this processor is currently not used by a
+   * scheduler instance.
+   */
+  const struct Scheduler_Control *control;
+
+  /**
+   * @brief The scheduler context of the scheduler owning this processor.
+   *
+   * This pointer is NULL in case this processor is currently not used by a
+   * scheduler instance.
+   */
+  const struct Scheduler_Context *context;
+} Scheduler;
 
 /**
  * @brief Indicates the current state of the CPU.
diff --git a/cpukit/score/include/rtems/score/schedulerimpl.h 
b/cpukit/score/include/rtems/score/schedulerimpl.h
index 8d804bb..de9af50 100644
--- a/cpukit/score/include/rtems/score/schedulerimpl.h
+++ b/cpukit/score/include/rtems/score/schedulerimpl.h
@@ -53,28 +53,18 @@ RTEMS_INLINE_ROUTINE Scheduler_Context 
*_Scheduler_Get_context(
   return scheduler->context;
 }
 
-RTEMS_INLINE_ROUTINE const Scheduler_Control *_Scheduler_Get_by_CPU_index(
-  uint32_t cpu_index
+RTEMS_INLINE_ROUTINE const Scheduler_Control *_Scheduler_Get_by_CPU(
+  const Per_CPU_Control *cpu
 )
 {
 #if defined(RTEMS_SMP)
-  return _Scheduler_Assignments[ cpu_index ].scheduler;
+  return cpu->Scheduler.control;
 #else
-  (void) cpu_index;
-
+  (void) cpu;
   return &_Scheduler_Table[ 0 ];
 #endif
 }
 
-RTEMS_INLINE_ROUTINE const Scheduler_Control *_Scheduler_Get_by_CPU(
-  const Per_CPU_Control *cpu
-)
-{
-  uint32_t cpu_index = _Per_CPU_Get_index( cpu );
-
-  return _Scheduler_Get_by_CPU_index( cpu_index );
-}
-
 /**
  * @brief Acquires the scheduler instance inside a critical section (interrupts
  * disabled).
@@ -673,14 +663,17 @@ RTEMS_INLINE_ROUTINE bool 
_Scheduler_Should_start_processor(
 
 RTEMS_INLINE_ROUTINE bool _Scheduler_Has_processor_ownership(
   const Scheduler_Control *scheduler,
-  uint32_t cpu_index
+  uint32_t cpu_index
 )
 {
 #if defined(RTEMS_SMP)
-  const Scheduler_Assignment *assignment =
-_Scheduler_Get_assignment( cpu_index );
+  const Per_CPU_Control   *cpu;
+  const Scheduler_Control *scheduler_of_cpu;
+
+  cpu = _Per_CPU_Get_by_index( cpu_index );
+  scheduler_of_cpu = _Scheduler_Get_by_CPU( cpu );
 
-  return assignment->scheduler == scheduler;
+  return scheduler_of_cpu == scheduler;
 #else
   (void) scheduler;
   (void) cpu_index;
@@ -748,8 +741,11 @@ RTEMS_INLINE_ROUTINE bool 
_Scheduler_default_Set_affinity_body(
 
   for ( cpu_index = 0 ; cpu_index < cpu_count ; ++cpu_index ) {
 #if defined(RTEMS_SMP)
-const Scheduler_Control *scheduler_of_cpu =
-  _Scheduler_Get_by_CPU_index( cpu_index );
+const Per_CPU_Control   *cpu;
+const Scheduler_Control *scheduler_of_cpu;
+
+cpu = _Per_CPU_Get_by_index( cpu_index );
+scheduler_of_cpu = _Scheduler_Get_by_CPU( cpu );
 
 ok = ok
   && ( CPU_ISSET_S( (int) cpu_index, cpusetsize, cpuset )
diff --git a/cpukit/score/include/rtems/score/schedulersmpimpl.h 
b/cpukit/score/include/rtems/score/schedulersmpimpl.h
index b12dd5f..ece075a 100644
--- a/cpukit/score/include/rtems/score/schedulersmpimpl.h
+++ b/cpukit/score/include/rtems/score/schedulersmpimpl.h
@@ -443,7 +443,7 @@ static inline bool _Scheduler_SMP_Is_processor_owned_by_us(
   const Per_CPU_Control   *cpu
 )
 {
-  return cpu->scheduler_context == context;
+  return cpu->Scheduler.context == context;
 }
 
 static inline Thread_Control *_Scheduler_SMP_Get_idle_thread(
diff --git a/cpukit/score/src/smp.c b/cpukit/score/src/smp.c
index f383f6d..c880d7e 100644
--- a/cpukit/score/src/smp.c
+++ b/cpukit/score/src/smp.c
@@ -66,11 +66,15 @@ static void _SMP_Start_processors( uint32_t cpu_count )
 cpu->online = started;
 
 if ( started ) {
-  Scheduler_Context *context =
-_Scheduler_Get_context( assignment->scheduler );
+  const Scheduler_Control *scheduler;
+  Scheduler_Context   *context;
+
+  scheduler = assignment->scheduler;
+  context = _Scheduler_Get_context( scheduler );
 
   ++context->processor_count;
-  cpu-

[PATCH 10/10] rtems: Add scheduler processor add/remove

2016-11-08 Thread Sebastian Huber
Update #2797.
---
 cpukit/rtems/Makefile.am   |   2 +
 cpukit/rtems/include/rtems/rtems/tasks.h   |  45 
 cpukit/rtems/src/scheduleraddprocessor.c   | 125 +
 cpukit/rtems/src/schedulerremoveprocessor.c| 145 ++
 cpukit/score/include/rtems/score/percpu.h  |   6 +
 cpukit/score/include/rtems/score/scheduler.h   |  28 +-
 .../rtems/score/schedulerpriorityaffinitysmp.h |  12 +
 .../include/rtems/score/schedulerprioritysmp.h |  12 +
 .../include/rtems/score/schedulerprioritysmpimpl.h |   8 +
 .../score/include/rtems/score/schedulersimplesmp.h |  12 +
 .../score/include/rtems/score/schedulersmpimpl.h   |  92 +++
 .../score/include/rtems/score/schedulerstrongapa.h |  12 +
 cpukit/score/src/schedulerpriorityaffinitysmp.c|  30 +++
 cpukit/score/src/schedulerprioritysmp.c|  30 +++
 cpukit/score/src/schedulersimplesmp.c  |  38 +++
 cpukit/score/src/schedulersmpstartidle.c   |   2 +-
 cpukit/score/src/schedulerstrongapa.c  |  38 +++
 testsuites/smptests/Makefile.am|   1 +
 testsuites/smptests/configure.ac   |   1 +
 testsuites/smptests/smpscheduler02/init.c  | 130 +
 testsuites/smptests/smpscheduler04/Makefile.am |  19 ++
 testsuites/smptests/smpscheduler04/init.c  | 298 +
 .../smptests/smpscheduler04/smpscheduler04.doc |  14 +
 .../smptests/smpscheduler04/smpscheduler04.scn |   4 +
 testsuites/sptests/spscheduler01/init.c|  28 ++
 25 files changed, 1130 insertions(+), 2 deletions(-)
 create mode 100644 cpukit/rtems/src/scheduleraddprocessor.c
 create mode 100644 cpukit/rtems/src/schedulerremoveprocessor.c
 create mode 100644 testsuites/smptests/smpscheduler04/Makefile.am
 create mode 100644 testsuites/smptests/smpscheduler04/init.c
 create mode 100644 testsuites/smptests/smpscheduler04/smpscheduler04.doc
 create mode 100644 testsuites/smptests/smpscheduler04/smpscheduler04.scn

diff --git a/cpukit/rtems/Makefile.am b/cpukit/rtems/Makefile.am
index 6ecff9e..ada1f83 100644
--- a/cpukit/rtems/Makefile.am
+++ b/cpukit/rtems/Makefile.am
@@ -105,8 +105,10 @@ librtems_a_SOURCES += src/taskstart.c
 librtems_a_SOURCES += src/tasksuspend.c
 librtems_a_SOURCES += src/taskwakeafter.c
 librtems_a_SOURCES += src/taskwakewhen.c
+librtems_a_SOURCES += src/scheduleraddprocessor.c
 librtems_a_SOURCES += src/schedulergetprocessorset.c
 librtems_a_SOURCES += src/schedulerident.c
+librtems_a_SOURCES += src/schedulerremoveprocessor.c
 
 ## RATEMON_C_FILES
 librtems_a_SOURCES += src/ratemon.c
diff --git a/cpukit/rtems/include/rtems/rtems/tasks.h 
b/cpukit/rtems/include/rtems/rtems/tasks.h
index 3a94e34..fcbf5ed 100644
--- a/cpukit/rtems/include/rtems/rtems/tasks.h
+++ b/cpukit/rtems/include/rtems/rtems/tasks.h
@@ -585,6 +585,51 @@ rtems_status_code rtems_scheduler_get_processor_set(
 );
 #endif
 
+/**
+ * @brief Adds a processor the set of processors owned by the scheduler.
+ *
+ * Must be called from task context.  This operation obtains and releases the
+ * objects allocator lock.
+ *
+ * @param[in] scheduler_id Identifier of the scheduler.
+ * @param[in] cpu_index Index of the processor to add.
+ *
+ * @retval RTEMS_SUCCESSFUL Successful operation.
+ * @retval RTEMS_INVALID_ID Invalid scheduler identifier.
+ * @retval RTEMS_NOT_CONFIGURED The processor is not configured to be used by
+ *   the application.
+ * @retval RTEMS_INCORRECT_STATE The processor is configured to be used by
+ *   the application, however, it is not available.
+ * @retval RTEMS_RESOURCE_IN_USE The processor is already assigned to a
+ *   scheduler instance.
+ */
+rtems_status_code rtems_scheduler_add_processor(
+  rtems_id scheduler_id,
+  uint32_t cpu_index
+);
+
+/**
+ * @brief Removes a processor from set of processors owned by the scheduler.
+ *
+ * Must be called from task context.  This operation obtains and releases the
+ * objects allocator lock.  Removing a processor from a scheduler is a complex
+ * operation that involves all tasks in the system.
+ *
+ * @param[in] scheduler_id Identifier of the scheduler.
+ * @param[in] cpu_index Index of the processor to add.
+ *
+ * @retval RTEMS_SUCCESSFUL Successful operation.
+ * @retval RTEMS_INVALID_ID Invalid scheduler identifier.
+ * @retval RTEMS_INVALID_NUMBER The processor is not owned by the scheduler.
+ * @retval RTEMS_RESOURCE_IN_USE The set of processors owned by the scheduler
+ *   would be empty after the processor removal and there exists a non-idle
+ *   task that uses this scheduler as its home scheduler.
+ */
+rtems_status_code rtems_scheduler_remove_processor(
+  rtems_id scheduler_id,
+  uint32_t cpu_index
+);
+
 /**@}*/
 
 /**
diff --git a/cpukit/rtems/src/scheduleraddprocessor.c 
b/cpukit/rtems/src/scheduleraddprocessor.c
new file mode 100644
index 000..c9f7a18
--- /dev/null
+++ b/cpukit/rtems/src/scheduleraddprocessor.c
@@ -0,0 +1,125 @@
+/*
+ * Copy

[PATCH 08/10] score: Rename _Scheduler_Assignments

2016-11-08 Thread Sebastian Huber
Rename _Scheduler_Assignments into _Scheduler_Initial_assignments to
make it clear that they may not reflect the run-time scheduler
assignment.

Update #2797.
---
 cpukit/sapi/include/confdefs.h   |  6 ++--
 cpukit/score/include/rtems/score/scheduler.h |  2 +-
 cpukit/score/include/rtems/score/schedulerimpl.h | 23 -
 cpukit/score/src/smp.c   | 44 +++-
 4 files changed, 39 insertions(+), 36 deletions(-)

diff --git a/cpukit/sapi/include/confdefs.h b/cpukit/sapi/include/confdefs.h
index 3eac92c..be817bb 100644
--- a/cpukit/sapi/include/confdefs.h
+++ b/cpukit/sapi/include/confdefs.h
@@ -1019,7 +1019,7 @@ extern rtems_initialization_tasks_table 
Initialization_tasks[];
   #if defined(RTEMS_SMP)
 const size_t _Scheduler_Count = CONFIGURE_SCHEDULER_COUNT;
 
-const Scheduler_Assignment _Scheduler_Assignments[] = {
+const Scheduler_Assignment _Scheduler_Initial_assignments[] = {
   #if defined(CONFIGURE_SMP_SCHEDULER_ASSIGNMENTS)
 CONFIGURE_SMP_SCHEDULER_ASSIGNMENTS
   #else
@@ -1128,8 +1128,8 @@ extern rtems_initialization_tasks_table 
Initialization_tasks[];
 
 RTEMS_STATIC_ASSERT(
   CONFIGURE_SMP_MAXIMUM_PROCESSORS
-== RTEMS_ARRAY_SIZE( _Scheduler_Assignments ),
-  _Scheduler_Assignments
+== RTEMS_ARRAY_SIZE( _Scheduler_Initial_assignments ),
+  _Scheduler_Initial_assignments
 );
   #endif
 #endif
diff --git a/cpukit/score/include/rtems/score/scheduler.h 
b/cpukit/score/include/rtems/score/scheduler.h
index 873dabc..2e2f5f4 100644
--- a/cpukit/score/include/rtems/score/scheduler.h
+++ b/cpukit/score/include/rtems/score/scheduler.h
@@ -327,7 +327,7 @@ extern const Scheduler_Control _Scheduler_Table[];
*
* @see _Scheduler_Table and rtems_configuration_get_maximum_processors().
*/
-  extern const Scheduler_Assignment _Scheduler_Assignments[];
+  extern const Scheduler_Assignment _Scheduler_Initial_assignments[];
 #endif
 
 /**
diff --git a/cpukit/score/include/rtems/score/schedulerimpl.h 
b/cpukit/score/include/rtems/score/schedulerimpl.h
index de9af50..62a8e94 100644
--- a/cpukit/score/include/rtems/score/schedulerimpl.h
+++ b/cpukit/score/include/rtems/score/schedulerimpl.h
@@ -638,29 +638,6 @@ RTEMS_INLINE_ROUTINE void _Scheduler_Start_idle(
   ( *scheduler->Operations.start_idle )( scheduler, the_thread, cpu );
 }
 
-#if defined(RTEMS_SMP)
-RTEMS_INLINE_ROUTINE const Scheduler_Assignment *_Scheduler_Get_assignment(
-  uint32_t cpu_index
-)
-{
-  return &_Scheduler_Assignments[ cpu_index ];
-}
-
-RTEMS_INLINE_ROUTINE bool _Scheduler_Is_mandatory_processor(
-  const Scheduler_Assignment *assignment
-)
-{
-  return (assignment->attributes & SCHEDULER_ASSIGN_PROCESSOR_MANDATORY) != 0;
-}
-
-RTEMS_INLINE_ROUTINE bool _Scheduler_Should_start_processor(
-  const Scheduler_Assignment *assignment
-)
-{
-  return assignment->scheduler != NULL;
-}
-#endif /* defined(RTEMS_SMP) */
-
 RTEMS_INLINE_ROUTINE bool _Scheduler_Has_processor_ownership(
   const Scheduler_Control *scheduler,
   uint32_t cpu_index
diff --git a/cpukit/score/src/smp.c b/cpukit/score/src/smp.c
index c880d7e..ab9c7a6 100644
--- a/cpukit/score/src/smp.c
+++ b/cpukit/score/src/smp.c
@@ -32,16 +32,41 @@ Processor_mask _SMP_Online_processors;
 
 uint32_t _SMP_Processor_count;
 
+static const Scheduler_Assignment *_Scheduler_Get_initial_assignment(
+  uint32_t cpu_index
+)
+{
+  return &_Scheduler_Initial_assignments[ cpu_index ];
+}
+
+static bool _Scheduler_Is_mandatory_processor(
+  const Scheduler_Assignment *assignment
+)
+{
+  return (assignment->attributes & SCHEDULER_ASSIGN_PROCESSOR_MANDATORY) != 0;
+}
+
+static bool _Scheduler_Should_start_processor(
+  const Scheduler_Assignment *assignment
+)
+{
+  return assignment->scheduler != NULL;
+}
+
 static void _SMP_Start_processors( uint32_t cpu_count )
 {
-  uint32_t cpu_index_self = _SMP_Get_current_processor();
+  uint32_t cpu_index_self;
   uint32_t cpu_index;
 
+  cpu_index_self = _SMP_Get_current_processor();
+
   for ( cpu_index = 0 ; cpu_index < cpu_count; ++cpu_index ) {
-const Scheduler_Assignment *assignment =
-  _Scheduler_Get_assignment( cpu_index );
-Per_CPU_Control *cpu = _Per_CPU_Get_by_index( cpu_index );
-bool started;
+const Scheduler_Assignment *assignment;
+Per_CPU_Control*cpu;
+boolstarted;
+
+assignment = _Scheduler_Get_initial_assignment( cpu_index );
+cpu = _Per_CPU_Get_by_index( cpu_index );
 
 if ( cpu_index != cpu_index_self ) {
   if ( _Scheduler_Should_start_processor( assignment ) ) {
@@ -105,8 +130,9 @@ void _SMP_Handler_initialize( void )
   _SMP_Processor_count = cpu_count;
 
   for ( cpu_index = cpu_count ; cpu_index < cpu_max; ++cpu_index ) {
-const Scheduler_Assignment *assignment =
-  _Scheduler_Get_assignment( cpu_index );
+const Scheduler_Assignment *assignment;
+
+assignment = _Scheduler_Get_initial_a

[PATCH 07/10] score: Clarify _Scheduler_SMP_Start_idle()

2016-11-08 Thread Sebastian Huber
---
 cpukit/score/include/rtems/score/schedulersmp.h |  4 ++--
 cpukit/score/src/schedulersmpstartidle.c| 20 
 2 files changed, 14 insertions(+), 10 deletions(-)

diff --git a/cpukit/score/include/rtems/score/schedulersmp.h 
b/cpukit/score/include/rtems/score/schedulersmp.h
index c85445d..0bd899a 100644
--- a/cpukit/score/include/rtems/score/schedulersmp.h
+++ b/cpukit/score/include/rtems/score/schedulersmp.h
@@ -114,8 +114,8 @@ typedef struct {
 
 void _Scheduler_SMP_Start_idle(
   const Scheduler_Control *scheduler,
-  Thread_Control *thread,
-  struct Per_CPU_Control *cpu
+  Thread_Control  *idle,
+  struct Per_CPU_Control  *cpu
 );
 
 /** @} */
diff --git a/cpukit/score/src/schedulersmpstartidle.c 
b/cpukit/score/src/schedulersmpstartidle.c
index 0ffb628..c28a4c3 100644
--- a/cpukit/score/src/schedulersmpstartidle.c
+++ b/cpukit/score/src/schedulersmpstartidle.c
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2013-2014 embedded brains GmbH
+ * Copyright (c) 2013, 2016 embedded brains GmbH.
  *
  * The license and distribution terms for this file may be
  * found in the file LICENSE in this distribution or at
@@ -14,18 +14,22 @@
 
 void _Scheduler_SMP_Start_idle(
   const Scheduler_Control *scheduler,
-  Thread_Control *thread,
-  Per_CPU_Control *cpu
+  Thread_Control  *idle,
+  Per_CPU_Control *cpu
 )
 {
-  Scheduler_Context *context = _Scheduler_Get_context( scheduler );
-  Scheduler_SMP_Context *self = _Scheduler_SMP_Get_self( context );
-  Scheduler_SMP_Node *node = _Scheduler_SMP_Thread_get_node( thread );
+  Scheduler_Context *context;
+  Scheduler_SMP_Context *self;
+  Scheduler_SMP_Node*node;
+
+  context = _Scheduler_Get_context( scheduler );
+  self = _Scheduler_SMP_Get_self( context );
+  node = _Scheduler_SMP_Thread_get_node( idle );
 
   _Scheduler_Thread_change_state( thread, THREAD_SCHEDULER_SCHEDULED );
   node->state = SCHEDULER_SMP_NODE_SCHEDULED;
 
-  _Thread_Set_CPU( thread, cpu );
+  _Thread_Set_CPU( idle, cpu );
   _Chain_Append_unprotected( &self->Scheduled, &node->Base.Node );
-  _Chain_Prepend_unprotected( &self->Idle_threads, &thread->Object.Node );
+  _Scheduler_SMP_Release_idle_thread( &self->Base, idle );
 }
-- 
1.8.4.5

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


[PATCH 05/10] score: Avoid _Scheduler_Get_by_CPU_index( 0 )

2016-11-08 Thread Sebastian Huber
Avoid use of processor index 0 which may have no scheduler assigned.
---
 cpukit/score/include/rtems/score/coremuteximpl.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/cpukit/score/include/rtems/score/coremuteximpl.h 
b/cpukit/score/include/rtems/score/coremuteximpl.h
index 31d2a6e..e3da6a7 100644
--- a/cpukit/score/include/rtems/score/coremuteximpl.h
+++ b/cpukit/score/include/rtems/score/coremuteximpl.h
@@ -237,7 +237,7 @@ _CORE_ceiling_mutex_Get_scheduler(
 #if defined(RTEMS_SMP)
   return the_mutex->scheduler;
 #else
-  return _Scheduler_Get_by_CPU_index( 0 );
+  return &_Scheduler_Table[ 0 ];
 #endif
 }
 
-- 
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-08 Thread Chris Johns
On 8/11/16 9:32 am, Christian Mauderer wrote:
> 
> it would be nice if there are some good visible warnings if fallback packages 
> are used. Otherwise it might be hard for someone building the documentation 
> to find out why the output looks different.
> 

At the moment there is a configure warning.

> As an alternative it could be nice to have a configuration option like 
> '--no-fallback' that prevents the system from using any fallback fonts or 
> packages. This would allow to find all missing packages for the optimal 
> output.

This is a good idea. Maybe an option to accept the lower quality?

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


rtems-docs.git 4.11 branch added.

2016-11-08 Thread Chris Johns

Hi,

I have add the 4.11 branch to rtems-docs.git. The repo's master is open 
to accept changes for 4.12.


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