[PATCH] score: Simplify _Scheduler_Tick()
Sebastian Huber
sebastian.huber at embedded-brains.de
Thu Aug 12 09:11:22 UTC 2021
The NULL pointer check for the executing thread was introduced by
commit:
commit be3c257286ad870d8d1a64941cde53fd2d33a633
Author: Sebastian Huber <sebastian.huber at embedded-brains.de>
Date: Thu Jun 5 11:17:26 2014 +0200
score: Avoid NULL pointer access
Check that the executing thread is not NULL in _Scheduler_Tick(). It
may be NULL in case the processor has an optional scheduler assigned and
the system was not able to start the processor.
However, it is no longer necessary since now the clock interrupt is
distributed to the online processors.
---
cpukit/include/rtems/score/schedulerimpl.h | 26 ++++++++++++++++++----
1 file changed, 22 insertions(+), 4 deletions(-)
diff --git a/cpukit/include/rtems/score/schedulerimpl.h b/cpukit/include/rtems/score/schedulerimpl.h
index 586f9e0ec8..7b0658073e 100644
--- a/cpukit/include/rtems/score/schedulerimpl.h
+++ b/cpukit/include/rtems/score/schedulerimpl.h
@@ -611,12 +611,30 @@ RTEMS_INLINE_ROUTINE void _Scheduler_Cancel_job(
*/
RTEMS_INLINE_ROUTINE void _Scheduler_Tick( const Per_CPU_Control *cpu )
{
- const Scheduler_Control *scheduler = _Scheduler_Get_by_CPU( cpu );
- Thread_Control *executing = cpu->executing;
+ const Scheduler_Control *scheduler;
+ Thread_Control *executing;
+
+ scheduler = _Scheduler_Get_by_CPU( cpu );
- if ( scheduler != NULL && executing != NULL ) {
- ( *scheduler->Operations.tick )( scheduler, executing );
+#if defined(RTEMS_SMP)
+ if ( scheduler == NULL ) {
+ /*
+ * In SMP configurations, processors may be removed/added at runtime
+ * from/to a scheduler. There may be still clock interrupts on currently
+ * unassigned processors.
+ */
+ return;
}
+#endif
+
+ /*
+ * Each online processor has at least an idle thread as the executing thread
+ * even in case it has currently no scheduler assigned. Clock interrupts on
+ * processors which are not online would be a severe bug of the Clock Driver.
+ */
+ executing = _Per_CPU_Get_executing( cpu );
+ _Assert( executing != NULL );
+ ( *scheduler->Operations.tick )( scheduler, executing );
}
/**
--
2.26.2
More information about the devel
mailing list