Changeset 6f6da82c in rtems


Ignore:
Timestamp:
Jan 26, 2017, 10:06:50 AM (5 years ago)
Author:
Sebastian Huber <sebastian.huber@…>
Branches:
5, master
Children:
abc963d
Parents:
d1505a1
git-author:
Sebastian Huber <sebastian.huber@…> (01/26/17 10:06:50)
git-committer:
Sebastian Huber <sebastian.huber@…> (01/26/17 10:20:45)
Message:

score: Fix user extensions order

Use forward and reverse order for initial and dynamic extensions. This
is the behaviour documented in the C Users Guide. Change thread
terminate order to backward to be in line with the thread delete order.
Change fatal error order to forward to ensure that initial extensions
are called first due the peculiar execution context of fatal error
extensions, see _Terminate() documentation.

Update #2692.

Files:
5 edited

Legend:

Unmodified
Added
Removed
  • cpukit/score/include/rtems/score/userextimpl.h

    rd1505a1 r6f6da82c  
    308308    &ctx,
    309309    _User_extensions_Fatal_visitor,
    310     CHAIN_ITERATOR_BACKWARD
     310    CHAIN_ITERATOR_FORWARD
    311311  );
    312312}
     
    319319    executing,
    320320    _User_extensions_Thread_terminate_visitor,
    321     CHAIN_ITERATOR_FORWARD
     321    CHAIN_ITERATOR_BACKWARD
    322322  );
    323323}
  • cpukit/score/include/rtems/sysinit.h

    rd1505a1 r6f6da82c  
    5656#define RTEMS_SYSINIT_POSIX_RWLOCK               000368
    5757#define RTEMS_SYSINIT_POSIX_SHM                  000369
    58 #define RTEMS_SYSINIT_POSIX_CLEANUP              00036a
    59 #define RTEMS_SYSINIT_POSIX_KEYS                 00036b
     58#define RTEMS_SYSINIT_POSIX_KEYS                 00036a
     59#define RTEMS_SYSINIT_POSIX_CLEANUP              00036b
    6060#define RTEMS_SYSINIT_IDLE_THREADS               000380
    6161#define RTEMS_SYSINIT_LIBIO                      000400
  • cpukit/score/src/userextiterate.c

    rd1505a1 r6f6da82c  
    88
    99/*
    10  * Copyright (c) 2012, 2016 embedded brains GmbH.  All rights reserved.
     10 * Copyright (c) 2012, 2017 embedded brains GmbH.  All rights reserved.
    1111 *
    1212 *  embedded brains GmbH
     
    155155{
    156156  Thread_Control              *executing;
    157   const User_extensions_Table *callouts_current;
    158   const User_extensions_Table *callouts_end;
     157  const User_extensions_Table *initial_current;
     158  const User_extensions_Table *initial_begin;
     159  const User_extensions_Table *initial_end;
    159160  const Chain_Node            *end;
    160161  Chain_Node                  *node;
     
    164165  executing = _Thread_Get_executing();
    165166
    166   callouts_current = rtems_configuration_get_user_extension_table();
    167   callouts_end = callouts_current
    168     + rtems_configuration_get_number_of_initial_extensions();
    169 
    170   while ( callouts_current != callouts_end ) {
    171     (*visitor)( executing, arg, callouts_current );
    172 
    173     ++callouts_current;
    174   }
     167  initial_begin = rtems_configuration_get_user_extension_table();
     168  initial_end =
     169    initial_begin + rtems_configuration_get_number_of_initial_extensions();
    175170
    176171  if ( direction == CHAIN_ITERATOR_FORWARD ) {
     172    initial_current = initial_begin;
     173
     174    while ( initial_current != initial_end ) {
     175      (*visitor)( executing, arg, initial_current );
     176      ++initial_current;
     177    }
     178
    177179    end = _Chain_Immutable_tail( &_User_extensions_List.Active );
    178180  } else {
     
    214216
    215217  _User_extensions_Release( &lock_context );
    216 }
     218
     219  if ( direction == CHAIN_ITERATOR_BACKWARD ) {
     220    initial_current = initial_end;
     221
     222    while ( initial_current != initial_begin ) {
     223      --initial_current;
     224      (*visitor)( executing, arg, initial_current );
     225    }
     226  }
     227}
  • testsuites/sptests/spextensions01/init.c

    rd1505a1 r6f6da82c  
    11/*
    2  * Copyright (c) 2016 embedded brains GmbH.  All rights reserved.
     2 * Copyright (c) 2016, 2017 embedded brains GmbH.  All rights reserved.
    33 *
    44 *  embedded brains GmbH
     
    8181}
    8282
    83 static void assert_static_order(int index)
     83static void assert_forward_order(int index)
    8484{
    8585  assert((counter % active_extensions) == index);
     
    8787}
    8888
    89 static void assert_forward_order(int index)
    90 {
    91   assert((counter % active_extensions) == index);
     89static void assert_reverse_order(int index)
     90{
     91  assert((counter % active_extensions) == (active_extensions - 1 - index));
    9292  ++counter;
    9393}
    9494
    95 static void assert_reverse_order(int index)
    96 {
    97   assert((counter % active_extensions) == (5 - index));
    98   ++counter;
    99 }
    100 
    10195static bool zero_thread_create(rtems_tcb *a, rtems_tcb *b)
    10296{
    103   assert_static_order(0);
     97  assert_forward_order(0);
    10498  assert_allocator_protected_thread_context();
    10599  return true;
     
    108102static void zero_thread_start(rtems_tcb *a, rtems_tcb *b)
    109103{
    110   assert_static_order(0);
     104  assert_forward_order(0);
    111105  assert_thread_dispatch_disabled_context();
    112106}
     
    114108static void zero_thread_restart(rtems_tcb *a, rtems_tcb *b)
    115109{
    116   assert_static_order(0);
     110  assert_forward_order(0);
    117111  assert_life_protected_thread_context();
    118112}
     
    120114static void zero_thread_delete(rtems_tcb *a, rtems_tcb *b)
    121115{
    122   assert_static_order(0);
     116  assert_reverse_order(0);
    123117  assert_allocator_protected_thread_context();
    124118}
     
    126120static void zero_thread_switch(rtems_tcb *a, rtems_tcb *b)
    127121{
    128   assert_static_order(0);
     122  assert_forward_order(0);
    129123}
    130124
    131125static void zero_thread_begin(rtems_tcb *a)
    132126{
    133   assert_static_order(0);
     127  assert_forward_order(0);
    134128  assert_normal_thread_context();
    135129}
     
    137131static void zero_thread_exitted(rtems_tcb *a)
    138132{
    139   assert_static_order(0);
     133  assert_forward_order(0);
    140134  assert_normal_thread_context();
    141135}
     
    148142{
    149143  if (source == RTEMS_FATAL_SOURCE_EXIT) {
    150     assert_static_order(0);
     144    assert_forward_order(0);
    151145  }
    152146}
     
    154148static void zero_thread_terminate(rtems_tcb *a)
    155149{
    156   assert_static_order(0);
     150  assert_reverse_order(0);
    157151  assert_life_protected_thread_context();
    158152}
     
    160154static bool one_thread_create(rtems_tcb *a, rtems_tcb *b)
    161155{
    162   assert_static_order(1);
     156  assert_forward_order(1);
    163157  assert_allocator_protected_thread_context();
    164158  return true;
     
    167161static void one_thread_start(rtems_tcb *a, rtems_tcb *b)
    168162{
    169   assert_static_order(1);
     163  assert_forward_order(1);
    170164  assert_thread_dispatch_disabled_context();
    171165}
     
    173167static void one_thread_restart(rtems_tcb *a, rtems_tcb *b)
    174168{
    175   assert_static_order(1);
     169  assert_forward_order(1);
    176170  assert_life_protected_thread_context();
    177171}
     
    179173static void one_thread_delete(rtems_tcb *a, rtems_tcb *b)
    180174{
    181   assert_static_order(1);
     175  assert_reverse_order(1);
    182176  assert_allocator_protected_thread_context();
    183177}
     
    185179static void one_thread_switch(rtems_tcb *a, rtems_tcb *b)
    186180{
    187   assert_static_order(1);
     181  assert_forward_order(1);
    188182}
    189183
    190184static void one_thread_begin(rtems_tcb *a)
    191185{
    192   assert_static_order(1);
     186  assert_forward_order(1);
    193187  assert_normal_thread_context();
    194188}
     
    196190static void one_thread_exitted(rtems_tcb *a)
    197191{
    198   assert_static_order(1);
     192  assert_forward_order(1);
    199193  assert_normal_thread_context();
    200194}
     
    207201{
    208202  if (source == RTEMS_FATAL_SOURCE_EXIT) {
    209     assert_static_order(1);
     203    assert_forward_order(1);
    210204  }
    211205}
     
    213207static void one_thread_terminate(rtems_tcb *a)
    214208{
    215   assert_static_order(1);
     209  assert_reverse_order(1);
    216210  assert_life_protected_thread_context();
    217211}
     
    232226static void two_thread_restart(rtems_tcb *a, rtems_tcb *b)
    233227{
    234   assert_static_order(2);
     228  assert_forward_order(2);
    235229  assert_life_protected_thread_context();
    236230}
     
    266260{
    267261  if (source == RTEMS_FATAL_SOURCE_EXIT) {
    268     assert_reverse_order(2);
    269     assert(counter == 72);
    270     TEST_END();
     262    assert_forward_order(2);
    271263  }
    272264}
     
    274266static void two_thread_terminate(rtems_tcb *a)
    275267{
    276   assert_forward_order(2);
     268  assert_reverse_order(2);
    277269  assert_life_protected_thread_context();
    278270}
     
    293285static void three_thread_restart(rtems_tcb *a, rtems_tcb *b)
    294286{
    295   assert_static_order(3);
     287  assert_forward_order(3);
    296288  assert_life_protected_thread_context();
    297289}
     
    327319{
    328320  if (source == RTEMS_FATAL_SOURCE_EXIT) {
    329     assert_reverse_order(3);
     321    assert_forward_order(3);
     322    assert(counter == 72);
     323    TEST_END();
    330324  }
    331325}
     
    333327static void three_thread_terminate(rtems_tcb *a)
    334328{
    335   assert_forward_order(3);
     329  assert_reverse_order(3);
    336330  assert_life_protected_thread_context();
    337331}
  • testsuites/sptests/spsysinit01/init.c

    rd1505a1 r6f6da82c  
    121121  POSIX_SHM_PRE,
    122122  POSIX_SHM_POST,
     123#endif /* RTEMS_POSIX_API */
     124  POSIX_KEYS_PRE,
     125  POSIX_KEYS_POST,
     126#ifdef RTEMS_POSIX_API
    123127  POSIX_CLEANUP_PRE,
    124128  POSIX_CLEANUP_POST,
    125129#endif /* RTEMS_POSIX_API */
    126   POSIX_KEYS_PRE,
    127   POSIX_KEYS_POST,
    128130  IDLE_THREADS_PRE,
    129131  IDLE_THREADS_POST,
Note: See TracChangeset for help on using the changeset viewer.