From 05e82bd76b057bf60f8590c5226561538ba9057e Mon Sep 17 00:00:00 2001 From: Sebastian Huber Date: Thu, 18 Jul 2013 11:53:48 +0200 Subject: score: Error for non-preemptible tasks on SMP A common use case for disabled preemption was to ensure mutual exclusion on single-processor configurations. On SMP this does not work. To abandon non-preemptible tasks simplifies the scheduler. --- cpukit/rtems/src/taskcreate.c | 1 + cpukit/rtems/src/taskmode.c | 13 ++++++++++++- cpukit/sapi/include/confdefs.h | 6 +++++- cpukit/score/src/threadinitialize.c | 7 +++++++ 4 files changed, 25 insertions(+), 2 deletions(-) (limited to 'cpukit') diff --git a/cpukit/rtems/src/taskcreate.c b/cpukit/rtems/src/taskcreate.c index 64ad1ebd76..471990da0a 100644 --- a/cpukit/rtems/src/taskcreate.c +++ b/cpukit/rtems/src/taskcreate.c @@ -19,6 +19,7 @@ #endif #include +#include #include #include #include diff --git a/cpukit/rtems/src/taskmode.c b/cpukit/rtems/src/taskmode.c index d9c7fce0ec..eb3636d172 100644 --- a/cpukit/rtems/src/taskmode.c +++ b/cpukit/rtems/src/taskmode.c @@ -19,6 +19,7 @@ #endif #include +#include #include #include #include @@ -67,8 +68,18 @@ rtems_status_code rtems_task_mode( /* * These are generic thread scheduling characteristics. */ - if ( mask & RTEMS_PREEMPT_MASK ) + if ( mask & RTEMS_PREEMPT_MASK ) { +#if defined( RTEMS_SMP ) + if ( + rtems_configuration_is_smp_enabled() + && !_Modes_Is_preempt( mode_set ) + ) { + return RTEMS_NOT_IMPLEMENTED; + } +#endif + executing->is_preemptible = _Modes_Is_preempt( mode_set ); + } if ( mask & RTEMS_TIMESLICE_MASK ) { if ( _Modes_Is_timeslice(mode_set) ) { diff --git a/cpukit/sapi/include/confdefs.h b/cpukit/sapi/include/confdefs.h index b7cbfaa676..c969fa78de 100644 --- a/cpukit/sapi/include/confdefs.h +++ b/cpukit/sapi/include/confdefs.h @@ -1021,7 +1021,11 @@ const rtems_libio_helper rtems_fs_init_helper = #endif #ifndef CONFIGURE_INIT_TASK_INITIAL_MODES - #define CONFIGURE_INIT_TASK_INITIAL_MODES RTEMS_NO_PREEMPT + #if defined(RTEMS_SMP) && defined(CONFIGURE_SMP_APPLICATION) + #define CONFIGURE_INIT_TASK_INITIAL_MODES RTEMS_DEFAULT_MODES + #else + #define CONFIGURE_INIT_TASK_INITIAL_MODES RTEMS_NO_PREEMPT + #endif #endif #ifndef CONFIGURE_INIT_TASK_ARGUMENTS diff --git a/cpukit/score/src/threadinitialize.c b/cpukit/score/src/threadinitialize.c index 4c40ae87b8..cc74573def 100644 --- a/cpukit/score/src/threadinitialize.c +++ b/cpukit/score/src/threadinitialize.c @@ -18,6 +18,7 @@ #endif #include +#include #include #include #include @@ -57,6 +58,12 @@ bool _Thread_Initialize( bool extension_status; int i; +#if defined( RTEMS_SMP ) + if ( rtems_configuration_is_smp_enabled() && !is_preemptible ) { + return false; + } +#endif + /* * Initialize the Ada self pointer */ -- cgit v1.2.3