Changeset d507c037 in rtems


Ignore:
Timestamp:
Apr 3, 2014, 5:55:43 PM (5 years ago)
Author:
Joel Sherrill <joel.sherrill@…>
Branches:
4.11, master
Children:
57740ce8
Parents:
cae120e2
git-author:
Joel Sherrill <joel.sherrill@…> (04/03/14 17:55:43)
git-committer:
Joel Sherrill <joel.sherrill@…> (04/04/14 19:27:27)
Message:

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.

Files:
16 edited

Legend:

Unmodified
Added
Removed
  • cpukit/rtems/Makefile.am

    rcae120e2 rd507c037  
    107107librtems_a_SOURCES += src/taskwakeafter.c
    108108librtems_a_SOURCES += src/taskwakewhen.c
     109if HAS_SMP
     110else
    109111librtems_a_SOURCES += src/taskvariableadd.c
    110112librtems_a_SOURCES += src/taskvariabledelete.c
    111113librtems_a_SOURCES += src/taskvariableget.c
    112114librtems_a_SOURCES += src/taskvariable_invoke_dtor.c
     115endif
    113116librtems_a_SOURCES += src/taskdata.c
    114117
  • cpukit/rtems/include/rtems/rtems/tasks.h

    rcae120e2 rd507c037  
    2929
    3030/*
    31  * COPYRIGHT (c) 1989-2011.
     31 * COPYRIGHT (c) 1989-2014.
    3232 * On-Line Applications Research Corporation (OAR).
    3333 *
     
    450450 *  This directive returns a status indicating whether or not
    451451 *  the specified task is suspended.
    452  *
    453  *  RTEMS Task Manager
    454452 */
    455453rtems_status_code rtems_task_is_suspended(
     
    457455);
    458456
     457#if !defined(RTEMS_SMP)
    459458/**
    460459 *  @brief RTEMS Add Task Variable
    461460 *
    462461 *  This directive adds a per task variable.
     462 *
     463 *  @note This service is not available in SMP configurations.
    463464 */
    464465rtems_status_code rtems_task_variable_add(
     
    471472 *  @brief Get a per-task variable
    472473 *
    473  *  RTEMS Task Variable Get
    474  *
    475474 *  This directive gets the value of a task variable.
     475 *
     476 *  @note This service is not available in SMP configurations.
    476477 */
    477478rtems_status_code rtems_task_variable_get(
     
    485486 *
    486487 *  This directive removes a per task variable.
     488 *
     489 *  @note This service is not available in SMP configurations.
    487490 */
    488491rtems_status_code rtems_task_variable_delete(
     
    490493  void    **ptr
    491494);
     495#endif
    492496
    493497#if defined(__RTEMS_HAVE_SYS_CPUSET_H__) && defined(RTEMS_SMP)
  • cpukit/rtems/include/rtems/rtems/tasksimpl.h

    rcae120e2 rd507c037  
    77 */
    88
    9 /*  COPYRIGHT (c) 1989-2008.
     9/*  COPYRIGHT (c) 1989-2014.
    1010 *  On-Line Applications Research Corporation (OAR).
    1111 *
     
    6767void _RTEMS_tasks_Initialize_user_tasks( void );
    6868
     69#if !defined(RTEMS_SMP)
    6970/**
    7071 *  @brief RTEMS Tasks Invoke Task Variable Destructor
     
    7778  rtems_task_variable_t *tvp
    7879);
     80#endif
    7981
    8082RTEMS_INLINE_ROUTINE Thread_Control *_RTEMS_tasks_Allocate(void)
  • cpukit/rtems/mainpage.h

    rcae120e2 rd507c037  
    66
    77/*
    8  *  COPYRIGHT (c) 1989-2011.
     8 *  COPYRIGHT (c) 1989-2014.
    99 *  On-Line Applications Research Corporation (OAR).
    1010 *
     
    887887 * A critical point with per-task variables is that each task must separately
    888888 * request that the same global variable is per-task private.
     889 *
     890 * @b{WARNING}: Per-task variables are fundamentally incorrect in SMP
     891 *              systems and should not be used in SMP applications. They
     892 *              are disabled.
    889893 *
    890894 * @section ClassicTasksSecBuildingTaskAttributeSet Building a Task Attribute Set
  • cpukit/rtems/src/tasks.c

    rcae120e2 rd507c037  
    7373  _ASR_Initialize( &api->Signal );
    7474  _Thread_Action_initialize( &api->Signal_action, _Signal_Action_handler );
     75#if !defined(RTEMS_SMP)
    7576  created->task_variables = NULL;
     77#endif
    7678
    7779  if ( rtems_configuration_get_notepads_enabled() ) {
     
    125127)
    126128{
    127   rtems_task_variable_t *tvp, *next;
    128129
    129130  /*
    130131   *  Free per task variable memory
    131    */
    132 
    133   tvp = executing->task_variables;
    134   executing->task_variables = NULL;
    135   while (tvp) {
    136     next = (rtems_task_variable_t *)tvp->next;
    137     _RTEMS_Tasks_Invoke_task_variable_dtor( executing, tvp );
    138     tvp = next;
    139   }
     132   *
     133   *  Per Task Variables are only enabled in uniprocessor configurations
     134   */
     135  #if !defined(RTEMS_SMP)
     136    do {
     137      rtems_task_variable_t *tvp, *next;
     138
     139      tvp = executing->task_variables;
     140      executing->task_variables = NULL;
     141      while (tvp) {
     142        next = (rtems_task_variable_t *)tvp->next;
     143        _RTEMS_Tasks_Invoke_task_variable_dtor( executing, tvp );
     144        tvp = next;
     145      }
     146    } while (0);
     147  #endif
    140148
    141149  /*
     
    145153}
    146154
     155#if !defined(RTEMS_SMP)
    147156/*
    148157 *  _RTEMS_tasks_Switch_extension
    149158 *
    150159 *  This extension routine is invoked at each context switch.
    151  */
    152 
     160 *
     161 *  @note Since this only needs to address per-task variables, it is
     162 *        disabled entirely for SMP configurations.
     163 */
    153164static void _RTEMS_tasks_Switch_extension(
    154165  Thread_Control *executing,
     
    159170
    160171  /*
    161    *  Per Task Variables
     172   *  Per Task Variables are only enabled in uniprocessor configurations
    162173   */
    163174
     
    176187  }
    177188}
     189#define RTEMS_TASKS_SWITCH_EXTENSION _RTEMS_tasks_Switch_extension
     190#else
     191#define RTEMS_TASKS_SWITCH_EXTENSION NULL
     192#endif
    178193
    179194API_extensions_Control _RTEMS_tasks_API_extensions = {
     
    186201User_extensions_Control _RTEMS_tasks_User_extensions = {
    187202  { NULL, NULL },
    188   { { NULL, NULL }, _RTEMS_tasks_Switch_extension },
     203  { { NULL, NULL }, RTEMS_TASKS_SWITCH_EXTENSION },
    189204  { _RTEMS_tasks_Create_extension,            /* create */
    190205    _RTEMS_tasks_Start_extension,             /* start */
    191206    _RTEMS_tasks_Start_extension,             /* restart */
    192207    _RTEMS_tasks_Delete_extension,            /* delete */
    193     _RTEMS_tasks_Switch_extension,            /* switch */
     208    RTEMS_TASKS_SWITCH_EXTENSION,             /* switch */
    194209    NULL,                                     /* begin */
    195210    NULL,                                     /* exitted */
  • cpukit/rtems/src/taskvariable_invoke_dtor.c

    rcae120e2 rd507c037  
    77
    88/*
    9  *  COPYRIGHT (c) 1989-2007.
     9 *  COPYRIGHT (c) 1989-2014.
    1010 *  On-Line Applications Research Corporation (OAR).
    1111 *
     
    1919#endif
    2020
     21#if !defined(RTEMS_SMP)
    2122#include <rtems/rtems/tasksimpl.h>
    2223#include <rtems/score/threadimpl.h>
     
    4445  _Workspace_Free(tvp);
    4546}
     47#endif
  • cpukit/rtems/src/taskvariableadd.c

    rcae120e2 rd507c037  
    77
    88/*
    9  *  COPYRIGHT (c) 1989-2007.
     9 *  COPYRIGHT (c) 1989-2014.
    1010 *  On-Line Applications Research Corporation (OAR).
    1111 *
     
    1919#endif
    2020
     21#if !defined(RTEMS_SMP)
    2122#include <rtems/rtems/tasks.h>
    2223#include <rtems/score/threadimpl.h>
     
    8990  return RTEMS_INVALID_ID;
    9091}
     92#endif
  • cpukit/rtems/src/taskvariabledelete.c

    rcae120e2 rd507c037  
    77
    88/*
    9  *  COPYRIGHT (c) 1989-2007.
     9 *  COPYRIGHT (c) 1989-2014.
    1010 *  On-Line Applications Research Corporation (OAR).
    1111 *
     
    1919#endif
    2020
     21#if !defined(RTEMS_SMP)
    2122#include <rtems/rtems/tasksimpl.h>
    2223#include <rtems/score/threadimpl.h>
     
    7879  return RTEMS_INVALID_ID;
    7980}
     81#endif
  • cpukit/rtems/src/taskvariableget.c

    rcae120e2 rd507c037  
    77
    88/*
    9  *  COPYRIGHT (c) 1989-2007.
     9 *  COPYRIGHT (c) 1989-2014.
    1010 *  On-Line Applications Research Corporation (OAR).
    1111 *
     
    1919#endif
    2020
     21#if !defined(RTEMS_SMP)
    2122#include <rtems/rtems/tasksimpl.h>
    2223#include <rtems/score/threadimpl.h>
     
    8687  return RTEMS_INVALID_ID;
    8788}
     89#endif
  • cpukit/sapi/include/confdefs.h

    rcae120e2 rd507c037  
    15921592  #endif
    15931593
    1594   /**
    1595    * This macro calculates the memory required for task variables.
    1596    *
    1597    * NOTE: Each task variable is individually allocated from the Workspace.
    1598    *       Hence, we do the multiplication on the configured size.
    1599    */
     1594/**
     1595 * This macro calculates the memory required for task variables.
     1596 *
     1597 * Each task variable is individually allocated from the Workspace.
     1598 * Hence, we do the multiplication on the configured size.
     1599 *
     1600 * @note Per-task variables are disabled for SMP configurations.
     1601 */
     1602#if defined(RTEMS_SMP)
     1603  #ifdef CONFIGURE_MAXIMUM_TASK_VARIABLES
     1604    #error "Per-Task Variables are not safe for SMP systems and disabled"
     1605  #endif
     1606  #define CONFIGURE_MAXIMUM_TASK_VARIABLES                     0
     1607  #define CONFIGURE_MEMORY_FOR_TASK_VARIABLES(_task_variables) 0
     1608#else
    16001609  #ifndef CONFIGURE_MAXIMUM_TASK_VARIABLES
    16011610    #define CONFIGURE_MAXIMUM_TASK_VARIABLES                     0
     
    16061615         _Configure_From_workspace(sizeof(rtems_task_variable_t))
    16071616  #endif
     1617#endif
    16081618
    16091619  #ifndef CONFIGURE_MAXIMUM_TIMERS
  • cpukit/score/include/rtems/score/thread.h

    rcae120e2 rd507c037  
    172172typedef void (*Thread_CPU_budget_algorithm_callout )( Thread_Control * );
    173173
     174#if !defined(RTEMS_SMP)
    174175/**
    175176 *  @brief Forward reference to the per task variable structure..
     
    198199  void                          (*dtor)(void *);
    199200} rtems_task_variable_t;
     201#endif
    200202
    201203/**
     
    568570  void                                **extensions;
    569571
     572#if !defined(RTEMS_SMP)
    570573  /** This field points to the set of per task variables. */
    571574  rtems_task_variable_t                *task_variables;
     575#endif
    572576
    573577  /**
  • doc/user/task.t

    rcae120e2 rd507c037  
    11@c
    2 @c  COPYRIGHT (c) 1988-2008.
     2@c  COPYRIGHT (c) 1988-2014.
    33@c  On-Line Applications Research Corporation (OAR).
    44@c  All rights reserved.
     
    340340A critical point with per-task variables is that each task must separately
    341341request that the same global variable is per-task private.
     342
     343@b{WARNING}: Per-Task variables are inherently broken on SMP systems. They
     344only work correctly when there is one task executing in the system and
     345that task is the logical owner of the value in the per-task variable's
     346location. There is no way for a single memory image to contain the
     347correct value for each task executing on each core. Consequently,
     348per-task variables are disabled in SMP configurations of RTEMS.
    342349
    343350@subsection Building a Task Attribute Set
     
    17801787In this case the destructor function could be `free'.
    17811788
     1789Per-task variables are disabled in SMP configurations and this service
     1790is not available.
     1791
    17821792@page
    17831793
     
    18331843should be considered volatile.
    18341844
     1845Per-task variables are disabled in SMP configurations and this service
     1846is not available.
     1847
    18351848@page
    18361849
     
    18751888@subheading NOTES:
    18761889
    1877 NONE
     1890Per-task variables are disabled in SMP configurations and this service
     1891is not available.
     1892
  • testsuites/psxtests/psxconfig01/init.c

    rcae120e2 rd507c037  
    88
    99/*
     10 * Copyright (c) 2014. On-Line Applications Research Corporation (OAR).
    1011 * Copyright (c) 2011-2012 embedded brains GmbH.  All rights reserved.
    1112 *
     
    5253#define CONFIGURE_MAXIMUM_SEMAPHORES 47
    5354#define CONFIGURE_MAXIMUM_TASKS 11
    54 #define CONFIGURE_MAXIMUM_TASK_VARIABLES 13
     55#if !defined(RTEMS_SMP)
     56  #define CONFIGURE_MAXIMUM_TASK_VARIABLES 13
     57#endif
    5558#define CONFIGURE_MAXIMUM_TIMERS 59
    5659#define CONFIGURE_MAXIMUM_USER_EXTENSIONS 17
     
    197200static char posix_name [NAME_MAX];
    198201
    199 static void *task_var;
     202#if !defined(RTEMS_SMP)
     203  static void *task_var;
     204#endif
    200205
    201206static char *get_posix_name(char a, char b, char c, int i)
     
    209214}
    210215
     216#if !defined(RTEMS_SMP)
    211217static void task_var_dtor(void *var __attribute__((unused)))
    212218{
    213219  /* Do nothing */
    214220}
     221#endif
    215222
    216223static void *posix_thread(void *arg __attribute__((unused)))
     
    404411#endif
    405412
     413#if !defined(RTEMS_SMP)
    406414#ifdef CONFIGURE_MAXIMUM_TASK_VARIABLES
    407415  for (i = 0; i < CONFIGURE_MAXIMUM_TASK_VARIABLES; ++i) {
     
    409417    directive_failed(sc, "rtems_task_variable_add");
    410418  }
     419#endif
    411420#endif
    412421
  • testsuites/smptests/smpunsupported01/init.c

    rcae120e2 rd507c037  
    11/*
     2 * Copyright (c) 2014 On-Line Applications Research Corporation (OAR).
    23 * Copyright (c) 2013-2014 embedded brains GmbH.  All rights reserved.
    34 *
     
    2829
    2930  rtems_test_assert(rtems_configuration_is_smp_enabled());
    30 
    31   sc = rtems_task_variable_add(RTEMS_SELF, NULL, NULL);
    32   rtems_test_assert(sc == RTEMS_NOT_IMPLEMENTED);
    33 
    34   sc = rtems_task_variable_delete(RTEMS_SELF, NULL);
    35   rtems_test_assert(sc == RTEMS_NOT_IMPLEMENTED);
    36 
    37   sc = rtems_task_variable_get(RTEMS_SELF, NULL, NULL);
    38   rtems_test_assert(sc == RTEMS_NOT_IMPLEMENTED);
    3931
    4032  sc = rtems_task_mode(RTEMS_NO_PREEMPT, RTEMS_PREEMPT_MASK, &mode);
  • testsuites/sptests/Makefile.am

    rcae120e2 rd507c037  
    66         sp01 sp02 sp03 sp04 sp05 sp06 sp07 sp08 \
    77    sp10 sp11 sp12 sp13 sp14 sp15 sp16 sp17 sp18 sp19 \
    8     sp20 sp21 sp22 sp23 sp24 sp25 sp26 sp27 sp27a sp28 sp29 \
     8    sp20 sp21 sp22 sp23 sp24 sp25 sp26 sp27 sp27a           \
    99    sp30 sp31 sp32 sp33 sp34 sp35      sp37 sp38 sp39 \
    1010    sp40 sp41 sp42 sp43 sp44 sp45 sp46 sp47 sp48 sp49 \
     
    3434    spsem_err02 sptask_err01 spevent_err03 sptask_err03 sptask_err02 \
    3535    sptask_err04 spclock_err01
     36if HAS_SMP
     37else
     38SUBDIRS += sp29
     39endif
     40 SUBDIRS += spprofiling01
    3641SUBDIRS += spfatal28
    3742SUBDIRS += spthreadlife01
  • testsuites/sptests/configure.ac

    rcae120e2 rd507c037  
    3434AC_CHECK_HEADERS([sys/cpuset.h])
    3535AM_CONDITIONAL(HAS_CPUSET,test x"${ac_cv_header_sys_cpuset_h}" = x"yes")
     36
     37# Some tests should not be built/run in SMP configurations
     38RTEMS_CHECK_CPUOPTS([RTEMS_SMP])
     39AM_CONDITIONAL(HAS_SMP,test "$rtems_cv_RTEMS_SMP" = "yes")
    3640
    3741# Explicitly list all Makefiles here
Note: See TracChangeset for help on using the changeset viewer.