[rtems commit] score: Simplify _Scheduler_Tick()
Sebastian Huber
sebh at rtems.org
Thu Aug 12 19:07:30 UTC 2021
Module: rtems
Branch: master
Commit: 0a69ce0fb4a71f8093f94d2c2bd7343968802980
Changeset: http://git.rtems.org/rtems/commit/?id=0a69ce0fb4a71f8093f94d2c2bd7343968802980
Author: Sebastian Huber <sebastian.huber at embedded-brains.de>
Date: Thu Aug 12 11:06:55 2021 +0200
score: Simplify _Scheduler_Tick()
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 24db4d7..98f8e33 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 );
}
/**
More information about the vc
mailing list