[rtems commit] smp: Disable restart of threads other than self

Sebastian Huber sebh at rtems.org
Tue Aug 20 08:57:22 UTC 2013


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

Author:    Sebastian Huber <sebastian.huber at embedded-brains.de>
Date:      Tue Aug 20 11:01:55 2013 +0200

smp: Disable restart of threads other than self

---

 cpukit/score/src/threadrestart.c            |   10 ++++++++++
 testsuites/smptests/smpunsupported01/init.c |   23 +++++++++++++++++++++++
 2 files changed, 33 insertions(+), 0 deletions(-)

diff --git a/cpukit/score/src/threadrestart.c b/cpukit/score/src/threadrestart.c
index 726cfa9..85803d8 100644
--- a/cpukit/score/src/threadrestart.c
+++ b/cpukit/score/src/threadrestart.c
@@ -20,6 +20,7 @@
 
 #include <rtems/score/threadimpl.h>
 #include <rtems/score/userextimpl.h>
+#include <rtems/config.h>
 
 bool _Thread_Restart(
   Thread_Control            *the_thread,
@@ -27,6 +28,15 @@ bool _Thread_Restart(
   Thread_Entry_numeric_type  numeric_argument
 )
 {
+#if defined( RTEMS_SMP )
+  if (
+    rtems_configuration_is_smp_enabled()
+      && !_Thread_Is_executing( the_thread )
+  ) {
+    return false;
+  }
+#endif
+
   if ( !_States_Is_dormant( the_thread->current_state ) ) {
 
     _Thread_Set_transient( the_thread );
diff --git a/testsuites/smptests/smpunsupported01/init.c b/testsuites/smptests/smpunsupported01/init.c
index a9782e8..bf7272b 100644
--- a/testsuites/smptests/smpunsupported01/init.c
+++ b/testsuites/smptests/smpunsupported01/init.c
@@ -18,6 +18,13 @@
 
 #include "tmacros.h"
 
+static void some_task(rtems_task_argument arg)
+{
+  (void) arg;
+
+  while (1);
+}
+
 static void test(void)
 {
   rtems_status_code sc;
@@ -50,6 +57,22 @@ static void test(void)
     &id
   );
   rtems_test_assert(sc == RTEMS_UNSATISFIED);
+
+  sc = rtems_task_create(
+    rtems_build_name('T', 'A', 'S', 'K'),
+    RTEMS_MAXIMUM_PRIORITY,
+    RTEMS_MINIMUM_STACK_SIZE,
+    RTEMS_DEFAULT_MODES,
+    RTEMS_DEFAULT_ATTRIBUTES,
+    &id
+  );
+  rtems_test_assert(sc == RTEMS_SUCCESSFUL);
+
+  sc = rtems_task_start(id, some_task, 0);
+  rtems_test_assert(sc == RTEMS_SUCCESSFUL);
+
+  sc = rtems_task_restart(id, 0);
+  rtems_test_assert(sc == RTEMS_INCORRECT_STATE);
 }
 
 static void Init(rtems_task_argument arg)




More information about the vc mailing list