summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSebastian Huber <sebastian.huber@embedded-brains.de>2016-11-07 06:25:03 +0100
committerSebastian Huber <sebastian.huber@embedded-brains.de>2016-11-09 15:27:29 +0100
commit1c46b80329d5d099022d8c7e0a8c593845120729 (patch)
tree10806fd4ca26dd0a7b3410baf1187575d6bc8102
parentscore: Avoid _Scheduler_Get_by_CPU_index( 0 ) (diff)
downloadrtems-1c46b80329d5d099022d8c7e0a8c593845120729.tar.bz2
score: Add scheduler to per-CPU information
This makes it possible to adjust the scheduler of a processor at run-time. Update #2797.
-rw-r--r--cpukit/score/include/rtems/score/percpu.h21
-rw-r--r--cpukit/score/include/rtems/score/schedulerimpl.h36
-rw-r--r--cpukit/score/include/rtems/score/schedulersmpimpl.h2
-rw-r--r--cpukit/score/src/smp.c10
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 e3be0c80d3..94aef1de22 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 8d804bb0e4..de9af50db9 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 b12dd5f0d4..ece075a931 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 f383f6de97..c880d7eb5d 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->scheduler_context = context;
+ cpu->Scheduler.control = scheduler;
+ cpu->Scheduler.context = context;
_Processor_mask_Set( _SMP_Online_processors, cpu_index );
}