summaryrefslogtreecommitdiffstats
path: root/cpukit/score/include
diff options
context:
space:
mode:
authorSebastian Huber <sebastian.huber@embedded-brains.de>2015-04-22 11:15:46 +0200
committerSebastian Huber <sebastian.huber@embedded-brains.de>2015-05-19 12:00:45 +0200
commit383cf42217d05a9cf19c6d081d50f92b2262a308 (patch)
tree0ee3fb9e007b2028a357a14056ed4e337886313b /cpukit/score/include
parentscore: Add Thread_queue_Operations (diff)
downloadrtems-383cf42217d05a9cf19c6d081d50f92b2262a308.tar.bz2
score: More thread queue operations
Move thread queue discipline specific operations into Thread_queue_Operations. Use a separate node in the thread control block for the thread queue to make it independent of the scheduler data structures. Update #2273.
Diffstat (limited to 'cpukit/score/include')
-rw-r--r--cpukit/score/include/rtems/score/thread.h19
-rw-r--r--cpukit/score/include/rtems/score/threadimpl.h5
-rw-r--r--cpukit/score/include/rtems/score/threadq.h106
3 files changed, 121 insertions, 9 deletions
diff --git a/cpukit/score/include/rtems/score/thread.h b/cpukit/score/include/rtems/score/thread.h
index bce6f5643e..b6662e49af 100644
--- a/cpukit/score/include/rtems/score/thread.h
+++ b/cpukit/score/include/rtems/score/thread.h
@@ -286,6 +286,21 @@ typedef unsigned int Thread_Wait_flags;
* blocked and to return information to it.
*/
typedef struct {
+ /**
+ * @brief Node for thread queues.
+ */
+ union {
+ /**
+ * @brief A node for chains.
+ */
+ Chain_Node Chain;
+
+ /**
+ * @brief A node for red-black trees.
+ */
+ RBTree_Node RBTree;
+ } Node;
+
/** This field is the Id of the object this thread is waiting upon. */
Objects_Id id;
/** This field is used to return an integer while when blocked. */
@@ -349,8 +364,6 @@ typedef struct {
typedef struct {
/** This field is the object management structure for each proxy. */
Objects_Control Object;
- /** This field is used to enqueue the thread on RBTrees. */
- RBTree_Node RBNode;
/** This field is the current execution state of this proxy. */
States_Control current_state;
/** This field is the current priority state of this proxy. */
@@ -638,8 +651,6 @@ typedef struct {
struct Thread_Control_struct {
/** This field is the object management structure for each thread. */
Objects_Control Object;
- /** This field is used to enqueue the thread on RBTrees. */
- RBTree_Node RBNode;
/** This field is the current execution state of this thread. */
States_Control current_state;
/** This field is the current priority state of this thread. */
diff --git a/cpukit/score/include/rtems/score/threadimpl.h b/cpukit/score/include/rtems/score/threadimpl.h
index 953b88b925..b8c235c846 100644
--- a/cpukit/score/include/rtems/score/threadimpl.h
+++ b/cpukit/score/include/rtems/score/threadimpl.h
@@ -78,8 +78,11 @@ SCORE_EXTERN Thread_Control *_Thread_Allocated_fp;
SCORE_EXTERN struct _reent **_Thread_libc_reent;
#endif
+#define THREAD_CHAIN_NODE_TO_THREAD( node ) \
+ RTEMS_CONTAINER_OF( node, Thread_Control, Wait.Node.Chain )
+
#define THREAD_RBTREE_NODE_TO_THREAD( node ) \
- RTEMS_CONTAINER_OF( node, Thread_Control, RBNode )
+ RTEMS_CONTAINER_OF( node, Thread_Control, Wait.Node.RBTree )
#if defined(RTEMS_SMP)
#define THREAD_RESOURCE_NODE_TO_THREAD( node ) \
diff --git a/cpukit/score/include/rtems/score/threadq.h b/cpukit/score/include/rtems/score/threadq.h
index c483b87620..59781ac73c 100644
--- a/cpukit/score/include/rtems/score/threadq.h
+++ b/cpukit/score/include/rtems/score/threadq.h
@@ -49,14 +49,81 @@ typedef struct Thread_queue_Control Thread_queue_Control;
*
* @param[in] the_thread The thread.
* @param[in] new_priority The new priority value.
- * @param[in] queue The thread queue.
+ * @param[in] the_thread_queue The thread queue.
*
* @see Thread_queue_Operations.
*/
typedef void ( *Thread_queue_Priority_change_operation )(
Thread_Control *the_thread,
Priority_Control new_priority,
- Thread_queue_Control *queue
+ Thread_queue_Control *the_thread_queue
+);
+
+/**
+ * @brief Thread queue initialize operation.
+ *
+ * @param[in] the_thread_queue The thread queue.
+ *
+ * @see _Thread_Wait_set_operations().
+ */
+typedef void ( *Thread_queue_Initialize_operation )(
+ Thread_queue_Control *the_thread_queue
+);
+
+/**
+ * @brief Thread queue enqueue operation.
+ *
+ * @param[in] the_thread_queue The thread queue.
+ * @param[in] the_thread The thread to enqueue on the queue.
+ *
+ * @see _Thread_Wait_set_operations().
+ */
+typedef void ( *Thread_queue_Enqueue_operation )(
+ Thread_queue_Control *the_thread_queue,
+ Thread_Control *the_thread
+);
+
+/**
+ * @brief Thread queue dequeue operation.
+ *
+ * @param[in] the_thread_queue The thread queue.
+ *
+ * @retval NULL No thread is present on the thread queue.
+ * @retval first The first thread of the thread queue according to the insert
+ * order. This thread is no longer on the thread queue.
+ *
+ * @see _Thread_Wait_set_operations().
+ */
+typedef Thread_Control *( *Thread_queue_Dequeue_operation )(
+ Thread_queue_Control *the_thread_queue
+);
+
+/**
+ * @brief Thread queue extract operation.
+ *
+ * @param[in] the_thread_queue The thread queue.
+ * @param[in] the_thread The thread to extract from the thread queue.
+ *
+ * @see _Thread_Wait_set_operations().
+ */
+typedef void ( *Thread_queue_Extract_operation )(
+ Thread_queue_Control *the_thread_queue,
+ Thread_Control *the_thread
+);
+
+/**
+ * @brief Thread queue first operation.
+ *
+ * @param[in] the_thread_queue The thread queue.
+ *
+ * @retval NULL No thread is present on the thread queue.
+ * @retval first The first thread of the thread queue according to the insert
+ * order. This thread remains on the thread queue.
+ *
+ * @see _Thread_Wait_set_operations().
+ */
+typedef Thread_Control *( *Thread_queue_First_operation )(
+ Thread_queue_Control *the_thread_queue
);
/**
@@ -76,6 +143,39 @@ typedef struct {
* to be done during a priority change.
*/
Thread_queue_Priority_change_operation priority_change;
+
+ /**
+ * @brief Thread queue initialize operation.
+ *
+ * Called by object initialization routines.
+ */
+ Thread_queue_Initialize_operation initialize;
+
+ /**
+ * @brief Thread queue enqueue operation.
+ *
+ * Called by object routines to enqueue the thread.
+ */
+ Thread_queue_Enqueue_operation enqueue;
+
+ /**
+ * @brief Thread queue dequeue operation.
+ *
+ * Called by object routines to dequeue the first waiting thread if present.
+ */
+ Thread_queue_Dequeue_operation dequeue;
+
+ /**
+ * @brief Thread queue extract operation.
+ *
+ * Called by object routines to extract a thread from a thread queue.
+ */
+ Thread_queue_Extract_operation extract;
+
+ /**
+ * @brief Thread queue first operation.
+ */
+ Thread_queue_First_operation first;
} Thread_queue_Operations;
/**
@@ -120,8 +220,6 @@ struct Thread_queue_Control {
/** This field is used to manage the critical section. */
Thread_blocking_operation_States sync_state;
- /** This field indicates the thread queue's blocking discipline. */
- Thread_queue_Disciplines discipline;
/** This is the status value returned to threads which timeout while
* waiting on this thread queue.
*/