[rtems commit] score: Add _SMP_Synchronize()

Sebastian Huber sebh at rtems.org
Tue May 21 04:25:00 UTC 2019


Module:    rtems
Branch:    master
Commit:    577293f0a959b5368c073d51f3404c57b3680d14
Changeset: http://git.rtems.org/rtems/commit/?id=577293f0a959b5368c073d51f3404c57b3680d14

Author:    Sebastian Huber <sebastian.huber at embedded-brains.de>
Date:      Sun Apr 28 14:31:10 2019 +0200

score: Add _SMP_Synchronize()

---

 cpukit/include/rtems/score/smpimpl.h  |  8 ++++++++
 cpukit/score/src/smpmulticastaction.c | 10 ++++++++++
 testsuites/smptests/smpipi01/init.c   |  7 ++++---
 3 files changed, 22 insertions(+), 3 deletions(-)

diff --git a/cpukit/include/rtems/score/smpimpl.h b/cpukit/include/rtems/score/smpimpl.h
index c0fe7a0..e52a82c 100644
--- a/cpukit/include/rtems/score/smpimpl.h
+++ b/cpukit/include/rtems/score/smpimpl.h
@@ -261,6 +261,14 @@ void _SMP_Othercast_action(
   void               *arg
 );
 
+/**
+ * @brief Ensures that all store operations issued by the current processor
+ * before the call this function are visible to all other online processors.
+ *
+ * Simply calls _SMP_Othercast_action() with an empty multicast action.
+ */
+void _SMP_Synchronize( void );
+
 #endif /* defined( RTEMS_SMP ) */
 
 /**
diff --git a/cpukit/score/src/smpmulticastaction.c b/cpukit/score/src/smpmulticastaction.c
index b5d21a4..232b314 100644
--- a/cpukit/score/src/smpmulticastaction.c
+++ b/cpukit/score/src/smpmulticastaction.c
@@ -211,3 +211,13 @@ void _SMP_Othercast_action(
   _Processor_mask_Clear( &targets, _SMP_Get_current_processor() );
   _SMP_Multicast_action( &targets, handler, arg );
 }
+
+static void _SMP_Do_nothing_action( void *arg )
+{
+  /* Do nothing */
+}
+
+void _SMP_Synchronize( void )
+{
+  _SMP_Othercast_action( _SMP_Do_nothing_action, NULL );
+}
diff --git a/testsuites/smptests/smpipi01/init.c b/testsuites/smptests/smpipi01/init.c
index 18d96da..3cc7a13 100644
--- a/testsuites/smptests/smpipi01/init.c
+++ b/testsuites/smptests/smpipi01/init.c
@@ -18,7 +18,6 @@
 
 #include <rtems/score/smpimpl.h>
 #include <rtems/score/smpbarrier.h>
-#include <rtems/counter.h>
 #include <rtems.h>
 
 #include <stdio.h>
@@ -195,10 +194,12 @@ static void test_send_message_flood(
   }
 
   for (cpu_index = 0; cpu_index < cpu_count; ++cpu_index) {
+    Per_CPU_Control *cpu_self;
     uint32_t i;
 
-    /* Wait 1us so that all outstanding messages have been processed */
-    rtems_counter_delay_nanoseconds(1000000);
+    cpu_self = _Thread_Dispatch_disable();
+    _SMP_Synchronize();
+    _Thread_Dispatch_enable(cpu_self);
 
     for (i = 0; i < cpu_count; ++i) {
       if (i != cpu_index) {



More information about the vc mailing list