<div dir="ltr"><div dir="ltr"><br></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Wed, Jan 27, 2021 at 11:38 AM Sebastian Huber <<a href="mailto:sebastian.huber@embedded-brains.de">sebastian.huber@embedded-brains.de</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">We do not need all the checks if we have a valid indentifier to a thread<br>
class object.<br>
<br>
Move _RTEMS_tasks_Free() to the only source file which calls this<br>
function.<br>
---<br>
 cpukit/include/rtems/rtems/tasksimpl.h  | 16 ----------------<br>
 cpukit/include/rtems/score/threadimpl.h | 25 +++++++++++++++++++++++++<br>
 cpukit/rtems/src/taskconstruct.c        |  8 ++++++++<br>
 cpukit/score/src/threadrestart.c        | 12 ++++++------<br>
 4 files changed, 39 insertions(+), 22 deletions(-)<br>
<br>
diff --git a/cpukit/include/rtems/rtems/tasksimpl.h b/cpukit/include/rtems/rtems/tasksimpl.h<br>
index eac4647897..62a618b635 100644<br>
--- a/cpukit/include/rtems/rtems/tasksimpl.h<br>
+++ b/cpukit/include/rtems/rtems/tasksimpl.h<br>
@@ -66,22 +66,6 @@ RTEMS_INLINE_ROUTINE Thread_Control *_RTEMS_tasks_Allocate(void)<br>
     _Objects_Allocate_unprotected( &_RTEMS_tasks_Information.Objects );<br>
 }<br>
<br>
-/**<br>
- *  @brief Frees a task control block.<br>
- *<br>
- *  This routine frees a task control block to the<br>
- *  inactive chain of free task control blocks.<br>
- */<br>
-RTEMS_INLINE_ROUTINE void _RTEMS_tasks_Free (<br>
-  Thread_Control *the_task<br>
-)<br>
-{<br>
-  _Objects_Free(<br>
-    _Objects_Get_information_id( the_task->Object.id ),<br>
-    &the_task->Object<br>
-  );<br>
-}<br>
-<br>
 /**<br>
  * @brief Converts the RTEMS API priority to the corresponding SuperCore<br>
  * priority and validates it.<br>
diff --git a/cpukit/include/rtems/score/threadimpl.h b/cpukit/include/rtems/score/threadimpl.h<br>
index 52945b407c..eb2810db73 100644<br>
--- a/cpukit/include/rtems/score/threadimpl.h<br>
+++ b/cpukit/include/rtems/score/threadimpl.h<br>
@@ -842,6 +842,31 @@ RTEMS_INLINE_ROUTINE Objects_Information *_Thread_Get_objects_information(<br>
   return _Objects_Information_table[ the_api ][ 1 ];<br>
 }<br>
<br>
+/**<br>
+ * @brief Demands the thread object information associated with the object<br>
+ *   identifier.<br>
+ *<br>
+ * @param id is a valid identifier to a thread class object.<br>
+ *<br>
+ * @return Returns the thread object information associated with the identifier.<br>
+ */<br>
+RTEMS_INLINE_ROUTINE Thread_Information *_Thread_Demand_objects_information(<br>
+  Objects_Id id<br>
+)<br>
+{<br>
+  size_t              the_api;<br>
+  Thread_Information *information;<br>
+<br>
+  the_api = (size_t) _Objects_Get_API( id );<br>
+  _Assert( _Objects_Is_api_valid( the_api ) );<br>
+<br>
+  information = (Thread_Information *)<br>
+    _Objects_Information_table[ the_api ][ 1 ];<br>
+  _Assert( information != NULL );<br>
+<br>
+  return information;<br>
+}<br>
+<br></blockquote><div>what does this add beyond _Thread_Get_objects_information? not clear to me</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
 /**<br>
  * @brief Gets a thread by its identifier.<br>
  *<br>
diff --git a/cpukit/rtems/src/taskconstruct.c b/cpukit/rtems/src/taskconstruct.c<br>
index 6ff83a0b9c..656db7a674 100644<br>
--- a/cpukit/rtems/src/taskconstruct.c<br>
+++ b/cpukit/rtems/src/taskconstruct.c<br>
@@ -79,6 +79,14 @@ rtems_status_code rtems_task_construct(<br>
   return _RTEMS_tasks_Create( config, id, _RTEMS_tasks_Prepare_user_stack );<br>
 }<br>
<br>
+static void _RTEMS_tasks_Free( Thread_Control *the_thread )<br>
+{<br>
+  Thread_Information *information;<br>
+<br>
+  information = _Thread_Demand_objects_information( the_thread->Object.id );<br>
+  _Objects_Free( &information->Objects, &the_thread->Object );<br>
+}<br>
+<br>
 rtems_status_code _RTEMS_tasks_Create(<br>
   const rtems_task_config   *config,<br>
   rtems_id                  *id,<br>
diff --git a/cpukit/score/src/threadrestart.c b/cpukit/score/src/threadrestart.c<br>
index b4204f7fbb..5670abdc26 100644<br>
--- a/cpukit/score/src/threadrestart.c<br>
+++ b/cpukit/score/src/threadrestart.c<br>
@@ -130,16 +130,16 @@ static void _Thread_Add_to_zombie_chain( Thread_Control *the_thread )<br>
<br>
 static void _Thread_Make_zombie( Thread_Control *the_thread )<br>
 {<br>
+  Thread_Information *information;<br>
+<br>
 #if defined(RTEMS_SCORE_THREAD_ENABLE_RESOURCE_COUNT)<br>
   if ( _Thread_Owns_resources( the_thread ) ) {<br>
     _Internal_error( INTERNAL_ERROR_RESOURCE_IN_USE );<br>
   }<br>
 #endif<br>
<br>
-  _Objects_Close(<br>
-    _Objects_Get_information_id( the_thread->Object.id ),<br>
-    &the_thread->Object<br>
-  );<br>
+  information = _Thread_Demand_objects_information( the_thread->Object.id );<br>
+  _Objects_Close( &information->Objects, &the_thread->Object );<br>
<br>
   _Thread_Set_state( the_thread, STATES_ZOMBIE );<br>
   _Thread_queue_Extract_with_proxy( the_thread );<br>
@@ -157,8 +157,7 @@ static void _Thread_Make_zombie( Thread_Control *the_thread )<br>
<br>
 static void _Thread_Free( Thread_Control *the_thread )<br>
 {<br>
-  Thread_Information *information = (Thread_Information *)<br>
-    _Objects_Get_information_id( the_thread->Object.id );<br>
+  Thread_Information *information;<br>
<br>
   _User_extensions_Thread_delete( the_thread );<br>
   _User_extensions_Destroy_iterators( the_thread );<br>
@@ -179,6 +178,7 @@ static void _Thread_Free( Thread_Control *the_thread )<br>
 #endif<br>
 #endif<br>
<br>
+  information = _Thread_Demand_objects_information( the_thread->Object.id );<br>
   _Freechain_Push(<br>
     &information->Thread_queue_heads.Free,<br>
     the_thread->Wait.spare_heads<br>
-- <br>
2.26.2<br>
<br>
_______________________________________________<br>
devel mailing list<br>
<a href="mailto:devel@rtems.org" target="_blank">devel@rtems.org</a><br>
<a href="http://lists.rtems.org/mailman/listinfo/devel" rel="noreferrer" target="_blank">http://lists.rtems.org/mailman/listinfo/devel</a><br>
</blockquote></div></div>