[rtems commit] score: Add _Thread_MP_Extract_proxy()
Sebastian Huber
sebh at rtems.org
Tue Nov 23 13:34:54 UTC 2021
Module: rtems
Branch: master
Commit: 50aef135a405a0dc26c39d7cfe7066f85b3dfbb5
Changeset: http://git.rtems.org/rtems/commit/?id=50aef135a405a0dc26c39d7cfe7066f85b3dfbb5
Author: Sebastian Huber <sebastian.huber at embedded-brains.de>
Date: Thu Nov 11 08:35:22 2021 +0100
score: Add _Thread_MP_Extract_proxy()
Remove _Thread_queue_Extract_with_proxy() and move the proxy extraction
to _Thread_MP_Extract_proxy(). Move similar code blocks of the previous
caller of _Thread_queue_Extract_with_proxy() to helper functions.
Update #4546.
---
cpukit/include/rtems/score/objectdata.h | 2 +-
cpukit/include/rtems/score/threadimpl.h | 27 ++++++++++++++++++
cpukit/include/rtems/score/threadmp.h | 13 +++++++++
cpukit/include/rtems/score/threadqimpl.h | 18 ------------
cpukit/posix/src/psignalunblockthread.c | 16 +++++++----
cpukit/score/src/threadqextractwithproxy.c | 46 ++++++++++++++----------------
cpukit/score/src/threadrestart.c | 8 ++----
spec/build/cpukit/librtemscpu.yml | 1 -
spec/build/cpukit/objmpci.yml | 1 +
9 files changed, 78 insertions(+), 54 deletions(-)
diff --git a/cpukit/include/rtems/score/objectdata.h b/cpukit/include/rtems/score/objectdata.h
index 149498d..c7fb33c 100644
--- a/cpukit/include/rtems/score/objectdata.h
+++ b/cpukit/include/rtems/score/objectdata.h
@@ -286,7 +286,7 @@ struct Objects_Information {
#if defined(RTEMS_MULTIPROCESSING)
/**
- * @brief This method is used by _Thread_queue_Extract_with_proxy().
+ * @brief This method is used by _Thread_MP_Extract_proxy().
*
* This member is statically initialized and read-only.
*/
diff --git a/cpukit/include/rtems/score/threadimpl.h b/cpukit/include/rtems/score/threadimpl.h
index 931de2c..dc41d28 100644
--- a/cpukit/include/rtems/score/threadimpl.h
+++ b/cpukit/include/rtems/score/threadimpl.h
@@ -2690,5 +2690,32 @@ RTEMS_INLINE_ROUTINE void _Thread_Unpin(
#include <rtems/score/threadmp.h>
#endif
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * @ingroup RTEMSScoreThread
+ *
+ * @brief Removes the watchdog timer from the thread and lets the thread
+ * continue its execution.
+ *
+ * @param[in, out] the_thread is the thread.
+ */
+RTEMS_INLINE_ROUTINE void _Thread_Timer_remove_and_continue(
+ Thread_Control *the_thread
+)
+{
+ _Thread_Timer_remove( the_thread );
+#if defined(RTEMS_MULTIPROCESSING)
+ _Thread_MP_Extract_proxy( the_thread );
+#endif
+ _Thread_queue_Extract( the_thread );
+}
+
+#ifdef __cplusplus
+}
+#endif
+
#endif
/* end of include file */
diff --git a/cpukit/include/rtems/score/threadmp.h b/cpukit/include/rtems/score/threadmp.h
index 6cc68e6..e10661a 100644
--- a/cpukit/include/rtems/score/threadmp.h
+++ b/cpukit/include/rtems/score/threadmp.h
@@ -98,6 +98,19 @@ Thread_Control *_Thread_MP_Find_proxy (
((_the_thread) == _MPCI_Receive_server_tcb)
/**
+ * @brief Extracts the proxy of the thread if necessary.
+ *
+ * This routine ensures that if there is a proxy for this thread on another
+ * node, it is also dealt with. A proxy is a data that is on the thread queue
+ * on the remote node and acts as a proxy for the local thread. If the local
+ * thread was waiting on a remote operation, then the remote side of the
+ * operation must be cleaned up.
+ *
+ * @param[in, out] the_thread is the thread to determine the proxy.
+ */
+void _Thread_MP_Extract_proxy( Thread_Control *the_thread );
+
+/**
* @brief Trees a proxy control block to the inactive chain of free proxy
* control blocks.
*/
diff --git a/cpukit/include/rtems/score/threadqimpl.h b/cpukit/include/rtems/score/threadqimpl.h
index 7e6f266..1831787 100644
--- a/cpukit/include/rtems/score/threadqimpl.h
+++ b/cpukit/include/rtems/score/threadqimpl.h
@@ -984,24 +984,6 @@ void _Thread_queue_Resume(
void _Thread_queue_Extract( Thread_Control *the_thread );
/**
- * @brief Extracts the_thread from the_thread_queue.
- *
- * This routine extracts the_thread from the_thread_queue
- * and ensures that if there is a proxy for this task on
- * another node, it is also dealt with. A proxy is a data
- * data that is on the thread queue on the remote node and
- * acts as a proxy for the local thread. If the local thread
- * was waiting on a remote operation, then the remote side
- * of the operation must be cleaned up.
- *
- * @param[in, out] the_thread The pointer to a thread control block that
- * is to be removed
- */
-void _Thread_queue_Extract_with_proxy(
- Thread_Control *the_thread
-);
-
-/**
* @brief Surrenders the thread queue previously owned by the thread to the
* first enqueued thread.
*
diff --git a/cpukit/posix/src/psignalunblockthread.c b/cpukit/posix/src/psignalunblockthread.c
index de814c1..1133234 100644
--- a/cpukit/posix/src/psignalunblockthread.c
+++ b/cpukit/posix/src/psignalunblockthread.c
@@ -175,6 +175,15 @@ static bool _POSIX_signals_Unblock_thread_done(
return status;
}
+static void _POSIX_signals_Interrupt_thread( Thread_Control *the_thread )
+{
+#if defined(RTEMS_MULTIPROCESSING)
+ _Thread_MP_Extract_proxy( the_thread );
+#endif
+ the_thread->Wait.return_code = STATUS_INTERRUPTED;
+ _Thread_queue_Extract( the_thread );
+}
+
bool _POSIX_signals_Unblock_thread(
Thread_Control *the_thread,
int signo,
@@ -196,8 +205,6 @@ bool _POSIX_signals_Unblock_thread(
if ( _States_Is_interruptible_signal( the_thread->current_state ) ) {
if ( (the_thread->Wait.option & mask) || (api->signals_unblocked & mask) ) {
- the_thread->Wait.return_code = STATUS_INTERRUPTED;
-
the_info = (siginfo_t *) the_thread->Wait.return_argument;
if ( !info ) {
@@ -208,7 +215,7 @@ bool _POSIX_signals_Unblock_thread(
*the_info = *info;
}
- _Thread_queue_Extract_with_proxy( the_thread );
+ _POSIX_signals_Interrupt_thread( the_thread );
return _POSIX_signals_Unblock_thread_done( the_thread, api, true );
}
@@ -238,8 +245,7 @@ bool _POSIX_signals_Unblock_thread(
*/
if ( _States_Is_interruptible_by_signal( the_thread->current_state ) ) {
- the_thread->Wait.return_code = STATUS_INTERRUPTED;
- _Thread_queue_Extract_with_proxy( the_thread );
+ _POSIX_signals_Interrupt_thread( the_thread );
}
}
return _POSIX_signals_Unblock_thread_done( the_thread, api, false );
diff --git a/cpukit/score/src/threadqextractwithproxy.c b/cpukit/score/src/threadqextractwithproxy.c
index 1370aec..a61934a 100644
--- a/cpukit/score/src/threadqextractwithproxy.c
+++ b/cpukit/score/src/threadqextractwithproxy.c
@@ -4,7 +4,7 @@
* @ingroup RTEMSScoreThreadQueue
*
* @brief This source file contains the implementation of
- * _Thread_queue_Extract_with_proxy().
+ * _Thread_MP_Extract_proxy().
*/
/*
@@ -20,32 +20,30 @@
#include "config.h"
#endif
-#include <rtems/score/threadqimpl.h>
+#include <rtems/score/threadimpl.h>
#include <rtems/score/objectimpl.h>
#include <rtems/score/statesimpl.h>
-void _Thread_queue_Extract_with_proxy(
- Thread_Control *the_thread
-)
+void _Thread_MP_Extract_proxy( Thread_Control *the_thread )
{
- #if defined(RTEMS_MULTIPROCESSING)
- States_Control state;
-
- state = the_thread->current_state;
- if ( _States_Is_waiting_for_rpc_reply( state ) &&
- _States_Is_locally_blocked( state ) ) {
- Objects_Id id;
- Objects_Information *the_information;
- Objects_Thread_queue_Extract_callout proxy_extract_callout;
-
- id = the_thread->Wait.remote_id;
- the_information = _Objects_Get_information_id( id );
- proxy_extract_callout = the_information->extract;
-
- if ( proxy_extract_callout != NULL )
- (*proxy_extract_callout)( the_thread, id );
- }
- #endif
+ States_Control state;
+
+ state = the_thread->current_state;
+
+ if (
+ _States_Is_waiting_for_rpc_reply( state ) &&
+ _States_Is_locally_blocked( state )
+ ) {
+ Objects_Id id;
+ const Objects_Information *the_information;
+ Objects_Thread_queue_Extract_callout proxy_extract_callout;
- _Thread_queue_Extract( the_thread );
+ id = the_thread->Wait.remote_id;
+ the_information = _Objects_Get_information_id( id );
+ proxy_extract_callout = the_information->extract;
+
+ if ( proxy_extract_callout != NULL ) {
+ ( *proxy_extract_callout )( the_thread, id );
+ }
+ }
}
diff --git a/cpukit/score/src/threadrestart.c b/cpukit/score/src/threadrestart.c
index 12a0329..d469705 100644
--- a/cpukit/score/src/threadrestart.c
+++ b/cpukit/score/src/threadrestart.c
@@ -137,8 +137,7 @@ static void _Thread_Make_zombie( Thread_Control *the_thread )
_Objects_Close( &information->Objects, &the_thread->Object );
_Thread_Set_state( the_thread, STATES_ZOMBIE );
- _Thread_Timer_remove( the_thread );
- _Thread_queue_Extract_with_proxy( the_thread );
+ _Thread_Timer_remove_and_continue( the_thread );
/*
* Add the thread to the thread zombie chain before we wake up joining
@@ -358,7 +357,7 @@ static void _Thread_Remove_life_change_request( Thread_Control *the_thread )
* Do not remove states used for thread queues to avoid race conditions on
* SMP configurations. We could interrupt an extract operation on another
* processor disregarding the thread wait flags. Rely on
- * _Thread_queue_Extract_with_proxy() for removal of these states.
+ * _Thread_queue_Extract() for removal of these states.
*/
_Thread_Clear_state_locked(
the_thread,
@@ -409,8 +408,7 @@ static void _Thread_Try_life_change_request(
_Thread_Add_life_change_request( the_thread );
_Thread_State_release( the_thread, lock_context );
- _Thread_Timer_remove( the_thread );
- _Thread_queue_Extract_with_proxy( the_thread );
+ _Thread_Timer_remove_and_continue( the_thread );
_Thread_Remove_life_change_request( the_thread );
} else {
_Thread_Clear_state_locked( the_thread, STATES_SUSPENDED );
diff --git a/spec/build/cpukit/librtemscpu.yml b/spec/build/cpukit/librtemscpu.yml
index 060ef27..b6ee8b9 100644
--- a/spec/build/cpukit/librtemscpu.yml
+++ b/spec/build/cpukit/librtemscpu.yml
@@ -1561,7 +1561,6 @@ source:
- cpukit/score/src/threadplaindispatch.c
- cpukit/score/src/threadq.c
- cpukit/score/src/threadqenqueue.c
-- cpukit/score/src/threadqextractwithproxy.c
- cpukit/score/src/threadqfirst.c
- cpukit/score/src/threadqflush.c
- cpukit/score/src/threadqgetnameandid.c
diff --git a/spec/build/cpukit/objmpci.yml b/spec/build/cpukit/objmpci.yml
index 24cfca9..0b9b5c6 100644
--- a/spec/build/cpukit/objmpci.yml
+++ b/spec/build/cpukit/objmpci.yml
@@ -23,4 +23,5 @@ source:
- cpukit/score/src/mpcidefault.c
- cpukit/score/src/objectmp.c
- cpukit/score/src/threadmp.c
+- cpukit/score/src/threadqextractwithproxy.c
type: build
More information about the vc
mailing list