summaryrefslogtreecommitdiffstats
path: root/cpukit/score/include/rtems/score/threadqimpl.h
diff options
context:
space:
mode:
authorSebastian Huber <sebastian.huber@embedded-brains.de>2016-04-01 11:38:47 +0200
committerSebastian Huber <sebastian.huber@embedded-brains.de>2016-04-06 09:08:21 +0200
commit8f9658187a46f3c3ee3d7c7b68491fab5175a8fd (patch)
treec1887c2441887909201698b8d16b8cb2e8598188 /cpukit/score/include/rtems/score/threadqimpl.h
parentscore: Simplify _Thread_queue_Do_flush() (diff)
downloadrtems-8f9658187a46f3c3ee3d7c7b68491fab5175a8fd.tar.bz2
score: Rework MP thread queue callout support
The thread queue implementation was heavily reworked to support SMP. This broke the multiprocessing support of the thread queues. This is fixed by this patch. A thread proxy is unblocked due to three reasons 1) timeout, 2) request satisfaction, and 3) extraction. In case 1) no MPCI message must be sent. This is ensured via the _Thread_queue_MP_callout_do_nothing() callout set during _Thread_MP_Allocate_proxy(). In case 2) and 3) an MPCI message must be sent. In case we interrupt the blocking operation during _Thread_queue_Enqueue_critical(), then this message must be sent by the blocking thread. For this the new fields Thread_Proxy_control::thread_queue_callout and Thread_Proxy_control::thread_queue_id are used. Delete the individual API MP callout types and use Thread_queue_MP_callout throughout. This type is only defined in multiprocessing configurations. Prefix the multiprocessing parameters with mp_ to ease code review. Multiprocessing specific parameters are optional due to use of a similar macro pattern. There is no overhead for non-multiprocessing configurations.
Diffstat (limited to 'cpukit/score/include/rtems/score/threadqimpl.h')
-rw-r--r--cpukit/score/include/rtems/score/threadqimpl.h213
1 files changed, 182 insertions, 31 deletions
diff --git a/cpukit/score/include/rtems/score/threadqimpl.h b/cpukit/score/include/rtems/score/threadqimpl.h
index 76f29d37f6..d56be79a45 100644
--- a/cpukit/score/include/rtems/score/threadqimpl.h
+++ b/cpukit/score/include/rtems/score/threadqimpl.h
@@ -153,20 +153,15 @@ RTEMS_INLINE_ROUTINE void _Thread_queue_Release(
);
}
+Thread_Control *_Thread_queue_Do_dequeue(
+ Thread_queue_Control *the_thread_queue,
+ const Thread_queue_Operations *operations
#if defined(RTEMS_MULTIPROCESSING)
-/**
- * @brief Multiprocessing (MP) support callout for thread queue operations.
- *
- * @param the_proxy The thread proxy of the thread queue operation. A thread
- * control is actually a thread proxy if and only if
- * _Objects_Is_local_id( the_proxy->Object.id ) is false.
- * @param mp_id Object identifier of the object containing the thread queue.
- */
-typedef void ( *Thread_queue_MP_callout )(
- Thread_Control *the_proxy,
- Objects_Id mp_id
-);
+ ,
+ Thread_queue_MP_callout mp_callout,
+ Objects_Id mp_id
#endif
+);
/**
* @brief Gets a pointer to a thread waiting on the_thread_queue.
@@ -179,10 +174,31 @@ typedef void ( *Thread_queue_MP_callout )(
* - INTERRUPT LATENCY:
* + single case
*/
-Thread_Control *_Thread_queue_Dequeue(
- Thread_queue_Control *the_thread_queue,
- const Thread_queue_Operations *operations
-);
+#if defined(RTEMS_MULTIPROCESSING)
+ #define _Thread_queue_Dequeue( \
+ the_thread_queue, \
+ operations, \
+ mp_callout, \
+ mp_id \
+ ) \
+ _Thread_queue_Do_dequeue( \
+ the_thread_queue, \
+ operations, \
+ mp_callout, \
+ mp_id \
+ )
+#else
+ #define _Thread_queue_Dequeue( \
+ the_thread_queue, \
+ operations, \
+ mp_callout, \
+ mp_id \
+ ) \
+ _Thread_queue_Do_dequeue( \
+ the_thread_queue, \
+ operations \
+ )
+#endif
/**
* @brief Blocks the thread and places it on the thread queue.
@@ -283,6 +299,17 @@ RTEMS_INLINE_ROUTINE void _Thread_queue_Enqueue(
);
}
+bool _Thread_queue_Do_extract_locked(
+ Thread_queue_Queue *queue,
+ const Thread_queue_Operations *operations,
+ Thread_Control *the_thread
+#if defined(RTEMS_MULTIPROCESSING)
+ ,
+ Thread_queue_MP_callout mp_callout,
+ Objects_Id mp_id
+#endif
+);
+
/**
* @brief Extracts the thread from the thread queue, restores the default wait
* operations and restores the default thread lock.
@@ -293,6 +320,11 @@ RTEMS_INLINE_ROUTINE void _Thread_queue_Enqueue(
* @param[in] queue The actual thread queue.
* @param[in] operations The thread queue operations.
* @param[in] the_thread The thread to extract.
+ * @param[in] mp_callout Callout to unblock the thread in case it is actually a
+ * thread proxy. This parameter is only used on multiprocessing
+ * configurations.
+ * @param[in] mp_id Object identifier of the object containing the thread
+ * queue. This parameter is only used on multiprocessing configurations.
*
* @return Returns the unblock indicator for _Thread_queue_Unblock_critical().
* True indicates, that this thread must be unblocked by the scheduler later in
@@ -302,10 +334,45 @@ RTEMS_INLINE_ROUTINE void _Thread_queue_Enqueue(
* since this thread may already block on another resource in an SMP
* configuration.
*/
-bool _Thread_queue_Extract_locked(
- Thread_queue_Queue *queue,
- const Thread_queue_Operations *operations,
- Thread_Control *the_thread
+#if defined(RTEMS_MULTIPROCESSING)
+ #define _Thread_queue_Extract_locked( \
+ unblock, \
+ queue, \
+ the_thread, \
+ mp_callout, \
+ mp_id \
+ ) \
+ _Thread_queue_Do_extract_locked( \
+ unblock, \
+ queue, \
+ the_thread, \
+ mp_callout, \
+ mp_id \
+ )
+#else
+ #define _Thread_queue_Extract_locked( \
+ unblock, \
+ queue, \
+ the_thread, \
+ mp_callout, \
+ mp_id \
+ ) \
+ _Thread_queue_Do_extract_locked( \
+ unblock, \
+ queue, \
+ the_thread \
+ )
+#endif
+
+void _Thread_queue_Do_unblock_critical(
+ bool unblock,
+ Thread_queue_Queue *queue,
+ Thread_Control *the_thread,
+#if defined(RTEMS_MULTIPROCESSING)
+ Thread_queue_MP_callout mp_callout,
+ Objects_Id mp_id,
+#endif
+ ISR_lock_Context *lock_context
);
/**
@@ -320,13 +387,56 @@ bool _Thread_queue_Extract_locked(
* _Thread_queue_Extract_locked().
* @param[in] queue The actual thread queue.
* @param[in] the_thread The thread to extract.
+ * @param[in] mp_callout Callout to unblock the thread in case it is actually a
+ * thread proxy. This parameter is only used on multiprocessing
+ * configurations.
+ * @param[in] mp_id Object identifier of the object containing the thread
+ * queue. This parameter is only used on multiprocessing configurations.
* @param[in] lock_context The lock context of the lock acquire.
*/
-void _Thread_queue_Unblock_critical(
- bool unblock,
- Thread_queue_Queue *queue,
- Thread_Control *the_thread,
- ISR_lock_Context *lock_context
+#if defined(RTEMS_MULTIPROCESSING)
+ #define _Thread_queue_Unblock_critical( \
+ unblock, \
+ queue, \
+ the_thread, \
+ mp_callout, \
+ mp_id, \
+ lock_context \
+ ) \
+ _Thread_queue_Do_unblock_critical( \
+ unblock, \
+ queue, \
+ the_thread, \
+ mp_callout, \
+ mp_id, \
+ lock_context \
+ )
+#else
+ #define _Thread_queue_Unblock_critical( \
+ unblock, \
+ queue, \
+ the_thread, \
+ mp_callout, \
+ mp_id, \
+ lock_context \
+ ) \
+ _Thread_queue_Do_unblock_critical( \
+ unblock, \
+ queue, \
+ the_thread, \
+ lock_context \
+ )
+#endif
+
+void _Thread_queue_Do_extract_critical(
+ Thread_queue_Queue *queue,
+ const Thread_queue_Operations *operations,
+ Thread_Control *the_thread,
+#if defined(RTEMS_MULTIPROCESSING)
+ Thread_queue_MP_callout mp_callout,
+ Objects_Id mp_id,
+#endif
+ ISR_lock_Context *lock_context
);
/**
@@ -364,6 +474,8 @@ void _Thread_queue_Unblock_critical(
* &mutex->Queue.Queue,
* mutex->Queue.operations,
* first,
+ * NULL,
+ * 0,
* &lock_context
* );
* }
@@ -372,14 +484,46 @@ void _Thread_queue_Unblock_critical(
* @param[in] queue The actual thread queue.
* @param[in] operations The thread queue operations.
* @param[in] the_thread The thread to extract.
+ * @param[in] mp_callout Callout to unblock the thread in case it is actually a
+ * thread proxy. This parameter is only used on multiprocessing
+ * configurations.
+ * @param[in] mp_id Object identifier of the object containing the thread
+ * queue. This parameter is only used on multiprocessing configurations.
* @param[in] lock_context The lock context of the lock acquire.
*/
-void _Thread_queue_Extract_critical(
- Thread_queue_Queue *queue,
- const Thread_queue_Operations *operations,
- Thread_Control *the_thread,
- ISR_lock_Context *lock_context
-);
+#if defined(RTEMS_MULTIPROCESSING)
+ #define _Thread_queue_Extract_critical( \
+ queue, \
+ operations, \
+ the_thread, \
+ mp_callout, \
+ mp_id, \
+ lock_context \
+ ) \
+ _Thread_queue_Do_extract_critical( \
+ queue, \
+ operations, \
+ the_thread, \
+ mp_callout, \
+ mp_id, \
+ lock_context \
+ )
+#else
+ #define _Thread_queue_Extract_critical( \
+ queue, \
+ operations, \
+ the_thread, \
+ mp_callout, \
+ mp_id, \
+ lock_context \
+ ) \
+ _Thread_queue_Do_extract_critical( \
+ queue, \
+ operations, \
+ the_thread, \
+ lock_context \
+ )
+#endif
/**
* @brief Extracts thread from thread queue.
@@ -574,6 +718,13 @@ RBTree_Compare_result _Thread_queue_Compare_priority(
const RBTree_Node *right
);
+#if defined(RTEMS_MULTIPROCESSING)
+void _Thread_queue_MP_callout_do_nothing(
+ Thread_Control *the_proxy,
+ Objects_Id mp_id
+);
+#endif
+
extern const Thread_queue_Operations _Thread_queue_Operations_default;
extern const Thread_queue_Operations _Thread_queue_Operations_FIFO;