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.
This commit is contained in:
Sebastian Huber
2017-01-31 09:38:07 +01:00
parent 70488f5655
commit e366f774a7
24 changed files with 151 additions and 80 deletions
@@ -43,7 +43,7 @@ RTEMS_INLINE_ROUTINE void _CORE_mutex_Initialize(
CORE_mutex_Control *the_mutex
)
{
_Thread_queue_Initialize( &the_mutex->Wait_queue );
_Thread_queue_Object_initialize( &the_mutex->Wait_queue );
}
RTEMS_INLINE_ROUTINE void _CORE_mutex_Destroy( CORE_mutex_Control *the_mutex )
@@ -186,7 +186,7 @@ RTEMS_INLINE_ROUTINE Status_Control _CORE_semaphore_Seize(
_Thread_queue_Context_set_thread_state(
queue_context,
STATES_THREAD_QUEUE_WITH_IDENTIFIER | STATES_WAITING_FOR_SEMAPHORE
STATES_WAITING_FOR_SEMAPHORE
);
_Thread_queue_Context_set_do_nothing_enqueue_callout( queue_context );
_Thread_queue_Enqueue(
+1 -1
View File
@@ -223,7 +223,7 @@ RTEMS_INLINE_ROUTINE Status_Control _MRSP_Initialize(
}
}
_Thread_queue_Initialize( &mrsp->Wait_queue );
_Thread_queue_Object_initialize( &mrsp->Wait_queue );
return STATUS_SUCCESSFUL;
}
+19 -29
View File
@@ -41,71 +41,62 @@ extern "C" {
/** This macro corresponds to a task being ready. */
#define STATES_READY 0x00000000
/**
* @brief This macro corresponds to a task which is blocked on a thread queue
* embedded in an object with an identifier.
*
* This thread state bit is intended to ease debugging and improve system
* diagnostics, see _Thread_Wait_get_id().
*/
#define STATES_THREAD_QUEUE_WITH_IDENTIFIER 0x00000001
/** This macro corresponds to a task waiting for a mutex. */
#define STATES_WAITING_FOR_MUTEX 0x00000002
#define STATES_WAITING_FOR_MUTEX 0x00000001
/** This macro corresponds to a task waiting for a semaphore. */
#define STATES_WAITING_FOR_SEMAPHORE 0x00000004
#define STATES_WAITING_FOR_SEMAPHORE 0x00000002
/** This macro corresponds to a task waiting for an event. */
#define STATES_WAITING_FOR_EVENT 0x00000008
#define STATES_WAITING_FOR_EVENT 0x00000004
/** This macro corresponds to a task waiting for a system event. */
#define STATES_WAITING_FOR_SYSTEM_EVENT 0x00000010
#define STATES_WAITING_FOR_SYSTEM_EVENT 0x00000008
/** This macro corresponds to a task waiting for a message. */
#define STATES_WAITING_FOR_MESSAGE 0x00000020
#define STATES_WAITING_FOR_MESSAGE 0x00000010
/** This macro corresponds to a task waiting for a condition variable. */
#define STATES_WAITING_FOR_CONDITION_VARIABLE 0x00000040
#define STATES_WAITING_FOR_CONDITION_VARIABLE 0x00000020
/** This macro corresponds to a task waiting for a futex. */
#define STATES_WAITING_FOR_FUTEX 0x00000080
#define STATES_WAITING_FOR_FUTEX 0x00000040
/** This macro corresponds to a task waiting for BSD wakeup. */
#define STATES_WAITING_FOR_BSD_WAKEUP 0x00000100
#define STATES_WAITING_FOR_BSD_WAKEUP 0x00000080
/**
* @brief This macro corresponds to a task which is waiting for a relative or
* absolute timeout.
*/
#define STATES_WAITING_FOR_TIME 0x00000200
#define STATES_WAITING_FOR_TIME 0x00000100
/** This macro corresponds to a task waiting for a period. */
#define STATES_WAITING_FOR_PERIOD 0x00000400
#define STATES_WAITING_FOR_PERIOD 0x00000200
/** This macro corresponds to a task waiting for a signal. */
#define STATES_WAITING_FOR_SIGNAL 0x00000800
#define STATES_WAITING_FOR_SIGNAL 0x00000400
/** This macro corresponds to a task waiting for a barrier. */
#define STATES_WAITING_FOR_BARRIER 0x00001000
#define STATES_WAITING_FOR_BARRIER 0x00000800
/** This macro corresponds to a task waiting for a RWLock. */
#define STATES_WAITING_FOR_RWLOCK 0x00002000
#define STATES_WAITING_FOR_RWLOCK 0x00001000
/** This macro corresponds to a task waiting for a join while exiting. */
#define STATES_WAITING_FOR_JOIN_AT_EXIT 0x00004000
#define STATES_WAITING_FOR_JOIN_AT_EXIT 0x00002000
/** This macro corresponds to a task waiting for a join. */
#define STATES_WAITING_FOR_JOIN 0x00008000
#define STATES_WAITING_FOR_JOIN 0x00004000
/** This macro corresponds to a task being suspended. */
#define STATES_SUSPENDED 0x00010000
#define STATES_SUSPENDED 0x00008000
/** This macro corresponds to a task waiting for a fixed size segment. */
#define STATES_WAITING_FOR_SEGMENT 0x00020000
#define STATES_WAITING_FOR_SEGMENT 0x00010000
/** This macro corresponds to a task those life is changing. */
#define STATES_LIFE_IS_CHANGING 0x00040000
#define STATES_LIFE_IS_CHANGING 0x00020000
/** This macro corresponds to a task being held by the debugger. */
#define STATES_DEBUGGER 0x08000000
@@ -125,8 +116,7 @@ extern "C" {
#define STATES_DORMANT 0x80000000
/** This macro corresponds to a task waiting for a local object operation. */
#define STATES_LOCALLY_BLOCKED ( STATES_THREAD_QUEUE_WITH_IDENTIFIER | \
STATES_WAITING_FOR_SEGMENT | \
#define STATES_LOCALLY_BLOCKED ( STATES_WAITING_FOR_SEGMENT | \
STATES_WAITING_FOR_MESSAGE | \
STATES_WAITING_FOR_SEMAPHORE | \
STATES_WAITING_FOR_MUTEX | \
+46 -2
View File
@@ -353,7 +353,8 @@ RTEMS_INLINE_ROUTINE void _Thread_queue_Heads_initialize(
}
RTEMS_INLINE_ROUTINE void _Thread_queue_Queue_initialize(
Thread_queue_Queue *queue
Thread_queue_Queue *queue,
const char *name
)
{
#if defined(RTEMS_SMP)
@@ -361,6 +362,7 @@ RTEMS_INLINE_ROUTINE void _Thread_queue_Queue_initialize(
#endif
queue->heads = NULL;
queue->owner = NULL;
queue->name = name;
}
RTEMS_INLINE_ROUTINE void _Thread_queue_Queue_do_acquire_critical(
@@ -418,6 +420,25 @@ RTEMS_INLINE_ROUTINE void _Thread_queue_Queue_release(
_ISR_lock_ISR_enable( lock_context );
}
/**
* @brief Copies the thread queue name to the specified buffer.
*
* @param[in] queue The actual thread queue.
* @param[in] buffer The buffer for the thread queue name copy.
* @param[in] buffer_size The buffer size in characters.
* @param[in] id The object identifier in case the thread queue is embedded in
* an object with identifier, otherwise it is set to 0.
*
* @retval The length of the thread queue name. May be greater than or equal
* to the buffer size if truncation occurred.
*/
size_t _Thread_queue_Queue_get_name_and_id(
const Thread_queue_Queue *queue,
char *buffer,
size_t buffer_size,
Objects_Id *id
);
#if defined(RTEMS_SMP)
void _Thread_queue_Do_acquire_critical(
Thread_queue_Control *the_thread_queue,
@@ -1011,7 +1032,10 @@ size_t _Thread_queue_Flush_critical(
Thread_queue_Context *queue_context
);
void _Thread_queue_Initialize( Thread_queue_Control *the_thread_queue );
void _Thread_queue_Initialize(
Thread_queue_Control *the_thread_queue,
const char *name
);
#if defined(RTEMS_SMP) && defined(RTEMS_DEBUG) && defined(RTEMS_PROFILING)
#define THREAD_QUEUE_INITIALIZER( _name ) \
@@ -1137,6 +1161,26 @@ extern const Thread_queue_Operations _Thread_queue_Operations_priority;
extern const Thread_queue_Operations _Thread_queue_Operations_priority_inherit;
/**
* @brief The special thread queue name to indicated that the thread queue is
* embedded in an object with identifier.
*
* @see _Thread_queue_Object_initialize().
*/
extern const char _Thread_queue_Object_name[];
/**
* @brief Initializes a thread queue embedded in an object with identifier.
*
* The object must have the layout specified by Thread_queue_Object. It should
* be ensured with the THREAD_QUEUE_OBJECT_ASSERT() static assertion.
*
* @param[in] the_thread_queue The thread queue.
*/
void _Thread_queue_Object_initialize(
Thread_queue_Control *the_thread_queue
);
/**@}*/
#ifdef __cplusplus