diff options
author | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2013-08-20 11:01:55 +0200 |
---|---|---|
committer | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2013-08-20 11:03:38 +0200 |
commit | 518d82b6d39922eff34ee2eb7bd4df2a73ad2c1e (patch) | |
tree | e90eafaf3e2bfa607cf32365a73fadca77789185 | |
parent | add compare_and_swap check in check-atomic.m4 (diff) | |
download | rtems-518d82b6d39922eff34ee2eb7bd4df2a73ad2c1e.tar.bz2 |
smp: Disable restart of threads other than self
-rw-r--r-- | cpukit/score/src/threadrestart.c | 10 | ||||
-rw-r--r-- | 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 726cfa90cf..85803d8439 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 a9782e859a..bf7272bffb 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) |