diff options
Diffstat (limited to 'cpukit/include/rtems/score')
-rw-r--r-- | cpukit/include/rtems/score/percpu.h | 7 | ||||
-rw-r--r-- | cpukit/include/rtems/score/userextimpl.h | 11 |
2 files changed, 18 insertions, 0 deletions
diff --git a/cpukit/include/rtems/score/percpu.h b/cpukit/include/rtems/score/percpu.h index 7c95a9649a..31bc2b0bff 100644 --- a/cpukit/include/rtems/score/percpu.h +++ b/cpukit/include/rtems/score/percpu.h @@ -529,6 +529,13 @@ typedef struct Per_CPU_Control { } Scheduler; /** + * @brief The ancestor of the executing thread. + * + * This member is used by _User_extensions_Thread_switch(). + */ + struct _Thread_Control *ancestor; + + /** * @brief Begin of the per-CPU data area. * * Contains items defined via PER_CPU_DATA_ITEM(). diff --git a/cpukit/include/rtems/score/userextimpl.h b/cpukit/include/rtems/score/userextimpl.h index 8b456c072d..23ee957724 100644 --- a/cpukit/include/rtems/score/userextimpl.h +++ b/cpukit/include/rtems/score/userextimpl.h @@ -386,7 +386,16 @@ static inline void _User_extensions_Thread_switch( _ISR_lock_ISR_disable( &lock_context ); _Per_CPU_Acquire( cpu_self, &lock_context ); + executing = cpu_self->ancestor; + cpu_self->ancestor = heir; node = _Chain_Immutable_first( chain ); + + /* + * An executing thread equal to the heir thread may happen in two + * situations. Firstly, in case context switch extensions are created after + * system initialization. Secondly, during a thread self restart. + */ + if ( executing != heir ) { #endif while ( node != tail ) { @@ -398,6 +407,8 @@ static inline void _User_extensions_Thread_switch( } #if defined(RTEMS_SMP) + } + _Per_CPU_Release( cpu_self, &lock_context ); _ISR_lock_ISR_enable( &lock_context ); #endif |