summaryrefslogtreecommitdiffstats
path: root/cpukit/rtems
diff options
context:
space:
mode:
authorJoel Sherrill <joel.sherrill@oarcorp.com>2014-04-03 12:55:43 -0500
committerJoel Sherrill <joel.sherrill@oarcorp.com>2014-04-04 14:27:27 -0500
commitd507c0373168e6375b1e876d79730bff8020cb58 (patch)
tree1ca65b27019e70bdeef2e7d01357cfdbae2a0d5b /cpukit/rtems
parentrhealstone/rhmlatency: Fix configuration (diff)
downloadrtems-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 'cpukit/rtems')
-rw-r--r--cpukit/rtems/Makefile.am3
-rw-r--r--cpukit/rtems/include/rtems/rtems/tasks.h14
-rw-r--r--cpukit/rtems/include/rtems/rtems/tasksimpl.h4
-rw-r--r--cpukit/rtems/mainpage.h6
-rw-r--r--cpukit/rtems/src/tasks.c41
-rw-r--r--cpukit/rtems/src/taskvariable_invoke_dtor.c4
-rw-r--r--cpukit/rtems/src/taskvariableadd.c4
-rw-r--r--cpukit/rtems/src/taskvariabledelete.c4
-rw-r--r--cpukit/rtems/src/taskvariableget.c4
9 files changed, 60 insertions, 24 deletions
diff --git a/cpukit/rtems/Makefile.am b/cpukit/rtems/Makefile.am
index cf8ca3bb67..6cb5181188 100644
--- a/cpukit/rtems/Makefile.am
+++ b/cpukit/rtems/Makefile.am
@@ -106,10 +106,13 @@ librtems_a_SOURCES += src/taskstart.c
librtems_a_SOURCES += src/tasksuspend.c
librtems_a_SOURCES += src/taskwakeafter.c
librtems_a_SOURCES += src/taskwakewhen.c
+if HAS_SMP
+else
librtems_a_SOURCES += src/taskvariableadd.c
librtems_a_SOURCES += src/taskvariabledelete.c
librtems_a_SOURCES += src/taskvariableget.c
librtems_a_SOURCES += src/taskvariable_invoke_dtor.c
+endif
librtems_a_SOURCES += src/taskdata.c
## RATEMON_C_FILES
diff --git a/cpukit/rtems/include/rtems/rtems/tasks.h b/cpukit/rtems/include/rtems/rtems/tasks.h
index 325723ff85..263cc531d9 100644
--- a/cpukit/rtems/include/rtems/rtems/tasks.h
+++ b/cpukit/rtems/include/rtems/rtems/tasks.h
@@ -28,7 +28,7 @@
*/
/*
- * COPYRIGHT (c) 1989-2011.
+ * COPYRIGHT (c) 1989-2014.
* On-Line Applications Research Corporation (OAR).
*
* The license and distribution terms for this file may be
@@ -449,17 +449,18 @@ rtems_status_code rtems_task_wake_after(
*
* This directive returns a status indicating whether or not
* the specified task is suspended.
- *
- * RTEMS Task Manager
*/
rtems_status_code rtems_task_is_suspended(
rtems_id id
);
+#if !defined(RTEMS_SMP)
/**
* @brief RTEMS Add Task Variable
*
* This directive adds a per task variable.
+ *
+ * @note This service is not available in SMP configurations.
*/
rtems_status_code rtems_task_variable_add(
rtems_id tid,
@@ -470,9 +471,9 @@ rtems_status_code rtems_task_variable_add(
/**
* @brief Get a per-task variable
*
- * RTEMS Task Variable Get
- *
* This directive gets the value of a task variable.
+ *
+ * @note This service is not available in SMP configurations.
*/
rtems_status_code rtems_task_variable_get(
rtems_id tid,
@@ -484,11 +485,14 @@ rtems_status_code rtems_task_variable_get(
* @brief RTEMS Delete Task Variable
*
* This directive removes a per task variable.
+ *
+ * @note This service is not available in SMP configurations.
*/
rtems_status_code rtems_task_variable_delete(
rtems_id tid,
void **ptr
);
+#endif
#if defined(__RTEMS_HAVE_SYS_CPUSET_H__) && defined(RTEMS_SMP)
/**
diff --git a/cpukit/rtems/include/rtems/rtems/tasksimpl.h b/cpukit/rtems/include/rtems/rtems/tasksimpl.h
index c86d5914c2..280be2fac8 100644
--- a/cpukit/rtems/include/rtems/rtems/tasksimpl.h
+++ b/cpukit/rtems/include/rtems/rtems/tasksimpl.h
@@ -6,7 +6,7 @@
* @brief Classic Tasks Manager Implementation
*/
-/* COPYRIGHT (c) 1989-2008.
+/* COPYRIGHT (c) 1989-2014.
* On-Line Applications Research Corporation (OAR).
*
* The license and distribution terms for this file may be
@@ -66,6 +66,7 @@ void _RTEMS_tasks_Manager_initialization(void);
*/
void _RTEMS_tasks_Initialize_user_tasks( void );
+#if !defined(RTEMS_SMP)
/**
* @brief RTEMS Tasks Invoke Task Variable Destructor
*
@@ -76,6 +77,7 @@ void _RTEMS_Tasks_Invoke_task_variable_dtor(
Thread_Control *the_thread,
rtems_task_variable_t *tvp
);
+#endif
RTEMS_INLINE_ROUTINE Thread_Control *_RTEMS_tasks_Allocate(void)
{
diff --git a/cpukit/rtems/mainpage.h b/cpukit/rtems/mainpage.h
index c3fc44d9fc..720698140e 100644
--- a/cpukit/rtems/mainpage.h
+++ b/cpukit/rtems/mainpage.h
@@ -5,7 +5,7 @@
*/
/*
- * COPYRIGHT (c) 1989-2011.
+ * COPYRIGHT (c) 1989-2014.
* On-Line Applications Research Corporation (OAR).
*
* The license and distribution terms for this file may be
@@ -887,6 +887,10 @@
* A critical point with per-task variables is that each task must separately
* request that the same global variable is per-task private.
*
+ * @b{WARNING}: Per-task variables are fundamentally incorrect in SMP
+ * systems and should not be used in SMP applications. They
+ * are disabled.
+ *
* @section ClassicTasksSecBuildingTaskAttributeSet Building a Task Attribute Set
*
* In general, an attribute set is built by a bitwise OR of the desired
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 */
diff --git a/cpukit/rtems/src/taskvariable_invoke_dtor.c b/cpukit/rtems/src/taskvariable_invoke_dtor.c
index 51b9453d82..062772369f 100644
--- a/cpukit/rtems/src/taskvariable_invoke_dtor.c
+++ b/cpukit/rtems/src/taskvariable_invoke_dtor.c
@@ -6,7 +6,7 @@
*/
/*
- * COPYRIGHT (c) 1989-2007.
+ * COPYRIGHT (c) 1989-2014.
* On-Line Applications Research Corporation (OAR).
*
* The license and distribution terms for this file may be
@@ -18,6 +18,7 @@
#include "config.h"
#endif
+#if !defined(RTEMS_SMP)
#include <rtems/rtems/tasksimpl.h>
#include <rtems/score/threadimpl.h>
#include <rtems/score/wkspace.h>
@@ -43,3 +44,4 @@ void _RTEMS_Tasks_Invoke_task_variable_dtor(
_Workspace_Free(tvp);
}
+#endif
diff --git a/cpukit/rtems/src/taskvariableadd.c b/cpukit/rtems/src/taskvariableadd.c
index bd4501822b..c79195e94c 100644
--- a/cpukit/rtems/src/taskvariableadd.c
+++ b/cpukit/rtems/src/taskvariableadd.c
@@ -6,7 +6,7 @@
*/
/*
- * COPYRIGHT (c) 1989-2007.
+ * COPYRIGHT (c) 1989-2014.
* On-Line Applications Research Corporation (OAR).
*
* The license and distribution terms for this file may be
@@ -18,6 +18,7 @@
#include "config.h"
#endif
+#if !defined(RTEMS_SMP)
#include <rtems/rtems/tasks.h>
#include <rtems/score/threadimpl.h>
#include <rtems/score/wkspace.h>
@@ -88,3 +89,4 @@ rtems_status_code rtems_task_variable_add(
}
return RTEMS_INVALID_ID;
}
+#endif
diff --git a/cpukit/rtems/src/taskvariabledelete.c b/cpukit/rtems/src/taskvariabledelete.c
index 49e2746a00..f5362f94d4 100644
--- a/cpukit/rtems/src/taskvariabledelete.c
+++ b/cpukit/rtems/src/taskvariabledelete.c
@@ -6,7 +6,7 @@
*/
/*
- * COPYRIGHT (c) 1989-2007.
+ * COPYRIGHT (c) 1989-2014.
* On-Line Applications Research Corporation (OAR).
*
* The license and distribution terms for this file may be
@@ -18,6 +18,7 @@
#include "config.h"
#endif
+#if !defined(RTEMS_SMP)
#include <rtems/rtems/tasksimpl.h>
#include <rtems/score/threadimpl.h>
#include <rtems/score/wkspace.h>
@@ -77,3 +78,4 @@ rtems_status_code rtems_task_variable_delete(
return RTEMS_INVALID_ID;
}
+#endif
diff --git a/cpukit/rtems/src/taskvariableget.c b/cpukit/rtems/src/taskvariableget.c
index 627d40ad09..ba49b4d88e 100644
--- a/cpukit/rtems/src/taskvariableget.c
+++ b/cpukit/rtems/src/taskvariableget.c
@@ -6,7 +6,7 @@
*/
/*
- * COPYRIGHT (c) 1989-2007.
+ * COPYRIGHT (c) 1989-2014.
* On-Line Applications Research Corporation (OAR).
*
* The license and distribution terms for this file may be
@@ -18,6 +18,7 @@
#include "config.h"
#endif
+#if !defined(RTEMS_SMP)
#include <rtems/rtems/tasksimpl.h>
#include <rtems/score/threadimpl.h>
#include <rtems/score/wkspace.h>
@@ -85,3 +86,4 @@ rtems_status_code rtems_task_variable_get(
}
return RTEMS_INVALID_ID;
}
+#endif