diff options
author | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2017-01-31 08:08:24 +0100 |
---|---|---|
committer | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2017-01-31 09:38:07 +0100 |
commit | e366f774a76d3607ad41dc0992e787ce38df980d (patch) | |
tree | 4ba5522aaa87021c60bcaf8d162af9b521b9268c /cpukit/score/src | |
parent | score: Fix _Thread_Initialize() (diff) | |
download | rtems-e366f774a76d3607ad41dc0992e787ce38df980d.tar.bz2 |
score: Add _Thread_queue_Object_name
Add the special thread queue name _Thread_queue_Object_name to mark
thread queues embedded in an object with identifier. Using the special
thread state STATES_THREAD_QUEUE_WITH_IDENTIFIER is not reliable for
this purpose since the thread wait information and thread state are
protected by different SMP locks in separate critical sections. Remove
STATES_THREAD_QUEUE_WITH_IDENTIFIER.
Add and use _Thread_queue_Object_initialize().
Update #2858.
Diffstat (limited to 'cpukit/score/src')
-rw-r--r-- | cpukit/score/src/corebarrier.c | 2 | ||||
-rw-r--r-- | cpukit/score/src/corebarrierwait.c | 2 | ||||
-rw-r--r-- | cpukit/score/src/coremsg.c | 2 | ||||
-rw-r--r-- | cpukit/score/src/coremsgseize.c | 2 | ||||
-rw-r--r-- | cpukit/score/src/coremsgsubmit.c | 2 | ||||
-rw-r--r-- | cpukit/score/src/coremutexseize.c | 2 | ||||
-rw-r--r-- | cpukit/score/src/corerwlock.c | 2 | ||||
-rw-r--r-- | cpukit/score/src/corerwlockobtainread.c | 2 | ||||
-rw-r--r-- | cpukit/score/src/corerwlockobtainwrite.c | 2 | ||||
-rw-r--r-- | cpukit/score/src/coresem.c | 2 | ||||
-rw-r--r-- | cpukit/score/src/threadinitialize.c | 3 | ||||
-rw-r--r-- | cpukit/score/src/threadq.c | 46 | ||||
-rw-r--r-- | cpukit/score/src/threadwaitgetid.c | 15 |
13 files changed, 62 insertions, 22 deletions
diff --git a/cpukit/score/src/corebarrier.c b/cpukit/score/src/corebarrier.c index 8da3ca1063..98dfd0bb4e 100644 --- a/cpukit/score/src/corebarrier.c +++ b/cpukit/score/src/corebarrier.c @@ -29,5 +29,5 @@ void _CORE_barrier_Initialize( the_barrier->Attributes = *the_barrier_attributes; the_barrier->number_of_waiting_threads = 0; - _Thread_queue_Initialize( &the_barrier->Wait_queue ); + _Thread_queue_Object_initialize( &the_barrier->Wait_queue ); } diff --git a/cpukit/score/src/corebarrierwait.c b/cpukit/score/src/corebarrierwait.c index 9cce4cfa56..f47c039e7b 100644 --- a/cpukit/score/src/corebarrierwait.c +++ b/cpukit/score/src/corebarrierwait.c @@ -46,7 +46,7 @@ Status_Control _CORE_barrier_Seize( the_barrier->number_of_waiting_threads = number_of_waiting_threads; _Thread_queue_Context_set_thread_state( queue_context, - STATES_THREAD_QUEUE_WITH_IDENTIFIER | STATES_WAITING_FOR_BARRIER + STATES_WAITING_FOR_BARRIER ); _Thread_queue_Context_set_do_nothing_enqueue_callout( queue_context ); _Thread_queue_Enqueue( diff --git a/cpukit/score/src/coremsg.c b/cpukit/score/src/coremsg.c index a3a0d76089..1dbadc25c7 100644 --- a/cpukit/score/src/coremsg.c +++ b/cpukit/score/src/coremsg.c @@ -104,7 +104,7 @@ bool _CORE_message_queue_Initialize( _Chain_Initialize_empty( &the_message_queue->Pending_messages ); - _Thread_queue_Initialize( &the_message_queue->Wait_queue ); + _Thread_queue_Object_initialize( &the_message_queue->Wait_queue ); if ( discipline == CORE_MESSAGE_QUEUE_DISCIPLINES_PRIORITY ) { the_message_queue->operations = &_Thread_queue_Operations_priority; diff --git a/cpukit/score/src/coremsgseize.c b/cpukit/score/src/coremsgseize.c index 98a7b156d4..b48a3f93d7 100644 --- a/cpukit/score/src/coremsgseize.c +++ b/cpukit/score/src/coremsgseize.c @@ -115,7 +115,7 @@ Status_Control _CORE_message_queue_Seize( _Thread_queue_Context_set_thread_state( queue_context, - STATES_THREAD_QUEUE_WITH_IDENTIFIER | STATES_WAITING_FOR_MESSAGE + STATES_WAITING_FOR_MESSAGE ); _Thread_queue_Context_set_do_nothing_enqueue_callout( queue_context ); _Thread_queue_Enqueue( diff --git a/cpukit/score/src/coremsgsubmit.c b/cpukit/score/src/coremsgsubmit.c index 5a8827a843..3c961014e3 100644 --- a/cpukit/score/src/coremsgsubmit.c +++ b/cpukit/score/src/coremsgsubmit.c @@ -133,7 +133,7 @@ Status_Control _CORE_message_queue_Submit( _Thread_queue_Context_set_thread_state( queue_context, - STATES_THREAD_QUEUE_WITH_IDENTIFIER | STATES_WAITING_FOR_MESSAGE + STATES_WAITING_FOR_MESSAGE ); _Thread_queue_Context_set_do_nothing_enqueue_callout( queue_context ); _Thread_queue_Enqueue( diff --git a/cpukit/score/src/coremutexseize.c b/cpukit/score/src/coremutexseize.c index b00cad9707..4309380627 100644 --- a/cpukit/score/src/coremutexseize.c +++ b/cpukit/score/src/coremutexseize.c @@ -34,7 +34,7 @@ Status_Control _CORE_mutex_Seize_slow( if ( wait ) { _Thread_queue_Context_set_thread_state( queue_context, - STATES_THREAD_QUEUE_WITH_IDENTIFIER | STATES_WAITING_FOR_MUTEX + STATES_WAITING_FOR_MUTEX ); _Thread_queue_Context_set_do_nothing_enqueue_callout( queue_context ); _Thread_queue_Context_set_deadlock_callout( diff --git a/cpukit/score/src/corerwlock.c b/cpukit/score/src/corerwlock.c index eae62584e9..51ae2c70df 100644 --- a/cpukit/score/src/corerwlock.c +++ b/cpukit/score/src/corerwlock.c @@ -28,5 +28,5 @@ void _CORE_RWLock_Initialize( the_rwlock->number_of_readers = 0; the_rwlock->current_state = CORE_RWLOCK_UNLOCKED; - _Thread_queue_Initialize( &the_rwlock->Wait_queue ); + _Thread_queue_Object_initialize( &the_rwlock->Wait_queue ); } diff --git a/cpukit/score/src/corerwlockobtainread.c b/cpukit/score/src/corerwlockobtainread.c index 035b1d59ae..641945635f 100644 --- a/cpukit/score/src/corerwlockobtainread.c +++ b/cpukit/score/src/corerwlockobtainread.c @@ -80,7 +80,7 @@ Status_Control _CORE_RWLock_Seize_for_reading( _Thread_queue_Context_set_thread_state( queue_context, - STATES_THREAD_QUEUE_WITH_IDENTIFIER | STATES_WAITING_FOR_RWLOCK + STATES_WAITING_FOR_RWLOCK ); _Thread_queue_Context_set_do_nothing_enqueue_callout( queue_context ); _Thread_queue_Enqueue( diff --git a/cpukit/score/src/corerwlockobtainwrite.c b/cpukit/score/src/corerwlockobtainwrite.c index 75168fc062..7f636daa99 100644 --- a/cpukit/score/src/corerwlockobtainwrite.c +++ b/cpukit/score/src/corerwlockobtainwrite.c @@ -68,7 +68,7 @@ Status_Control _CORE_RWLock_Seize_for_writing( _Thread_queue_Context_set_thread_state( queue_context, - STATES_THREAD_QUEUE_WITH_IDENTIFIER | STATES_WAITING_FOR_RWLOCK + STATES_WAITING_FOR_RWLOCK ); _Thread_queue_Context_set_do_nothing_enqueue_callout( queue_context ); _Thread_queue_Enqueue( diff --git a/cpukit/score/src/coresem.c b/cpukit/score/src/coresem.c index e928f3d3a5..f8966448e3 100644 --- a/cpukit/score/src/coresem.c +++ b/cpukit/score/src/coresem.c @@ -27,5 +27,5 @@ void _CORE_semaphore_Initialize( { the_semaphore->count = initial_value; - _Thread_queue_Initialize( &the_semaphore->Wait_queue ); + _Thread_queue_Object_initialize( &the_semaphore->Wait_queue ); } diff --git a/cpukit/score/src/threadinitialize.c b/cpukit/score/src/threadinitialize.c index 60bbd22238..2eb6507565 100644 --- a/cpukit/score/src/threadinitialize.c +++ b/cpukit/score/src/threadinitialize.c @@ -250,13 +250,12 @@ bool _Thread_Initialize( _Thread_queue_Gate_open( &the_thread->Wait.Lock.Tranquilizer ); _RBTree_Initialize_node( &the_thread->Wait.Link.Registry_node ); _SMP_lock_Stats_initialize( &the_thread->Potpourri_stats, "Thread Potpourri" ); + _SMP_lock_Stats_initialize( &the_thread->Join_queue.Lock_stats, "Thread State" ); #endif /* Initialize the CPU for the non-SMP schedulers */ _Thread_Set_CPU( the_thread, cpu ); - _Thread_queue_Initialize( &the_thread->Join_queue ); - the_thread->current_state = STATES_DORMANT; the_thread->Wait.operations = &_Thread_queue_Operations_default; the_thread->Start.initial_priority = priority; diff --git a/cpukit/score/src/threadq.c b/cpukit/score/src/threadq.c index baed6325da..850ec6f07b 100644 --- a/cpukit/score/src/threadq.c +++ b/cpukit/score/src/threadq.c @@ -130,14 +130,24 @@ void _Thread_queue_Release( } #endif -void _Thread_queue_Initialize( Thread_queue_Control *the_thread_queue ) +const char _Thread_queue_Object_name[] = { '\0' }; + +void _Thread_queue_Initialize( + Thread_queue_Control *the_thread_queue, + const char *name +) { - _Thread_queue_Queue_initialize( &the_thread_queue->Queue ); + _Thread_queue_Queue_initialize( &the_thread_queue->Queue, name ); #if defined(RTEMS_SMP) _SMP_lock_Stats_initialize( &the_thread_queue->Lock_stats, "Thread Queue" ); #endif } +void _Thread_queue_Object_initialize( Thread_queue_Control *the_thread_queue ) +{ + _Thread_queue_Initialize( the_thread_queue, _Thread_queue_Object_name ); +} + #if defined(RTEMS_MULTIPROCESSING) void _Thread_queue_MP_callout_do_nothing( Thread_Control *the_proxy, @@ -147,3 +157,35 @@ void _Thread_queue_MP_callout_do_nothing( /* Do nothing */ } #endif + +size_t _Thread_queue_Queue_get_name_and_id( + const Thread_queue_Queue *queue, + char *buffer, + size_t buffer_size, + Objects_Id *id +) +{ + const char *name; + + name = queue->name; + + if ( name == _Thread_queue_Object_name ) { + const Thread_queue_Object *queue_object; + + queue_object = THREAD_QUEUE_QUEUE_TO_OBJECT( queue ); + *id = queue_object->Object.id; + return _Objects_Name_to_string( + queue_object->Object.name, + false, + buffer, + buffer_size + ); + } else { + if ( name == NULL ) { + name = _Thread_queue_Object_name; + } + + *id = 0; + return strlcpy( buffer, name, buffer_size ); + } +} diff --git a/cpukit/score/src/threadwaitgetid.c b/cpukit/score/src/threadwaitgetid.c index 9f17250353..fd32e5ec84 100644 --- a/cpukit/score/src/threadwaitgetid.c +++ b/cpukit/score/src/threadwaitgetid.c @@ -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 @@ -20,21 +20,20 @@ Objects_Id _Thread_Wait_get_id( const Thread_Control *the_thread ) { - States_Control current_state; - - current_state = the_thread->current_state; + const Thread_queue_Queue *queue; #if defined(RTEMS_MULTIPROCESSING) - if ( ( current_state & STATES_WAITING_FOR_RPC_REPLY ) != 0 ) { + if ( _States_Is_waiting_for_rpc_reply( the_thread->current_state ) ) { return the_thread->Wait.remote_id; } #endif - if ( ( current_state & STATES_THREAD_QUEUE_WITH_IDENTIFIER ) != 0 ) { - const Thread_queue_Object *queue_object; + queue = the_thread->Wait.queue; - queue_object = THREAD_QUEUE_QUEUE_TO_OBJECT( the_thread->Wait.queue ); + if ( queue != NULL && queue->name == _Thread_queue_Object_name ) { + const Thread_queue_Object *queue_object; + queue_object = THREAD_QUEUE_QUEUE_TO_OBJECT( queue ); return queue_object->Object.id; } |