diff options
author | Joel Sherrill <joel.sherrill@oarcorp.com> | 2014-04-03 12:55:43 -0500 |
---|---|---|
committer | Joel Sherrill <joel.sherrill@oarcorp.com> | 2014-04-04 14:27:27 -0500 |
commit | d507c0373168e6375b1e876d79730bff8020cb58 (patch) | |
tree | 1ca65b27019e70bdeef2e7d01357cfdbae2a0d5b /cpukit/rtems/src/tasks.c | |
parent | rhealstone/rhmlatency: Fix configuration (diff) | |
download | rtems-d507c0373168e6375b1e876d79730bff8020cb58.tar.bz2 |
Disable per task variables when SMP is enabled
Per task variables are inherently unsafe in SMP systems. This
patch disables them from the build and adds warnings in the
appropriate documentation and configuration sections.
Diffstat (limited to '')
-rw-r--r-- | cpukit/rtems/src/tasks.c | 41 |
1 files changed, 28 insertions, 13 deletions
diff --git a/cpukit/rtems/src/tasks.c b/cpukit/rtems/src/tasks.c index 594695080a..209a43cb07 100644 --- a/cpukit/rtems/src/tasks.c +++ b/cpukit/rtems/src/tasks.c @@ -72,7 +72,9 @@ static bool _RTEMS_tasks_Create_extension( _Event_Initialize( &api->System_event ); _ASR_Initialize( &api->Signal ); _Thread_Action_initialize( &api->Signal_action, _Signal_Action_handler ); +#if !defined(RTEMS_SMP) created->task_variables = NULL; +#endif if ( rtems_configuration_get_notepads_enabled() ) { for (i=0; i < RTEMS_NUMBER_NOTEPADS; i++) @@ -124,19 +126,25 @@ static void _RTEMS_tasks_Terminate_extension( Thread_Control *executing ) { - rtems_task_variable_t *tvp, *next; /* * Free per task variable memory + * + * Per Task Variables are only enabled in uniprocessor configurations */ - - tvp = executing->task_variables; - executing->task_variables = NULL; - while (tvp) { - next = (rtems_task_variable_t *)tvp->next; - _RTEMS_Tasks_Invoke_task_variable_dtor( executing, tvp ); - tvp = next; - } + #if !defined(RTEMS_SMP) + do { + rtems_task_variable_t *tvp, *next; + + tvp = executing->task_variables; + executing->task_variables = NULL; + while (tvp) { + next = (rtems_task_variable_t *)tvp->next; + _RTEMS_Tasks_Invoke_task_variable_dtor( executing, tvp ); + tvp = next; + } + } while (0); + #endif /* * Run all the key destructors @@ -144,12 +152,15 @@ static void _RTEMS_tasks_Terminate_extension( _POSIX_Keys_Run_destructors( executing ); } +#if !defined(RTEMS_SMP) /* * _RTEMS_tasks_Switch_extension * * This extension routine is invoked at each context switch. + * + * @note Since this only needs to address per-task variables, it is + * disabled entirely for SMP configurations. */ - static void _RTEMS_tasks_Switch_extension( Thread_Control *executing, Thread_Control *heir @@ -158,7 +169,7 @@ static void _RTEMS_tasks_Switch_extension( rtems_task_variable_t *tvp; /* - * Per Task Variables + * Per Task Variables are only enabled in uniprocessor configurations */ tvp = executing->task_variables; @@ -175,6 +186,10 @@ static void _RTEMS_tasks_Switch_extension( tvp = (rtems_task_variable_t *)tvp->next; } } +#define RTEMS_TASKS_SWITCH_EXTENSION _RTEMS_tasks_Switch_extension +#else +#define RTEMS_TASKS_SWITCH_EXTENSION NULL +#endif API_extensions_Control _RTEMS_tasks_API_extensions = { #if defined(FUNCTIONALITY_NOT_CURRENTLY_USED_BY_ANY_API) @@ -185,12 +200,12 @@ API_extensions_Control _RTEMS_tasks_API_extensions = { User_extensions_Control _RTEMS_tasks_User_extensions = { { NULL, NULL }, - { { NULL, NULL }, _RTEMS_tasks_Switch_extension }, + { { NULL, NULL }, RTEMS_TASKS_SWITCH_EXTENSION }, { _RTEMS_tasks_Create_extension, /* create */ _RTEMS_tasks_Start_extension, /* start */ _RTEMS_tasks_Start_extension, /* restart */ _RTEMS_tasks_Delete_extension, /* delete */ - _RTEMS_tasks_Switch_extension, /* switch */ + RTEMS_TASKS_SWITCH_EXTENSION, /* switch */ NULL, /* begin */ NULL, /* exitted */ NULL, /* fatal */ |