forked from Imagelibrary/rtems
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.
This commit is contained in:
@@ -307,7 +307,7 @@ static inline void _User_extensions_Fatal(
|
||||
_User_extensions_Iterate(
|
||||
&ctx,
|
||||
_User_extensions_Fatal_visitor,
|
||||
CHAIN_ITERATOR_BACKWARD
|
||||
CHAIN_ITERATOR_FORWARD
|
||||
);
|
||||
}
|
||||
|
||||
@@ -318,7 +318,7 @@ static inline void _User_extensions_Thread_terminate(
|
||||
_User_extensions_Iterate(
|
||||
executing,
|
||||
_User_extensions_Thread_terminate_visitor,
|
||||
CHAIN_ITERATOR_FORWARD
|
||||
CHAIN_ITERATOR_BACKWARD
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -55,8 +55,8 @@ extern "C" {
|
||||
#define RTEMS_SYSINIT_POSIX_BARRIER 000367
|
||||
#define RTEMS_SYSINIT_POSIX_RWLOCK 000368
|
||||
#define RTEMS_SYSINIT_POSIX_SHM 000369
|
||||
#define RTEMS_SYSINIT_POSIX_CLEANUP 00036a
|
||||
#define RTEMS_SYSINIT_POSIX_KEYS 00036b
|
||||
#define RTEMS_SYSINIT_POSIX_KEYS 00036a
|
||||
#define RTEMS_SYSINIT_POSIX_CLEANUP 00036b
|
||||
#define RTEMS_SYSINIT_IDLE_THREADS 000380
|
||||
#define RTEMS_SYSINIT_LIBIO 000400
|
||||
#define RTEMS_SYSINIT_ROOT_FILESYSTEM 000401
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2012, 2016 embedded brains GmbH. All rights reserved.
|
||||
* Copyright (c) 2012, 2017 embedded brains GmbH. All rights reserved.
|
||||
*
|
||||
* embedded brains GmbH
|
||||
* Dornierstr. 4
|
||||
@@ -154,8 +154,9 @@ void _User_extensions_Iterate(
|
||||
)
|
||||
{
|
||||
Thread_Control *executing;
|
||||
const User_extensions_Table *callouts_current;
|
||||
const User_extensions_Table *callouts_end;
|
||||
const User_extensions_Table *initial_current;
|
||||
const User_extensions_Table *initial_begin;
|
||||
const User_extensions_Table *initial_end;
|
||||
const Chain_Node *end;
|
||||
Chain_Node *node;
|
||||
User_extensions_Iterator iter;
|
||||
@@ -163,17 +164,18 @@ void _User_extensions_Iterate(
|
||||
|
||||
executing = _Thread_Get_executing();
|
||||
|
||||
callouts_current = rtems_configuration_get_user_extension_table();
|
||||
callouts_end = callouts_current
|
||||
+ rtems_configuration_get_number_of_initial_extensions();
|
||||
|
||||
while ( callouts_current != callouts_end ) {
|
||||
(*visitor)( executing, arg, callouts_current );
|
||||
|
||||
++callouts_current;
|
||||
}
|
||||
initial_begin = rtems_configuration_get_user_extension_table();
|
||||
initial_end =
|
||||
initial_begin + rtems_configuration_get_number_of_initial_extensions();
|
||||
|
||||
if ( direction == CHAIN_ITERATOR_FORWARD ) {
|
||||
initial_current = initial_begin;
|
||||
|
||||
while ( initial_current != initial_end ) {
|
||||
(*visitor)( executing, arg, initial_current );
|
||||
++initial_current;
|
||||
}
|
||||
|
||||
end = _Chain_Immutable_tail( &_User_extensions_List.Active );
|
||||
} else {
|
||||
end = _Chain_Immutable_head( &_User_extensions_List.Active );
|
||||
@@ -213,4 +215,13 @@ void _User_extensions_Iterate(
|
||||
_Chain_Iterator_destroy( &iter.Iterator );
|
||||
|
||||
_User_extensions_Release( &lock_context );
|
||||
|
||||
if ( direction == CHAIN_ITERATOR_BACKWARD ) {
|
||||
initial_current = initial_end;
|
||||
|
||||
while ( initial_current != initial_begin ) {
|
||||
--initial_current;
|
||||
(*visitor)( executing, arg, initial_current );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2016 embedded brains GmbH. All rights reserved.
|
||||
* Copyright (c) 2016, 2017 embedded brains GmbH. All rights reserved.
|
||||
*
|
||||
* embedded brains GmbH
|
||||
* Dornierstr. 4
|
||||
@@ -80,12 +80,6 @@ static void assert_thread_dispatch_disabled_context(void)
|
||||
assert(!life_protected());
|
||||
}
|
||||
|
||||
static void assert_static_order(int index)
|
||||
{
|
||||
assert((counter % active_extensions) == index);
|
||||
++counter;
|
||||
}
|
||||
|
||||
static void assert_forward_order(int index)
|
||||
{
|
||||
assert((counter % active_extensions) == index);
|
||||
@@ -94,49 +88,49 @@ static void assert_forward_order(int index)
|
||||
|
||||
static void assert_reverse_order(int index)
|
||||
{
|
||||
assert((counter % active_extensions) == (5 - index));
|
||||
assert((counter % active_extensions) == (active_extensions - 1 - index));
|
||||
++counter;
|
||||
}
|
||||
|
||||
static bool zero_thread_create(rtems_tcb *a, rtems_tcb *b)
|
||||
{
|
||||
assert_static_order(0);
|
||||
assert_forward_order(0);
|
||||
assert_allocator_protected_thread_context();
|
||||
return true;
|
||||
}
|
||||
|
||||
static void zero_thread_start(rtems_tcb *a, rtems_tcb *b)
|
||||
{
|
||||
assert_static_order(0);
|
||||
assert_forward_order(0);
|
||||
assert_thread_dispatch_disabled_context();
|
||||
}
|
||||
|
||||
static void zero_thread_restart(rtems_tcb *a, rtems_tcb *b)
|
||||
{
|
||||
assert_static_order(0);
|
||||
assert_forward_order(0);
|
||||
assert_life_protected_thread_context();
|
||||
}
|
||||
|
||||
static void zero_thread_delete(rtems_tcb *a, rtems_tcb *b)
|
||||
{
|
||||
assert_static_order(0);
|
||||
assert_reverse_order(0);
|
||||
assert_allocator_protected_thread_context();
|
||||
}
|
||||
|
||||
static void zero_thread_switch(rtems_tcb *a, rtems_tcb *b)
|
||||
{
|
||||
assert_static_order(0);
|
||||
assert_forward_order(0);
|
||||
}
|
||||
|
||||
static void zero_thread_begin(rtems_tcb *a)
|
||||
{
|
||||
assert_static_order(0);
|
||||
assert_forward_order(0);
|
||||
assert_normal_thread_context();
|
||||
}
|
||||
|
||||
static void zero_thread_exitted(rtems_tcb *a)
|
||||
{
|
||||
assert_static_order(0);
|
||||
assert_forward_order(0);
|
||||
assert_normal_thread_context();
|
||||
}
|
||||
|
||||
@@ -147,55 +141,55 @@ static void zero_fatal(
|
||||
)
|
||||
{
|
||||
if (source == RTEMS_FATAL_SOURCE_EXIT) {
|
||||
assert_static_order(0);
|
||||
assert_forward_order(0);
|
||||
}
|
||||
}
|
||||
|
||||
static void zero_thread_terminate(rtems_tcb *a)
|
||||
{
|
||||
assert_static_order(0);
|
||||
assert_reverse_order(0);
|
||||
assert_life_protected_thread_context();
|
||||
}
|
||||
|
||||
static bool one_thread_create(rtems_tcb *a, rtems_tcb *b)
|
||||
{
|
||||
assert_static_order(1);
|
||||
assert_forward_order(1);
|
||||
assert_allocator_protected_thread_context();
|
||||
return true;
|
||||
}
|
||||
|
||||
static void one_thread_start(rtems_tcb *a, rtems_tcb *b)
|
||||
{
|
||||
assert_static_order(1);
|
||||
assert_forward_order(1);
|
||||
assert_thread_dispatch_disabled_context();
|
||||
}
|
||||
|
||||
static void one_thread_restart(rtems_tcb *a, rtems_tcb *b)
|
||||
{
|
||||
assert_static_order(1);
|
||||
assert_forward_order(1);
|
||||
assert_life_protected_thread_context();
|
||||
}
|
||||
|
||||
static void one_thread_delete(rtems_tcb *a, rtems_tcb *b)
|
||||
{
|
||||
assert_static_order(1);
|
||||
assert_reverse_order(1);
|
||||
assert_allocator_protected_thread_context();
|
||||
}
|
||||
|
||||
static void one_thread_switch(rtems_tcb *a, rtems_tcb *b)
|
||||
{
|
||||
assert_static_order(1);
|
||||
assert_forward_order(1);
|
||||
}
|
||||
|
||||
static void one_thread_begin(rtems_tcb *a)
|
||||
{
|
||||
assert_static_order(1);
|
||||
assert_forward_order(1);
|
||||
assert_normal_thread_context();
|
||||
}
|
||||
|
||||
static void one_thread_exitted(rtems_tcb *a)
|
||||
{
|
||||
assert_static_order(1);
|
||||
assert_forward_order(1);
|
||||
assert_normal_thread_context();
|
||||
}
|
||||
|
||||
@@ -206,13 +200,13 @@ static void one_fatal(
|
||||
)
|
||||
{
|
||||
if (source == RTEMS_FATAL_SOURCE_EXIT) {
|
||||
assert_static_order(1);
|
||||
assert_forward_order(1);
|
||||
}
|
||||
}
|
||||
|
||||
static void one_thread_terminate(rtems_tcb *a)
|
||||
{
|
||||
assert_static_order(1);
|
||||
assert_reverse_order(1);
|
||||
assert_life_protected_thread_context();
|
||||
}
|
||||
|
||||
@@ -231,7 +225,7 @@ static void two_thread_start(rtems_tcb *a, rtems_tcb *b)
|
||||
|
||||
static void two_thread_restart(rtems_tcb *a, rtems_tcb *b)
|
||||
{
|
||||
assert_static_order(2);
|
||||
assert_forward_order(2);
|
||||
assert_life_protected_thread_context();
|
||||
}
|
||||
|
||||
@@ -265,15 +259,13 @@ static void two_fatal(
|
||||
)
|
||||
{
|
||||
if (source == RTEMS_FATAL_SOURCE_EXIT) {
|
||||
assert_reverse_order(2);
|
||||
assert(counter == 72);
|
||||
TEST_END();
|
||||
assert_forward_order(2);
|
||||
}
|
||||
}
|
||||
|
||||
static void two_thread_terminate(rtems_tcb *a)
|
||||
{
|
||||
assert_forward_order(2);
|
||||
assert_reverse_order(2);
|
||||
assert_life_protected_thread_context();
|
||||
}
|
||||
|
||||
@@ -292,7 +284,7 @@ static void three_thread_start(rtems_tcb *a, rtems_tcb *b)
|
||||
|
||||
static void three_thread_restart(rtems_tcb *a, rtems_tcb *b)
|
||||
{
|
||||
assert_static_order(3);
|
||||
assert_forward_order(3);
|
||||
assert_life_protected_thread_context();
|
||||
}
|
||||
|
||||
@@ -326,13 +318,15 @@ static void three_fatal(
|
||||
)
|
||||
{
|
||||
if (source == RTEMS_FATAL_SOURCE_EXIT) {
|
||||
assert_reverse_order(3);
|
||||
assert_forward_order(3);
|
||||
assert(counter == 72);
|
||||
TEST_END();
|
||||
}
|
||||
}
|
||||
|
||||
static void three_thread_terminate(rtems_tcb *a)
|
||||
{
|
||||
assert_forward_order(3);
|
||||
assert_reverse_order(3);
|
||||
assert_life_protected_thread_context();
|
||||
}
|
||||
|
||||
|
||||
@@ -120,11 +120,13 @@ typedef enum {
|
||||
POSIX_RWLOCK_POST,
|
||||
POSIX_SHM_PRE,
|
||||
POSIX_SHM_POST,
|
||||
POSIX_CLEANUP_PRE,
|
||||
POSIX_CLEANUP_POST,
|
||||
#endif /* RTEMS_POSIX_API */
|
||||
POSIX_KEYS_PRE,
|
||||
POSIX_KEYS_POST,
|
||||
#ifdef RTEMS_POSIX_API
|
||||
POSIX_CLEANUP_PRE,
|
||||
POSIX_CLEANUP_POST,
|
||||
#endif /* RTEMS_POSIX_API */
|
||||
IDLE_THREADS_PRE,
|
||||
IDLE_THREADS_POST,
|
||||
LIBIO_PRE,
|
||||
|
||||
Reference in New Issue
Block a user