summaryrefslogtreecommitdiffstats
path: root/cpukit/score/include
diff options
context:
space:
mode:
authorSebastian Huber <sebastian.huber@embedded-brains.de>2016-08-01 11:03:16 +0200
committerSebastian Huber <sebastian.huber@embedded-brains.de>2016-09-08 09:55:27 +0200
commit15b5678dcd72a11909a54b63ddc8e57869d63244 (patch)
tree52c2f9c120d1e7fefc954837e32f7b1038d052ab /cpukit/score/include
parentscore: Move scheduler node to own header file (diff)
downloadrtems-15b5678dcd72a11909a54b63ddc8e57869d63244.tar.bz2
score: Move thread wait node to scheduler node
Update #2556.
Diffstat (limited to '')
-rw-r--r--cpukit/score/include/rtems/score/schedulerimpl.h17
-rw-r--r--cpukit/score/include/rtems/score/schedulernode.h40
-rw-r--r--cpukit/score/include/rtems/score/thread.h201
-rw-r--r--cpukit/score/include/rtems/score/threadimpl.h6
4 files changed, 143 insertions, 121 deletions
diff --git a/cpukit/score/include/rtems/score/schedulerimpl.h b/cpukit/score/include/rtems/score/schedulerimpl.h
index 1c5a697619..0832360c91 100644
--- a/cpukit/score/include/rtems/score/schedulerimpl.h
+++ b/cpukit/score/include/rtems/score/schedulerimpl.h
@@ -785,13 +785,14 @@ RTEMS_INLINE_ROUTINE void _Scheduler_Node_do_initialize(
Priority_Control priority
)
{
+ node->owner = the_thread;
+
node->Priority.value = priority;
node->Priority.prepend_it = false;
#if defined(RTEMS_SMP)
node->user = the_thread;
node->help_state = SCHEDULER_HELP_YOURSELF;
- node->owner = the_thread;
node->idle = NULL;
node->accepts_help = the_thread;
_SMP_sequence_lock_Initialize( &node->Priority.Lock );
@@ -800,6 +801,13 @@ RTEMS_INLINE_ROUTINE void _Scheduler_Node_do_initialize(
#endif
}
+RTEMS_INLINE_ROUTINE Thread_Control *_Scheduler_Node_get_owner(
+ const Scheduler_Node *node
+)
+{
+ return node->owner;
+}
+
RTEMS_INLINE_ROUTINE Priority_Control _Scheduler_Node_get_priority(
Scheduler_Node *node,
bool *prepend_it_p
@@ -885,13 +893,6 @@ typedef void ( *Scheduler_Release_idle_thread )(
Thread_Control *idle
);
-RTEMS_INLINE_ROUTINE Thread_Control *_Scheduler_Node_get_owner(
- const Scheduler_Node *node
-)
-{
- return node->owner;
-}
-
RTEMS_INLINE_ROUTINE Thread_Control *_Scheduler_Node_get_idle(
const Scheduler_Node *node
)
diff --git a/cpukit/score/include/rtems/score/schedulernode.h b/cpukit/score/include/rtems/score/schedulernode.h
index 6153624743..63d86e64ff 100644
--- a/cpukit/score/include/rtems/score/schedulernode.h
+++ b/cpukit/score/include/rtems/score/schedulernode.h
@@ -123,11 +123,6 @@ typedef struct {
Scheduler_Help_state help_state;
/**
- * @brief The thread owning this node.
- */
- struct _Thread_Control *owner;
-
- /**
* @brief The idle thread claimed by this node in case the help state is
* SCHEDULER_HELP_ACTIVE_OWNER.
*
@@ -146,6 +141,35 @@ typedef struct {
#endif
/**
+ * @brief Thread wait support block.
+ */
+ struct {
+ /**
+ * @brief Node for thread queues.
+ *
+ * Each scheduler node can be enqueued on a thread queue on behalf of the
+ * thread owning the scheduler node. The scheduler node reflects the
+ * priority of the thread within the corresponding scheduler instance.
+ */
+ union {
+ /**
+ * @brief A node for chains.
+ */
+ Chain_Node Chain;
+
+ /**
+ * @brief A node for red-black trees.
+ */
+ RBTree_Node RBTree;
+ } Node;
+ } Wait;
+
+ /**
+ * @brief The thread owning this node.
+ */
+ struct _Thread_Control *owner;
+
+ /**
* @brief The thread priority information used by the scheduler.
*
* The thread priority is manifest in two independent areas. One area is the
@@ -181,6 +205,12 @@ typedef struct {
} Priority;
} Scheduler_Node;
+#define SCHEDULER_NODE_OF_WAIT_CHAIN_NODE( node ) \
+ RTEMS_CONTAINER_OF( node, Scheduler_Node, Wait.Node.Chain )
+
+#define SCHEDULER_NODE_OF_WAIT_RBTREE_NODE( node ) \
+ RTEMS_CONTAINER_OF( node, Scheduler_Node, Wait.Node.RBTree )
+
#ifdef __cplusplus
}
#endif /* __cplusplus */
diff --git a/cpukit/score/include/rtems/score/thread.h b/cpukit/score/include/rtems/score/thread.h
index 2df0269491..2cd229f76f 100644
--- a/cpukit/score/include/rtems/score/thread.h
+++ b/cpukit/score/include/rtems/score/thread.h
@@ -210,6 +210,88 @@ typedef struct {
void *tls_area;
} Thread_Start_information;
+#if defined(RTEMS_SMP)
+/**
+ * @brief The thread state with respect to the scheduler.
+ */
+typedef enum {
+ /**
+ * @brief This thread is blocked with respect to the scheduler.
+ *
+ * This thread uses no scheduler nodes.
+ */
+ THREAD_SCHEDULER_BLOCKED,
+
+ /**
+ * @brief This thread is scheduled with respect to the scheduler.
+ *
+ * This thread executes using one of its scheduler nodes. This could be its
+ * own scheduler node or in case it owns resources taking part in the
+ * scheduler helping protocol a scheduler node of another thread.
+ */
+ THREAD_SCHEDULER_SCHEDULED,
+
+ /**
+ * @brief This thread is ready with respect to the scheduler.
+ *
+ * None of the scheduler nodes of this thread is scheduled.
+ */
+ THREAD_SCHEDULER_READY
+} Thread_Scheduler_state;
+#endif
+
+/**
+ * @brief Thread scheduler control.
+ */
+typedef struct {
+#if defined(RTEMS_SMP)
+ /**
+ * @brief The current scheduler state of this thread.
+ */
+ Thread_Scheduler_state state;
+
+ /**
+ * @brief The own scheduler control of this thread.
+ *
+ * This field is constant after initialization.
+ */
+ const struct Scheduler_Control *own_control;
+
+ /**
+ * @brief The scheduler control of this thread.
+ *
+ * The scheduler helping protocol may change this field.
+ */
+ const struct Scheduler_Control *control;
+
+ /**
+ * @brief The own scheduler node of this thread.
+ *
+ * This field is constant after initialization. It is used by change
+ * priority and ask for help operations.
+ */
+ Scheduler_Node *own_node;
+#endif
+
+ /**
+ * @brief The scheduler node of this thread.
+ *
+ * On uni-processor configurations this field is constant after
+ * initialization.
+ *
+ * On SMP configurations the scheduler helping protocol may change this
+ * field.
+ */
+ Scheduler_Node *node;
+
+#if defined(RTEMS_SMP)
+ /**
+ * @brief The processor assigned by the current scheduler.
+ */
+ struct Per_CPU_Control *cpu;
+#endif
+} Thread_Scheduler_control;
+
/**
* @brief Union type to hold a pointer to an immutable or a mutable object.
*
@@ -248,21 +330,6 @@ 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;
-
#if defined(RTEMS_MULTIPROCESSING)
/*
* @brief This field is the identifier of the remote object this thread is
@@ -424,6 +491,11 @@ typedef struct {
/** This field is the number of mutexes currently held by this proxy. */
uint32_t resource_count;
+ /**
+ * @brief Scheduler related control.
+ */
+ Thread_Scheduler_control Scheduler;
+
/** This field is the blocking information for this proxy. */
Thread_Wait_information Wait;
/** This field is the Watchdog used to manage proxy delays and timeouts. */
@@ -444,6 +516,12 @@ typedef struct {
RBTree_Node Active;
/**
+ * @brief The scheduler node providing the thread wait nodes used to enqueue
+ * this thread proxy on a thread queue.
+ */
+ Scheduler_Node Scheduler_node;
+
+ /**
* @brief Provide thread queue heads for this thread proxy.
*
* The actual size of the thread queue heads depends on the application
@@ -592,88 +670,6 @@ typedef struct {
#endif
} Thread_Life_control;
-#if defined(RTEMS_SMP)
-/**
- * @brief The thread state with respect to the scheduler.
- */
-typedef enum {
- /**
- * @brief This thread is blocked with respect to the scheduler.
- *
- * This thread uses no scheduler nodes.
- */
- THREAD_SCHEDULER_BLOCKED,
-
- /**
- * @brief This thread is scheduled with respect to the scheduler.
- *
- * This thread executes using one of its scheduler nodes. This could be its
- * own scheduler node or in case it owns resources taking part in the
- * scheduler helping protocol a scheduler node of another thread.
- */
- THREAD_SCHEDULER_SCHEDULED,
-
- /**
- * @brief This thread is ready with respect to the scheduler.
- *
- * None of the scheduler nodes of this thread is scheduled.
- */
- THREAD_SCHEDULER_READY
-} Thread_Scheduler_state;
-#endif
-
-/**
- * @brief Thread scheduler control.
- */
-typedef struct {
-#if defined(RTEMS_SMP)
- /**
- * @brief The current scheduler state of this thread.
- */
- Thread_Scheduler_state state;
-
- /**
- * @brief The own scheduler control of this thread.
- *
- * This field is constant after initialization.
- */
- const struct Scheduler_Control *own_control;
-
- /**
- * @brief The scheduler control of this thread.
- *
- * The scheduler helping protocol may change this field.
- */
- const struct Scheduler_Control *control;
-
- /**
- * @brief The own scheduler node of this thread.
- *
- * This field is constant after initialization. It is used by change
- * priority and ask for help operations.
- */
- Scheduler_Node *own_node;
-#endif
-
- /**
- * @brief The scheduler node of this thread.
- *
- * On uni-processor configurations this field is constant after
- * initialization.
- *
- * On SMP configurations the scheduler helping protocol may change this
- * field.
- */
- Scheduler_Node *node;
-
-#if defined(RTEMS_SMP)
- /**
- * @brief The processor assigned by the current scheduler.
- */
- struct Per_CPU_Control *cpu;
-#endif
-} Thread_Scheduler_control;
-
typedef struct {
uint32_t flags;
void * control;
@@ -740,6 +736,12 @@ struct _Thread_Control {
/** This field is the number of mutexes currently held by this thread. */
uint32_t resource_count;
+
+ /**
+ * @brief Scheduler related control.
+ */
+ Thread_Scheduler_control Scheduler;
+
/** This field is the blocking information for this thread. */
Thread_Wait_information Wait;
/** This field is the Watchdog used to manage thread delays and timeouts. */
@@ -778,11 +780,6 @@ struct _Thread_Control {
/** This field is true if the thread uses the floating point unit. */
bool is_fp;
- /**
- * @brief Scheduler related control.
- */
- Thread_Scheduler_control Scheduler;
-
#if __RTEMS_ADA__
/** This field is the GNAT self context pointer. */
void *rtems_ada_self;
diff --git a/cpukit/score/include/rtems/score/threadimpl.h b/cpukit/score/include/rtems/score/threadimpl.h
index 03c1ed8088..e51c009a95 100644
--- a/cpukit/score/include/rtems/score/threadimpl.h
+++ b/cpukit/score/include/rtems/score/threadimpl.h
@@ -77,12 +77,6 @@ extern Thread_Information _Thread_Internal_information;
extern Thread_Control *_Thread_Allocated_fp;
#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, Wait.Node.RBTree )
-
#if defined(RTEMS_SMP)
#define THREAD_RESOURCE_NODE_TO_THREAD( node ) \
RTEMS_CONTAINER_OF( node, Thread_Control, Resource_node )