[rtems commit] score: Return status in _Thread_Restart_other()

Sebastian Huber sebh at rtems.org
Fri May 14 07:41:24 UTC 2021


Module:    rtems
Branch:    master
Commit:    57be57c79969b2f27580bc9af6fb2b14f321ab19
Changeset: http://git.rtems.org/rtems/commit/?id=57be57c79969b2f27580bc9af6fb2b14f321ab19

Author:    Sebastian Huber <sebastian.huber at embedded-brains.de>
Date:      Fri May 14 09:31:47 2021 +0200

score: Return status in _Thread_Restart_other()

This simplifies rtems_task_restart().

---

 cpukit/include/rtems/score/threadimpl.h | 15 +++++++++------
 cpukit/rtems/src/taskrestart.c          |  7 ++++---
 cpukit/score/src/threadrestart.c        |  6 +++---
 3 files changed, 16 insertions(+), 12 deletions(-)

diff --git a/cpukit/include/rtems/score/threadimpl.h b/cpukit/include/rtems/score/threadimpl.h
index ba7c159..8674a3f 100644
--- a/cpukit/include/rtems/score/threadimpl.h
+++ b/cpukit/include/rtems/score/threadimpl.h
@@ -286,14 +286,17 @@ RTEMS_NO_RETURN void _Thread_Restart_self(
 /**
  * @brief Restarts the thread.
  *
- * @param[in, out] the_thread The thread to restart.
- * @param entry The start entry information for @a the_thread.
- * @param lock_context The lock context.
+ * @param[in, out] the_thread is the thread to restart.
+ *
+ * @param entry is the new start entry information for the thread to restart.
+ *
+ * @param[in, out] lock_context is the lock context with interrupts disabled.
+ *
+ * @retval STATUS_SUCCESSFUL The operation was successful.
  *
- * @retval true The operation was successful.
- * @retval false The operation failed.
+ * @retval STATUS_INCORRECT_STATE The thread was dormant.
  */
-bool _Thread_Restart_other(
+Status_Control _Thread_Restart_other(
   Thread_Control                 *the_thread,
   const Thread_Entry_information *entry,
   ISR_lock_Context               *lock_context
diff --git a/cpukit/rtems/src/taskrestart.c b/cpukit/rtems/src/taskrestart.c
index 6a56ff5..00b0635 100644
--- a/cpukit/rtems/src/taskrestart.c
+++ b/cpukit/rtems/src/taskrestart.c
@@ -21,6 +21,7 @@
 #endif
 
 #include <rtems/rtems/tasks.h>
+#include <rtems/rtems/statusimpl.h>
 #include <rtems/score/threadimpl.h>
 
 rtems_status_code rtems_task_restart(
@@ -31,7 +32,7 @@ rtems_status_code rtems_task_restart(
   Thread_Control           *the_thread;
   ISR_lock_Context          lock_context;
   Thread_Entry_information  entry;
-  bool                      ok;
+  Status_Control            status;
 
   the_thread = _Thread_Get( id, &lock_context );
 
@@ -53,7 +54,7 @@ rtems_status_code rtems_task_restart(
     RTEMS_UNREACHABLE();
   }
 
-  ok = _Thread_Restart_other( the_thread, &entry, &lock_context );
+  status = _Thread_Restart_other( the_thread, &entry, &lock_context );
 
-  return ok ? RTEMS_SUCCESSFUL : RTEMS_INCORRECT_STATE;
+  return _Status_Get( status );
 }
diff --git a/cpukit/score/src/threadrestart.c b/cpukit/score/src/threadrestart.c
index 364d67d..dcbf11c 100644
--- a/cpukit/score/src/threadrestart.c
+++ b/cpukit/score/src/threadrestart.c
@@ -524,7 +524,7 @@ void _Thread_Exit(
   _Thread_State_release( executing, &lock_context );
 }
 
-bool _Thread_Restart_other(
+Status_Control _Thread_Restart_other(
   Thread_Control                 *the_thread,
   const Thread_Entry_information *entry,
   ISR_lock_Context               *lock_context
@@ -537,7 +537,7 @@ bool _Thread_Restart_other(
 
   if ( _States_Is_dormant( the_thread->current_state ) ) {
     _Thread_State_release( the_thread, lock_context );
-    return false;
+    return STATUS_INCORRECT_STATE;
   }
 
   the_thread->Start.Entry = *entry;
@@ -564,7 +564,7 @@ bool _Thread_Restart_other(
   }
 
   _Thread_Dispatch_enable( cpu_self );
-  return true;
+  return STATUS_SUCCESSFUL;
 }
 
 void _Thread_Restart_self(



More information about the vc mailing list