Changeset a7dcef97 in rtems


Ignore:
Timestamp:
Nov 17, 2017, 5:36:54 AM (2 years ago)
Author:
Sebastian Huber <sebastian.huber@…>
Branches:
master
Children:
cd3e220
Parents:
a8bf9a3
git-author:
Sebastian Huber <sebastian.huber@…> (11/17/17 05:36:54)
git-committer:
Sebastian Huber <sebastian.huber@…> (11/22/17 08:40:22)
Message:

score: Simplify global construction

Update #3243.

Files:
4 added
1 deleted
8 edited

Legend:

Unmodified
Added
Removed
  • cpukit/posix/src/pthreadinitthreads.c

    ra8bf9a3 ra7dcef97  
    3232#include <rtems/posix/priorityimpl.h>
    3333#include <rtems/posix/config.h>
    34 #include <rtems/rtems/config.h>
    35 
    36 static void *_POSIX_Global_construction( void *arg )
    37 {
    38   Thread_Control           *executing = _Thread_Get_executing();
    39   Thread_Entry_information  entry = executing->Start.Entry;
    40 
    41   entry.Kinds.Pointer.entry = Configuration_POSIX_API
    42     .User_initialization_threads_table[ 0 ].thread_entry;
    43 
    44   (void) arg;
    45   _Thread_Global_construction( executing, &entry );
    46 }
    4734
    4835void _POSIX_Threads_Initialize_user_threads_body(void)
     
    5441  pthread_t                           thread_id;
    5542  pthread_attr_t                      attr;
    56   bool                                register_global_construction;
    5743  void                             *(*thread_entry)(void *);
    5844
     
    6248  if ( !user_threads )
    6349    return;
    64 
    65   register_global_construction =
    66     Configuration_RTEMS_API.number_of_initialization_tasks == 0;
    6750
    6851  /*
     
    8972    }
    9073
    91     if ( register_global_construction ) {
    92       register_global_construction = false;
    93       thread_entry = _POSIX_Global_construction;
    94     }
    95 
    9674    eno = pthread_create(
    9775      &thread_id,
     
    10381      _Internal_error( INTERNAL_ERROR_POSIX_INIT_THREAD_CREATE_FAILED );
    10482    }
     83
     84    if ( _Thread_Global_constructor == 0 ) {
     85      _Thread_Global_constructor = thread_id;
     86    }
    10587  }
    10688}
  • cpukit/rtems/src/taskinitusers.c

    ra8bf9a3 ra7dcef97  
    3030#include <rtems/score/wkspace.h>
    3131
    32 static void _RTEMS_Global_construction( rtems_task_argument arg )
    33 {
    34   Thread_Control           *executing = _Thread_Get_executing();
    35   Thread_Entry_information  entry = executing->Start.Entry;
    36 
    37   entry.Kinds.Numeric.entry =
    38     Configuration_RTEMS_API.User_initialization_tasks_table[ 0 ].entry_point;
    39 
    40   (void) arg;
    41   _Thread_Global_construction( executing, &entry );
    42 }
    43 
    4432/*
    4533 *  _RTEMS_tasks_Initialize_user_tasks_body
     
    6048  rtems_status_code                 return_value;
    6149  rtems_initialization_tasks_table *user_tasks;
    62   bool                              register_global_construction;
    6350  rtems_task_entry                  entry_point;
    6451
     
    7461  if ( !user_tasks )
    7562    return;
    76 
    77   register_global_construction = true;
    7863
    7964  /*
     
    9883    }
    9984
    100     if ( register_global_construction ) {
    101       register_global_construction = false;
    102       entry_point = _RTEMS_Global_construction;
    103     }
    104 
    10585    return_value = rtems_task_start(
    10686      id,
     
    11090    _Assert( rtems_is_status_successful( return_value ) );
    11191    (void) return_value;
     92
     93    if ( _Thread_Global_constructor == 0 ) {
     94      _Thread_Global_constructor = id;
     95    }
    11296  }
    11397}
  • cpukit/score/Makefile.am

    ra8bf9a3 ra7dcef97  
    293293libscore_a_SOURCES += src/threadentryadaptorpointer.c
    294294libscore_a_SOURCES += src/threadgetcputimeused.c
    295 libscore_a_SOURCES += src/threadglobalconstruction.c
    296295libscore_a_SOURCES += src/threaditerate.c
    297296libscore_a_SOURCES += src/threadname.c
  • cpukit/score/include/rtems/score/threadimpl.h

    ra8bf9a3 ra7dcef97  
    7171
    7272/**
     73 * @brief Object identifier of the global constructor thread.
     74 *
     75 * This variable is set by _RTEMS_tasks_Initialize_user_tasks_body() or
     76 * _POSIX_Threads_Initialize_user_threads_body().
     77 *
     78 * It is consumed by _Thread_Handler().
     79 */
     80extern Objects_Id _Thread_Global_constructor;
     81
     82/**
    7383 *  The following points to the thread whose floating point
    7484 *  context is currently loaded.
     
    345355 */
    346356void _Thread_Handler( void );
    347 
    348 /**
    349  * @brief Executes the global constructors and then restarts itself as the
    350  * first initialization thread.
    351  *
    352  * The first initialization thread is the first RTEMS initialization task or
    353  * the first POSIX initialization thread in case no RTEMS initialization tasks
    354  * are present.
    355  */
    356 void _Thread_Global_construction(
    357   Thread_Control                 *executing,
    358   const Thread_Entry_information *entry
    359 ) RTEMS_NO_RETURN;
    360357
    361358RTEMS_INLINE_ROUTINE void _Thread_State_acquire_critical(
  • cpukit/score/src/threadhandler.c

    ra8bf9a3 ra7dcef97  
    2424#include <rtems/score/isrlevel.h>
    2525#include <rtems/score/userextimpl.h>
     26
     27/*
     28 *  Conditional magic to determine what style of C++ constructor
     29 *  initialization this target and compiler version uses.
     30 */
     31#if defined(__USE_INIT_FINI__)
     32  #if defined(__ARM_EABI__)
     33    #define INIT_NAME __libc_init_array
     34  #else
     35    #define INIT_NAME _init
     36  #endif
     37
     38  extern void INIT_NAME(void);
     39  #define EXECUTE_GLOBAL_CONSTRUCTORS
     40#endif
     41
     42#if defined(__USE__MAIN__)
     43  extern void __main(void);
     44  #define INIT_NAME __main
     45  #define EXECUTE_GLOBAL_CONSTRUCTORS
     46#endif
     47
     48Objects_Id _Thread_Global_constructor;
     49
     50static void _Thread_Global_construction( Thread_Control *executing )
     51{
     52#if defined(EXECUTE_GLOBAL_CONSTRUCTORS)
     53  if ( executing->Object.id == _Thread_Global_constructor ) {
     54    /*
     55     * Prevent double construction in case the initialization thread is deleted
     56     * and then recycled.  There is not need for extra synchronization since
     57     * this variable is set during the sequential system boot procedure.
     58     */
     59    _Thread_Global_constructor = 0;
     60
     61    /*
     62     *  _init could be a weak symbol and we SHOULD test it but it isn't
     63     *  in any configuration I know of and it generates a warning on every
     64     *  RTEMS target configuration.  --joel (12 May 2007)
     65     */
     66    INIT_NAME();
     67  }
     68#endif
     69}
    2670
    2771void _Thread_Handler( void )
     
    81125  _User_extensions_Thread_begin( executing );
    82126
     127  _Thread_Global_construction( executing );
     128
    83129  /*
    84130   *  RTEMS supports multiple APIs and each API can define a different
  • testsuites/sptests/Makefile.am

    ra8bf9a3 ra7dcef97  
    6565_SUBDIRS += spcache01
    6666_SUBDIRS += sptls03
     67_SUBDIRS += sptls04
    6768_SUBDIRS += spcpucounter01
    6869if HAS_CPLUSPLUS
  • testsuites/sptests/configure.ac

    ra8bf9a3 ra7dcef97  
    3737# Explicitly list all Makefiles here
    3838AC_CONFIG_FILES([Makefile
     39sptls04/Makefile
    3940spconsole01/Makefile
    4041spintrcritical24/Makefile
  • testsuites/sptests/spextensions01/init.c

    ra8bf9a3 ra7dcef97  
    319319  if (source == RTEMS_FATAL_SOURCE_EXIT) {
    320320    assert_forward_order(3);
    321     assert(counter == 72);
     321    assert(counter == 68);
    322322    TEST_END();
    323323  }
     
    454454
    455455  active_extensions = 4;
    456   assert(counter == 14);
    457   counter = 16;
     456  assert(counter == 10);
     457  counter = 12;
    458458
    459459  sc = rtems_task_create(
Note: See TracChangeset for help on using the changeset viewer.