forked from Imagelibrary/rtems
score: Fix thread queue context initialization
Initialize the thread queue context with invalid data in debug configurations to catch missing set up steps.
This commit is contained in:
@@ -89,7 +89,7 @@ RTEMS_INLINE_ROUTINE int _POSIX_Zero_or_minus_one_plus_errno(
|
|||||||
* @brief Macro to generate a function body to get a POSIX object by
|
* @brief Macro to generate a function body to get a POSIX object by
|
||||||
* identifier.
|
* identifier.
|
||||||
*
|
*
|
||||||
* Generates a function body to get the object for the specified indentifier.
|
* Generates a function body to get the object for the specified identifier.
|
||||||
* Performs automatic initialization if requested and necessary. This is an
|
* Performs automatic initialization if requested and necessary. This is an
|
||||||
* ugly macro, since C lacks support for templates.
|
* ugly macro, since C lacks support for templates.
|
||||||
*/
|
*/
|
||||||
@@ -105,6 +105,7 @@ RTEMS_INLINE_ROUTINE int _POSIX_Zero_or_minus_one_plus_errno(
|
|||||||
if ( id == NULL ) { \
|
if ( id == NULL ) { \
|
||||||
return NULL; \
|
return NULL; \
|
||||||
} \
|
} \
|
||||||
|
_Thread_queue_Initialize( queue_context ); \
|
||||||
the_object = _Objects_Get( \
|
the_object = _Objects_Get( \
|
||||||
(Objects_Id) *id, \
|
(Objects_Id) *id, \
|
||||||
&queue_context->Lock_context.Lock_context, \
|
&queue_context->Lock_context.Lock_context, \
|
||||||
|
|||||||
@@ -67,7 +67,6 @@ int pthread_mutex_setprioceiling(
|
|||||||
Thread_queue_Context queue_context;
|
Thread_queue_Context queue_context;
|
||||||
Per_CPU_Control *cpu_self;
|
Per_CPU_Control *cpu_self;
|
||||||
|
|
||||||
_Thread_queue_Context_clear_priority_updates( &queue_context );
|
|
||||||
_CORE_ceiling_mutex_Set_priority(
|
_CORE_ceiling_mutex_Set_priority(
|
||||||
&the_mutex->Mutex,
|
&the_mutex->Mutex,
|
||||||
new_priority,
|
new_priority,
|
||||||
|
|||||||
@@ -91,8 +91,8 @@ void _POSIX_Threads_Sporadic_timer( Watchdog_Control *watchdog )
|
|||||||
api = RTEMS_CONTAINER_OF( watchdog, POSIX_API_Control, Sporadic.Timer );
|
api = RTEMS_CONTAINER_OF( watchdog, POSIX_API_Control, Sporadic.Timer );
|
||||||
the_thread = api->thread;
|
the_thread = api->thread;
|
||||||
|
|
||||||
_Thread_queue_Context_clear_priority_updates( &queue_context );
|
|
||||||
_Thread_Wait_acquire( the_thread, &queue_context );
|
_Thread_Wait_acquire( the_thread, &queue_context );
|
||||||
|
_Thread_queue_Context_clear_priority_updates( &queue_context );
|
||||||
|
|
||||||
if ( _Priority_Node_is_active( &api->Sporadic.Low_priority ) ) {
|
if ( _Priority_Node_is_active( &api->Sporadic.Low_priority ) ) {
|
||||||
_Thread_Priority_add(
|
_Thread_Priority_add(
|
||||||
@@ -122,8 +122,8 @@ void _POSIX_Threads_Sporadic_budget_callout( Thread_Control *the_thread )
|
|||||||
|
|
||||||
api = the_thread->API_Extensions[ THREAD_API_POSIX ];
|
api = the_thread->API_Extensions[ THREAD_API_POSIX ];
|
||||||
|
|
||||||
_Thread_queue_Context_clear_priority_updates( &queue_context );
|
|
||||||
_Thread_Wait_acquire( the_thread, &queue_context );
|
_Thread_Wait_acquire( the_thread, &queue_context );
|
||||||
|
_Thread_queue_Context_clear_priority_updates( &queue_context );
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* This will prevent the thread from consuming its entire "budget"
|
* This will prevent the thread from consuming its entire "budget"
|
||||||
|
|||||||
@@ -53,6 +53,7 @@ int pthread_getschedparam(
|
|||||||
|
|
||||||
api = the_thread->API_Extensions[ THREAD_API_POSIX ];
|
api = the_thread->API_Extensions[ THREAD_API_POSIX ];
|
||||||
|
|
||||||
|
_Thread_queue_Context_initialize( &queue_context );
|
||||||
_Thread_Wait_acquire_critical( the_thread, &queue_context );
|
_Thread_Wait_acquire_critical( the_thread, &queue_context );
|
||||||
|
|
||||||
*policy = api->Attributes.schedpolicy;
|
*policy = api->Attributes.schedpolicy;
|
||||||
|
|||||||
@@ -253,6 +253,7 @@ RTEMS_INLINE_ROUTINE void _CORE_ceiling_mutex_Set_priority(
|
|||||||
|
|
||||||
if ( owner != NULL ) {
|
if ( owner != NULL ) {
|
||||||
_Thread_Wait_acquire( owner, queue_context );
|
_Thread_Wait_acquire( owner, queue_context );
|
||||||
|
_Thread_queue_Context_clear_priority_updates( queue_context );
|
||||||
_Thread_Priority_change(
|
_Thread_Priority_change(
|
||||||
owner,
|
owner,
|
||||||
&the_mutex->Priority_ceiling,
|
&the_mutex->Priority_ceiling,
|
||||||
|
|||||||
@@ -87,9 +87,10 @@ RTEMS_INLINE_ROUTINE void _Thread_queue_Context_initialize(
|
|||||||
)
|
)
|
||||||
{
|
{
|
||||||
#if defined(RTEMS_DEBUG)
|
#if defined(RTEMS_DEBUG)
|
||||||
memset( queue_context, 0, sizeof( *queue_context ) );
|
memset( queue_context, 0x7f, sizeof( *queue_context ) );
|
||||||
queue_context->enqueue_callout = _Thread_queue_Enqueue_do_nothing;
|
#if defined(RTEMS_SMP)
|
||||||
queue_context->deadlock_callout = _Thread_queue_Deadlock_fatal;
|
_Chain_Initialize_node( &queue_context->Lock_context.Wait.Gate.Node );
|
||||||
|
#endif
|
||||||
#else
|
#else
|
||||||
(void) queue_context;
|
(void) queue_context;
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -420,6 +420,9 @@ void _Thread_queue_Enqueue(
|
|||||||
Per_CPU_Control *cpu_self;
|
Per_CPU_Control *cpu_self;
|
||||||
bool success;
|
bool success;
|
||||||
|
|
||||||
|
_Assert( (uint8_t) (uintptr_t) queue_context->enqueue_callout != 0x7f );
|
||||||
|
_Assert( (uint8_t) queue_context->timeout_discipline != 0x7f );
|
||||||
|
|
||||||
#if defined(RTEMS_MULTIPROCESSING)
|
#if defined(RTEMS_MULTIPROCESSING)
|
||||||
if ( _Thread_MP_Is_receive( the_thread ) && the_thread->receive_packet ) {
|
if ( _Thread_MP_Is_receive( the_thread ) && the_thread->receive_packet ) {
|
||||||
the_thread = _Thread_MP_Allocate_proxy( queue_context->thread_state );
|
the_thread = _Thread_MP_Allocate_proxy( queue_context->thread_state );
|
||||||
@@ -433,6 +436,7 @@ void _Thread_queue_Enqueue(
|
|||||||
_Thread_Wait_restore_default( the_thread );
|
_Thread_Wait_restore_default( the_thread );
|
||||||
_Thread_queue_Queue_release( queue, &queue_context->Lock_context.Lock_context );
|
_Thread_queue_Queue_release( queue, &queue_context->Lock_context.Lock_context );
|
||||||
_Thread_Wait_tranquilize( the_thread );
|
_Thread_Wait_tranquilize( the_thread );
|
||||||
|
_Assert( (uint8_t) (uintptr_t) queue_context->deadlock_callout != 0x7f );
|
||||||
( *queue_context->deadlock_callout )( the_thread );
|
( *queue_context->deadlock_callout )( the_thread );
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -597,6 +601,7 @@ bool _Thread_queue_Extract_locked(
|
|||||||
Thread_queue_Context *queue_context
|
Thread_queue_Context *queue_context
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
|
_Thread_queue_Context_clear_priority_updates( queue_context );
|
||||||
#if defined(RTEMS_MULTIPROCESSING)
|
#if defined(RTEMS_MULTIPROCESSING)
|
||||||
_Thread_queue_MP_set_callout( the_thread, queue_context );
|
_Thread_queue_MP_set_callout( the_thread, queue_context );
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -57,8 +57,8 @@ static void _Thread_Raise_real_priority(
|
|||||||
{
|
{
|
||||||
Thread_queue_Context queue_context;
|
Thread_queue_Context queue_context;
|
||||||
|
|
||||||
_Thread_queue_Context_clear_priority_updates( &queue_context );
|
|
||||||
_Thread_Wait_acquire( the_thread, &queue_context );
|
_Thread_Wait_acquire( the_thread, &queue_context );
|
||||||
|
_Thread_queue_Context_clear_priority_updates( &queue_context );
|
||||||
|
|
||||||
if ( priority < the_thread->Real_priority.priority ) {
|
if ( priority < the_thread->Real_priority.priority ) {
|
||||||
_Thread_Priority_change(
|
_Thread_Priority_change(
|
||||||
|
|||||||
@@ -31,8 +31,8 @@ void _Thread_Timeout( Watchdog_Control *watchdog )
|
|||||||
|
|
||||||
the_thread = RTEMS_CONTAINER_OF( watchdog, Thread_Control, Timer.Watchdog );
|
the_thread = RTEMS_CONTAINER_OF( watchdog, Thread_Control, Timer.Watchdog );
|
||||||
|
|
||||||
_Thread_queue_Context_clear_priority_updates( &queue_context );
|
|
||||||
_Thread_Wait_acquire( the_thread, &queue_context );
|
_Thread_Wait_acquire( the_thread, &queue_context );
|
||||||
|
_Thread_queue_Context_clear_priority_updates( &queue_context );
|
||||||
|
|
||||||
wait_flags = _Thread_Wait_flags_get( the_thread );
|
wait_flags = _Thread_Wait_flags_get( the_thread );
|
||||||
|
|
||||||
|
|||||||
@@ -52,8 +52,8 @@ static void apply_priority(
|
|||||||
Thread_queue_Context *queue_context
|
Thread_queue_Context *queue_context
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
_Thread_queue_Context_clear_priority_updates(queue_context);
|
|
||||||
_Thread_Wait_acquire(thread, queue_context);
|
_Thread_Wait_acquire(thread, queue_context);
|
||||||
|
_Thread_queue_Context_clear_priority_updates(queue_context);
|
||||||
_Thread_Priority_change(
|
_Thread_Priority_change(
|
||||||
thread,
|
thread,
|
||||||
&thread->Real_priority,
|
&thread->Real_priority,
|
||||||
|
|||||||
Reference in New Issue
Block a user