[rtems commit] score: Add resource node to thread control block

Sebastian Huber sebh at rtems.org
Tue Jun 3 07:02:46 UTC 2014


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

Author:    Sebastian Huber <sebastian.huber at embedded-brains.de>
Date:      Wed May 28 13:38:48 2014 +0200

score: Add resource node to thread control block

---

 cpukit/score/include/rtems/score/thread.h     |    8 ++++++++
 cpukit/score/include/rtems/score/threadimpl.h |   10 ++++++++++
 cpukit/score/src/threadinitialize.c           |    2 ++
 3 files changed, 20 insertions(+), 0 deletions(-)

diff --git a/cpukit/score/include/rtems/score/thread.h b/cpukit/score/include/rtems/score/thread.h
index 7229113..6ac4ecc 100644
--- a/cpukit/score/include/rtems/score/thread.h
+++ b/cpukit/score/include/rtems/score/thread.h
@@ -28,6 +28,7 @@
 #include <rtems/score/object.h>
 #include <rtems/score/percpu.h>
 #include <rtems/score/priority.h>
+#include <rtems/score/resource.h>
 #include <rtems/score/stack.h>
 #include <rtems/score/states.h>
 #include <rtems/score/threadq.h>
@@ -472,6 +473,13 @@ struct Thread_Control_struct {
    */
   Chain_Control            lock_mutex;
 #endif
+#if defined(RTEMS_SMP)
+  /**
+   * @brief Resource node to build a dependency tree in case this thread owns
+   * resources or depends on a resource.
+   */
+  Resource_Node            Resource_node;
+#endif
      /*================= end of common block =================*/
 #if defined(RTEMS_MULTIPROCESSING)
   /** This field is true if the thread is offered globally */
diff --git a/cpukit/score/include/rtems/score/threadimpl.h b/cpukit/score/include/rtems/score/threadimpl.h
index 8b91730..7e6681b 100644
--- a/cpukit/score/include/rtems/score/threadimpl.h
+++ b/cpukit/score/include/rtems/score/threadimpl.h
@@ -26,6 +26,7 @@
 #include <rtems/score/interr.h>
 #include <rtems/score/isr.h>
 #include <rtems/score/objectimpl.h>
+#include <rtems/score/resourceimpl.h>
 #include <rtems/score/statesimpl.h>
 #include <rtems/score/sysstate.h>
 #include <rtems/score/todimpl.h>
@@ -791,6 +792,10 @@ RTEMS_INLINE_ROUTINE bool _Thread_Is_life_changing(
  * Resources are accounted with the Thread_Control::resource_count resource
  * counter.  This counter is used by semaphore objects for example.
  *
+ * In addition to the resource counter there is a resource dependency tree
+ * available on SMP configurations.  In case this tree is non-empty, then the
+ * thread owns resources.
+ *
  * @param[in] the_thread The thread.
  */
 RTEMS_INLINE_ROUTINE bool _Thread_Owns_resources(
@@ -799,6 +804,11 @@ RTEMS_INLINE_ROUTINE bool _Thread_Owns_resources(
 {
   bool owns_resources = the_thread->resource_count != 0;
 
+#if defined(RTEMS_SMP)
+  owns_resources = owns_resources
+    || _Resource_Node_owns_resources( &the_thread->Resource_node );
+#endif
+
   return owns_resources;
 }
 
diff --git a/cpukit/score/src/threadinitialize.c b/cpukit/score/src/threadinitialize.c
index b65628d..9c65d73 100644
--- a/cpukit/score/src/threadinitialize.c
+++ b/cpukit/score/src/threadinitialize.c
@@ -19,6 +19,7 @@
 #endif
 
 #include <rtems/score/threadimpl.h>
+#include <rtems/score/resourceimpl.h>
 #include <rtems/score/schedulerimpl.h>
 #include <rtems/score/stackimpl.h>
 #include <rtems/score/tls.h>
@@ -182,6 +183,7 @@ bool _Thread_Initialize(
 
 #if defined(RTEMS_SMP)
   the_thread->scheduler               = scheduler;
+  _Resource_Node_initialize( &the_thread->Resource_node );
   _CPU_Context_Set_is_executing( &the_thread->Registers, false );
 #endif
 




More information about the vc mailing list