[PATCH 09/10] score: Add and use Thread_Control::is_idle
Sebastian Huber
sebastian.huber at embedded-brains.de
Tue Nov 8 08:59:43 UTC 2016
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_uptime_nanoseconds();
}
}
--
1.8.4.5
More information about the devel
mailing list