summaryrefslogtreecommitdiffstats
path: root/cpukit/posix/src/keygetspecific.c
diff options
context:
space:
mode:
authorZhongwei Yao <ashi08104@gmail.com>2013-08-05 09:20:45 -0400
committerSebastian Huber <sebastian.huber@embedded-brains.de>2013-08-06 14:11:38 +0200
commitb5c906429f6e67452eec1b0089ac7a204ff998ee (patch)
tree5e24aed5499922f6d3fa6e1559f5bc7e83fba4b2 /cpukit/posix/src/keygetspecific.c
parentbsp/realview-pbx-a9: Enable fast idle clock (diff)
downloadrtems-b5c906429f6e67452eec1b0089ac7a204ff998ee.tar.bz2
Unlimited objects support for POSIX keys
This patch enables unlimited model in POSIX key manger and have a decent runtime on POSIX key searching, adding and deleting operations. Memory overhead is lower than current implementation when the size of key and key value becomes big.
Diffstat (limited to 'cpukit/posix/src/keygetspecific.c')
-rw-r--r--cpukit/posix/src/keygetspecific.c39
1 files changed, 26 insertions, 13 deletions
diff --git a/cpukit/posix/src/keygetspecific.c b/cpukit/posix/src/keygetspecific.c
index 0e8bbcdec8..88e084ee96 100644
--- a/cpukit/posix/src/keygetspecific.c
+++ b/cpukit/posix/src/keygetspecific.c
@@ -6,12 +6,13 @@
*/
/*
- * COPYRIGHT (c) 1989-2007.
- * On-Line Applications Research Corporation (OAR).
+ * Copyright (c) 2012 Zhongwei Yao.
+ * COPYRIGHT (c) 1989-2007.
+ * On-Line Applications Research Corporation (OAR).
*
- * The license and distribution terms for this file may be
- * found in the file LICENSE in this distribution or at
- * http://www.rtems.com/license/LICENSE.
+ * The license and distribution terms for this file may be
+ * found in the file LICENSE in this distribution or at
+ * http://www.rtems.com/license/LICENSE.
*/
#if HAVE_CONFIG_H
@@ -26,6 +27,7 @@
#include <rtems/system.h>
#include <rtems/score/thread.h>
#include <rtems/score/wkspace.h>
+#include <rtems/score/rbtree.h>
#include <rtems/posix/key.h>
/*
@@ -36,20 +38,31 @@ void *pthread_getspecific(
pthread_key_t key
)
{
- register POSIX_Keys_Control *the_key;
- uint32_t api;
- uint32_t index;
Objects_Locations location;
+ POSIX_Keys_Key_value_pair search_node;
+ RBTree_Node *p;
void *key_data;
+ POSIX_Keys_Key_value_pair *value_pair_p;
- the_key = _POSIX_Keys_Get( key, &location );
+ _POSIX_Keys_Get( key, &location );
switch ( location ) {
case OBJECTS_LOCAL:
- api = _Objects_Get_API( _Thread_Executing->Object.id );
- index = _Objects_Get_index( _Thread_Executing->Object.id );
- key_data = (void *) the_key->Values[ api ][ index ];
- _Objects_Put( &the_key->Object );
+ search_node.key = key;
+ search_node.thread_id = _Thread_Executing->Object.id;
+ p = _RBTree_Find_unprotected( &_POSIX_Keys_Key_value_lookup_tree,
+ &search_node.Key_value_lookup_node );
+ key_data = NULL;
+ if ( p ) {
+ value_pair_p = _RBTree_Container_of( p,
+ POSIX_Keys_Key_value_pair,
+ Key_value_lookup_node );
+ /* key_data = _RBTree_Container_of( p, */
+ /* POSIX_Keys_Key_value_pair, */
+ /* Key_value_lookup_node )->value; */
+ key_data = value_pair_p->value;
+ }
+ _Thread_Enable_dispatch();
return key_data;
#if defined(RTEMS_MULTIPROCESSING)