summaryrefslogtreecommitdiffstats
path: root/cpukit/score
diff options
context:
space:
mode:
authorSebastian Huber <sebastian.huber@embedded-brains.de>2016-03-17 07:56:31 +0100
committerSebastian Huber <sebastian.huber@embedded-brains.de>2016-03-18 07:43:46 +0100
commit5eaf0e7458bac80ba669f03c4feaae5bad55c6c9 (patch)
treea6ed26d6617c2b1c2503df1607443e966d875897 /cpukit/score
parentscore: Destroy thread timer lock (diff)
downloadrtems-5eaf0e7458bac80ba669f03c4feaae5bad55c6c9.tar.bz2
posix: Use per-thread lookup tree for POSIX Keys
Yields higher performance on SMP systems. Close #2625.
Diffstat (limited to 'cpukit/score')
-rw-r--r--cpukit/score/include/rtems/score/thread.h23
-rw-r--r--cpukit/score/src/threadinitialize.c7
-rw-r--r--cpukit/score/src/threadrestart.c1
3 files changed, 21 insertions, 10 deletions
diff --git a/cpukit/score/include/rtems/score/thread.h b/cpukit/score/include/rtems/score/thread.h
index 44b706d7ff..4e0d8cf6f9 100644
--- a/cpukit/score/include/rtems/score/thread.h
+++ b/cpukit/score/include/rtems/score/thread.h
@@ -487,6 +487,21 @@ struct Thread_Action {
};
/**
+ * @brief Per-thread information for POSIX Keys.
+ */
+typedef struct {
+ /**
+ * @brief Key value pairs registered for this thread.
+ */
+ RBTree_Control Key_value_pairs;
+
+ /**
+ * @brief Lock to protect the tree operations.
+ */
+ ISR_LOCK_MEMBER( Lock )
+} Thread_Keys_information;
+
+/**
* @brief Control block to manage thread actions.
*
* Use _Thread_Action_control_initialize() to initialize this structure.
@@ -837,13 +852,9 @@ struct _Thread_Control {
#endif
/**
- * This is the thread key value chain's control, which is used
- * to track all key value for specific thread, and when thread
- * exits, we can remove all key value for specific thread by
- * iterating this chain, or we have to search a whole rbtree,
- * which is inefficient.
+ * @brief The POSIX Keys information.
*/
- Chain_Control Key_Chain;
+ Thread_Keys_information Keys;
/**
* @brief Thread life-cycle control.
diff --git a/cpukit/score/src/threadinitialize.c b/cpukit/score/src/threadinitialize.c
index 0b5fd3a125..bcf03bf833 100644
--- a/cpukit/score/src/threadinitialize.c
+++ b/cpukit/score/src/threadinitialize.c
@@ -210,10 +210,9 @@ bool _Thread_Initialize(
_Scheduler_Update_priority( the_thread, priority );
- /*
- * initialize thread's key vaule node chain
- */
- _Chain_Initialize_empty( &the_thread->Key_Chain );
+ /* POSIX Keys */
+ _RBTree_Initialize_empty( &the_thread->Keys.Key_value_pairs );
+ _ISR_lock_Initialize( &the_thread->Keys.Lock, "POSIX Key Value Pairs" );
_Thread_Action_control_initialize( &the_thread->Post_switch_actions );
diff --git a/cpukit/score/src/threadrestart.c b/cpukit/score/src/threadrestart.c
index f5419741bf..155acaa8d1 100644
--- a/cpukit/score/src/threadrestart.c
+++ b/cpukit/score/src/threadrestart.c
@@ -97,6 +97,7 @@ static void _Thread_Free( Thread_Control *the_thread )
_Objects_Get_information_id( the_thread->Object.id );
_User_extensions_Thread_delete( the_thread );
+ _ISR_lock_Destroy( &the_thread->Keys.Lock );
_Scheduler_Node_destroy( _Scheduler_Get( the_thread ), the_thread );
_ISR_lock_Destroy( &the_thread->Timer.Lock );