summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSebastian Huber <sebastian.huber@embedded-brains.de>2016-11-28 13:28:32 +0100
committerSebastian Huber <sebastian.huber@embedded-brains.de>2016-11-28 16:08:43 +0100
commitc09db57f37e02e8458e3bffce689774546845bef (patch)
tree7afe403fa39ff81cedf0c83df1a73b950a871c1f
parent9bf9068bb85367a23e285db416cc5fd62eb9dcc2 (diff)
downloadrtems-c09db57f37e02e8458e3bffce689774546845bef.tar.bz2
score: Fix thread queue context initialization
Initialize the thread queue context with invalid data in debug configurations to catch missing set up steps.
-rw-r--r--cpukit/posix/include/rtems/posix/posixapi.h3
-rw-r--r--cpukit/posix/src/mutexsetprioceiling.c1
-rw-r--r--cpukit/posix/src/pthread.c4
-rw-r--r--cpukit/posix/src/pthreadgetschedparam.c1
-rw-r--r--cpukit/score/include/rtems/score/coremuteximpl.h1
-rw-r--r--cpukit/score/include/rtems/score/threadqimpl.h7
-rw-r--r--cpukit/score/src/threadqenqueue.c5
-rw-r--r--cpukit/score/src/threadrestart.c2
-rw-r--r--cpukit/score/src/threadtimeout.c2
-rw-r--r--testsuites/smptests/smpscheduler03/init.c2
10 files changed, 18 insertions, 10 deletions
diff --git a/cpukit/posix/include/rtems/posix/posixapi.h b/cpukit/posix/include/rtems/posix/posixapi.h
index 12baa75eea..b35874d8ea 100644
--- a/cpukit/posix/include/rtems/posix/posixapi.h
+++ b/cpukit/posix/include/rtems/posix/posixapi.h
@@ -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
* 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
* 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 ) { \
return NULL; \
} \
+ _Thread_queue_Initialize( queue_context ); \
the_object = _Objects_Get( \
(Objects_Id) *id, \
&queue_context->Lock_context.Lock_context, \
diff --git a/cpukit/posix/src/mutexsetprioceiling.c b/cpukit/posix/src/mutexsetprioceiling.c
index aaea57ddfb..f483a2b495 100644
--- a/cpukit/posix/src/mutexsetprioceiling.c
+++ b/cpukit/posix/src/mutexsetprioceiling.c
@@ -67,7 +67,6 @@ int pthread_mutex_setprioceiling(
Thread_queue_Context queue_context;
Per_CPU_Control *cpu_self;
- _Thread_queue_Context_clear_priority_updates( &queue_context );
_CORE_ceiling_mutex_Set_priority(
&the_mutex->Mutex,
new_priority,
diff --git a/cpukit/posix/src/pthread.c b/cpukit/posix/src/pthread.c
index 6a39e3ed5e..eb7d652d77 100644
--- a/cpukit/posix/src/pthread.c
+++ b/cpukit/posix/src/pthread.c
@@ -91,8 +91,8 @@ void _POSIX_Threads_Sporadic_timer( Watchdog_Control *watchdog )
api = RTEMS_CONTAINER_OF( watchdog, POSIX_API_Control, Sporadic.Timer );
the_thread = api->thread;
- _Thread_queue_Context_clear_priority_updates( &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 ) ) {
_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 ];
- _Thread_queue_Context_clear_priority_updates( &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"
diff --git a/cpukit/posix/src/pthreadgetschedparam.c b/cpukit/posix/src/pthreadgetschedparam.c
index 88cd5fde98..b60022d87f 100644
--- a/cpukit/posix/src/pthreadgetschedparam.c
+++ b/cpukit/posix/src/pthreadgetschedparam.c
@@ -53,6 +53,7 @@ int pthread_getschedparam(
api = the_thread->API_Extensions[ THREAD_API_POSIX ];
+ _Thread_queue_Context_initialize( &queue_context );
_Thread_Wait_acquire_critical( the_thread, &queue_context );
*policy = api->Attributes.schedpolicy;
diff --git a/cpukit/score/include/rtems/score/coremuteximpl.h b/cpukit/score/include/rtems/score/coremuteximpl.h
index e3da6a7737..638cf8801c 100644
--- a/cpukit/score/include/rtems/score/coremuteximpl.h
+++ b/cpukit/score/include/rtems/score/coremuteximpl.h
@@ -253,6 +253,7 @@ RTEMS_INLINE_ROUTINE void _CORE_ceiling_mutex_Set_priority(
if ( owner != NULL ) {
_Thread_Wait_acquire( owner, queue_context );
+ _Thread_queue_Context_clear_priority_updates( queue_context );
_Thread_Priority_change(
owner,
&the_mutex->Priority_ceiling,
diff --git a/cpukit/score/include/rtems/score/threadqimpl.h b/cpukit/score/include/rtems/score/threadqimpl.h
index bb35b1718b..760c83c658 100644
--- a/cpukit/score/include/rtems/score/threadqimpl.h
+++ b/cpukit/score/include/rtems/score/threadqimpl.h
@@ -87,9 +87,10 @@ RTEMS_INLINE_ROUTINE void _Thread_queue_Context_initialize(
)
{
#if defined(RTEMS_DEBUG)
- memset( queue_context, 0, sizeof( *queue_context ) );
- queue_context->enqueue_callout = _Thread_queue_Enqueue_do_nothing;
- queue_context->deadlock_callout = _Thread_queue_Deadlock_fatal;
+ memset( queue_context, 0x7f, sizeof( *queue_context ) );
+#if defined(RTEMS_SMP)
+ _Chain_Initialize_node( &queue_context->Lock_context.Wait.Gate.Node );
+#endif
#else
(void) queue_context;
#endif
diff --git a/cpukit/score/src/threadqenqueue.c b/cpukit/score/src/threadqenqueue.c
index 7ffef336b4..4d71ba7492 100644
--- a/cpukit/score/src/threadqenqueue.c
+++ b/cpukit/score/src/threadqenqueue.c
@@ -420,6 +420,9 @@ void _Thread_queue_Enqueue(
Per_CPU_Control *cpu_self;
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 ( _Thread_MP_Is_receive( the_thread ) && the_thread->receive_packet ) {
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_queue_Queue_release( queue, &queue_context->Lock_context.Lock_context );
_Thread_Wait_tranquilize( the_thread );
+ _Assert( (uint8_t) (uintptr_t) queue_context->deadlock_callout != 0x7f );
( *queue_context->deadlock_callout )( the_thread );
return;
}
@@ -597,6 +601,7 @@ bool _Thread_queue_Extract_locked(
Thread_queue_Context *queue_context
)
{
+ _Thread_queue_Context_clear_priority_updates( queue_context );
#if defined(RTEMS_MULTIPROCESSING)
_Thread_queue_MP_set_callout( the_thread, queue_context );
#endif
diff --git a/cpukit/score/src/threadrestart.c b/cpukit/score/src/threadrestart.c
index fc934f6529..ac1427b090 100644
--- a/cpukit/score/src/threadrestart.c
+++ b/cpukit/score/src/threadrestart.c
@@ -57,8 +57,8 @@ static void _Thread_Raise_real_priority(
{
Thread_queue_Context queue_context;
- _Thread_queue_Context_clear_priority_updates( &queue_context );
_Thread_Wait_acquire( the_thread, &queue_context );
+ _Thread_queue_Context_clear_priority_updates( &queue_context );
if ( priority < the_thread->Real_priority.priority ) {
_Thread_Priority_change(
diff --git a/cpukit/score/src/threadtimeout.c b/cpukit/score/src/threadtimeout.c
index 8297c55c4b..ea270553b2 100644
--- a/cpukit/score/src/threadtimeout.c
+++ b/cpukit/score/src/threadtimeout.c
@@ -31,8 +31,8 @@ void _Thread_Timeout( Watchdog_Control *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_queue_Context_clear_priority_updates( &queue_context );
wait_flags = _Thread_Wait_flags_get( the_thread );
diff --git a/testsuites/smptests/smpscheduler03/init.c b/testsuites/smptests/smpscheduler03/init.c
index 16e00c63b5..88eb66c61d 100644
--- a/testsuites/smptests/smpscheduler03/init.c
+++ b/testsuites/smptests/smpscheduler03/init.c
@@ -52,8 +52,8 @@ static void apply_priority(
Thread_queue_Context *queue_context
)
{
- _Thread_queue_Context_clear_priority_updates(queue_context);
_Thread_Wait_acquire(thread, queue_context);
+ _Thread_queue_Context_clear_priority_updates(queue_context);
_Thread_Priority_change(
thread,
&thread->Real_priority,