diff options
author | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2016-03-17 07:56:31 +0100 |
---|---|---|
committer | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2016-03-18 07:43:46 +0100 |
commit | 5eaf0e7458bac80ba669f03c4feaae5bad55c6c9 (patch) | |
tree | a6ed26d6617c2b1c2503df1607443e966d875897 /cpukit/posix/src/keygetspecific.c | |
parent | score: Destroy thread timer lock (diff) | |
download | rtems-5eaf0e7458bac80ba669f03c4feaae5bad55c6c9.tar.bz2 |
posix: Use per-thread lookup tree for POSIX Keys
Yields higher performance on SMP systems.
Close #2625.
Diffstat (limited to 'cpukit/posix/src/keygetspecific.c')
-rw-r--r-- | cpukit/posix/src/keygetspecific.c | 50 |
1 files changed, 17 insertions, 33 deletions
diff --git a/cpukit/posix/src/keygetspecific.c b/cpukit/posix/src/keygetspecific.c index ef6c19d56c..08ac1ed28c 100644 --- a/cpukit/posix/src/keygetspecific.c +++ b/cpukit/posix/src/keygetspecific.c @@ -9,6 +9,7 @@ * Copyright (c) 2012 Zhongwei Yao. * COPYRIGHT (c) 1989-2007. * On-Line Applications Research Corporation (OAR). + * Copyright (c) 2016 embedded brains GmbH. * * The license and distribution terms for this file may be * found in the file LICENSE in this distribution or at @@ -19,15 +20,6 @@ #include "config.h" #endif -#include <errno.h> -#include <limits.h> -#include <pthread.h> -#include <string.h> - -#include <rtems/system.h> -#include <rtems/score/thread.h> -#include <rtems/score/wkspace.h> -#include <rtems/score/rbtree.h> #include <rtems/posix/keyimpl.h> /* @@ -38,34 +30,26 @@ void *pthread_getspecific( pthread_key_t key ) { - POSIX_Keys_Control *the_key; - Objects_Locations location; - RBTree_Node *p; - void *key_data; - POSIX_Keys_Key_value_pair *value_pair_p; - - the_key = _POSIX_Keys_Get( key, &location ); - switch ( location ) { + Thread_Control *executing; + ISR_lock_Context lock_context; + RBTree_Node *node; + void *value; - case OBJECTS_LOCAL: - p = _POSIX_Keys_Find( key, _Thread_Executing ); - if ( p != NULL ) { - value_pair_p = POSIX_KEYS_RBTREE_NODE_TO_KEY_VALUE_PAIR( p ); - key_data = value_pair_p->value; - } else { - key_data = NULL; - } + executing = _Thread_Get_executing(); + _POSIX_Keys_Key_value_acquire( executing, &lock_context ); - _Objects_Put( &the_key->Object ); + node = _POSIX_Keys_Key_value_find( key, executing ); - return key_data; + if ( node != NULL ) { + POSIX_Keys_Key_value_pair *key_value_pair; -#if defined(RTEMS_MULTIPROCESSING) - case OBJECTS_REMOTE: /* should never happen */ -#endif - case OBJECTS_ERROR: - break; + key_value_pair = POSIX_KEYS_RBTREE_NODE_TO_KEY_VALUE_PAIR( node ); + value = key_value_pair->value; + } else { + value = NULL; } - return NULL; + _POSIX_Keys_Key_value_release( executing, &lock_context ); + + return value; } |