summaryrefslogtreecommitdiffstats
path: root/cpukit
diff options
context:
space:
mode:
authorJoel Sherrill <joel.sherrill@oarcorp.com>2014-03-04 15:54:12 -0600
committerJoel Sherrill <joel.sherrill@oarcorp.com>2014-03-07 13:21:11 -0600
commite6c87f78724743bc74a38678f93ed579ace840f2 (patch)
treedce3962edb00574dade0c8caf837cd85b9607831 /cpukit
parentRemove trailing whitespace in previous patches (diff)
downloadrtems-e6c87f78724743bc74a38678f93ed579ace840f2.tar.bz2
POSIX keys now enabled in all configurations.
Formerly POSIX keys were only enabled when POSIX threads were enabled. Because they are a truly safe alternative to per-task variables in an SMP system, they are being enabled in all configurations.
Diffstat (limited to 'cpukit')
-rw-r--r--cpukit/posix/Makefile.am20
-rw-r--r--cpukit/posix/include/rtems/posix/config.h18
-rw-r--r--cpukit/posix/include/rtems/posix/threadsup.h11
-rw-r--r--cpukit/posix/preinstall.am32
-rw-r--r--cpukit/posix/src/key.c11
-rw-r--r--cpukit/posix/src/keyrundestructors.c8
-rw-r--r--cpukit/posix/src/keysetspecific.c14
-rw-r--r--cpukit/posix/src/pthread.c10
-rw-r--r--cpukit/rtems/src/tasks.c7
-rw-r--r--cpukit/sapi/include/confdefs.h80
-rw-r--r--cpukit/sapi/include/rtems/config.h18
-rw-r--r--cpukit/sapi/src/exinit.c14
-rw-r--r--cpukit/sapi/src/posixapi.c40
-rw-r--r--cpukit/score/include/rtems/score/thread.h13
-rw-r--r--cpukit/score/src/threadinitialize.c6
15 files changed, 159 insertions, 143 deletions
diff --git a/cpukit/posix/Makefile.am b/cpukit/posix/Makefile.am
index f9eeef2a43..53a588749d 100644
--- a/cpukit/posix/Makefile.am
+++ b/cpukit/posix/Makefile.am
@@ -15,6 +15,12 @@ include_rtems_posixdir = $(includedir)/rtems/posix
include_rtems_posix_HEADERS = include/rtems/posix/sigset.h
+## Some POSIX threads features are needed all the time
+include_rtems_posix_HEADERS += include/rtems/posix/key.h
+include_rtems_posix_HEADERS += include/rtems/posix/keyimpl.h
+include_rtems_posix_HEADERS += include/rtems/posix/config.h
+include_rtems_posix_HEADERS += include/rtems/posix/posixapi.h
+
if HAS_PTHREADS
# include
include_HEADERS = include/aio.h
@@ -26,15 +32,11 @@ include_rtems_posix_HEADERS += include/rtems/posix/aio_misc.h
include_rtems_posix_HEADERS += include/rtems/posix/cancel.h
include_rtems_posix_HEADERS += include/rtems/posix/cond.h
include_rtems_posix_HEADERS += include/rtems/posix/condimpl.h
-include_rtems_posix_HEADERS += include/rtems/posix/config.h
-include_rtems_posix_HEADERS += include/rtems/posix/key.h
-include_rtems_posix_HEADERS += include/rtems/posix/keyimpl.h
include_rtems_posix_HEADERS += include/rtems/posix/mqueue.h
include_rtems_posix_HEADERS += include/rtems/posix/mqueueimpl.h
include_rtems_posix_HEADERS += include/rtems/posix/mutex.h
include_rtems_posix_HEADERS += include/rtems/posix/muteximpl.h
include_rtems_posix_HEADERS += include/rtems/posix/onceimpl.h
-include_rtems_posix_HEADERS += include/rtems/posix/posixapi.h
include_rtems_posix_HEADERS += include/rtems/posix/priorityimpl.h
include_rtems_posix_HEADERS += include/rtems/posix/psignal.h
include_rtems_posix_HEADERS += include/rtems/posix/psignalimpl.h
@@ -89,11 +91,6 @@ libposix_a_SOURCES += src/cond.c src/condattrdestroy.c \
src/condinit.c src/condsignal.c src/condsignalsupp.c \
src/condtimedwait.c src/condwait.c src/condwaitsupp.c src/condget.c
-## KEY_C_FILES
-libposix_a_SOURCES += src/key.c src/keycreate.c src/keydelete.c \
- src/keygetspecific.c src/keyfreememory.c src/keyrundestructors.c \
- src/keysetspecific.c
-
## MEMORY_C_FILES
libposix_a_SOURCES += src/mprotect.c
@@ -158,6 +155,11 @@ libposix_a_SOURCES += src/psignal.c src/alarm.c src/kill.c src/killinfo.c \
src/pthreadsigmask.c src/sigaction.c
endif
+## KEY_C_FILES
+libposix_a_SOURCES += src/key.c src/keycreate.c src/keydelete.c \
+ src/keygetspecific.c src/keyfreememory.c src/keyrundestructors.c \
+ src/keysetspecific.c
+
libposix_a_SOURCES += src/sigaddset.c src/sigdelset.c src/sigfillset.c \
src/sigemptyset.c src/sigismember.c
diff --git a/cpukit/posix/include/rtems/posix/config.h b/cpukit/posix/include/rtems/posix/config.h
index 83bd1def58..58dfb59237 100644
--- a/cpukit/posix/include/rtems/posix/config.h
+++ b/cpukit/posix/include/rtems/posix/config.h
@@ -8,7 +8,7 @@
*/
/*
- * COPYRIGHT (c) 1989-2013.
+ * COPYRIGHT (c) 1989-2014.
* On-Line Applications Research Corporation (OAR).
*
* The license and distribution terms for this file may be
@@ -76,22 +76,6 @@ typedef struct {
/**
* This field contains the maximum number of POSIX API
- * keys which are configured for this application.
- */
- uint32_t maximum_keys;
-
- /**
- * This field contains the maximum number of POSIX API
- * key value pairs which are configured for this application.
- *
- * @note There can be potentially be a key/value pair for
- * every thread to use every key. But normally this
- * many are not needed in a system.
- */
- uint32_t maximum_key_value_pairs;
-
- /**
- * This field contains the maximum number of POSIX API
* timers which are configured for this application.
*/
uint32_t maximum_timers;
diff --git a/cpukit/posix/include/rtems/posix/threadsup.h b/cpukit/posix/include/rtems/posix/threadsup.h
index 6bb3b844cc..f5d57ebe23 100644
--- a/cpukit/posix/include/rtems/posix/threadsup.h
+++ b/cpukit/posix/include/rtems/posix/threadsup.h
@@ -7,7 +7,7 @@
*/
/*
- * COPYRIGHT (c) 1989-2011.
+ * COPYRIGHT (c) 1989-2014.
* On-Line Applications Research Corporation (OAR).
*
* The license and distribution terms for this file may be
@@ -90,15 +90,6 @@ typedef struct {
struct _pthread_cleanup_context *last_cleanup_context;
#endif /* HAVE_STRUCT__PTHREAD_CLEANUP_CONTEXT */
- /**
- * 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.
- */
- Chain_Control Key_Chain;
-
} POSIX_API_Control;
/**
diff --git a/cpukit/posix/preinstall.am b/cpukit/posix/preinstall.am
index d0e238cd15..d8ca9cdf26 100644
--- a/cpukit/posix/preinstall.am
+++ b/cpukit/posix/preinstall.am
@@ -27,6 +27,22 @@ $(PROJECT_INCLUDE)/rtems/posix/sigset.h: include/rtems/posix/sigset.h $(PROJECT_
$(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/posix/sigset.h
PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/posix/sigset.h
+$(PROJECT_INCLUDE)/rtems/posix/key.h: include/rtems/posix/key.h $(PROJECT_INCLUDE)/rtems/posix/$(dirstamp)
+ $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/posix/key.h
+PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/posix/key.h
+
+$(PROJECT_INCLUDE)/rtems/posix/keyimpl.h: include/rtems/posix/keyimpl.h $(PROJECT_INCLUDE)/rtems/posix/$(dirstamp)
+ $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/posix/keyimpl.h
+PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/posix/keyimpl.h
+
+$(PROJECT_INCLUDE)/rtems/posix/config.h: include/rtems/posix/config.h $(PROJECT_INCLUDE)/rtems/posix/$(dirstamp)
+ $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/posix/config.h
+PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/posix/config.h
+
+$(PROJECT_INCLUDE)/rtems/posix/posixapi.h: include/rtems/posix/posixapi.h $(PROJECT_INCLUDE)/rtems/posix/$(dirstamp)
+ $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/posix/posixapi.h
+PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/posix/posixapi.h
+
if HAS_PTHREADS
$(PROJECT_INCLUDE)/aio.h: include/aio.h $(PROJECT_INCLUDE)/$(dirstamp)
$(INSTALL_DATA) $< $(PROJECT_INCLUDE)/aio.h
@@ -56,18 +72,6 @@ $(PROJECT_INCLUDE)/rtems/posix/condimpl.h: include/rtems/posix/condimpl.h $(PROJ
$(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/posix/condimpl.h
PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/posix/condimpl.h
-$(PROJECT_INCLUDE)/rtems/posix/config.h: include/rtems/posix/config.h $(PROJECT_INCLUDE)/rtems/posix/$(dirstamp)
- $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/posix/config.h
-PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/posix/config.h
-
-$(PROJECT_INCLUDE)/rtems/posix/key.h: include/rtems/posix/key.h $(PROJECT_INCLUDE)/rtems/posix/$(dirstamp)
- $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/posix/key.h
-PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/posix/key.h
-
-$(PROJECT_INCLUDE)/rtems/posix/keyimpl.h: include/rtems/posix/keyimpl.h $(PROJECT_INCLUDE)/rtems/posix/$(dirstamp)
- $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/posix/keyimpl.h
-PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/posix/keyimpl.h
-
$(PROJECT_INCLUDE)/rtems/posix/mqueue.h: include/rtems/posix/mqueue.h $(PROJECT_INCLUDE)/rtems/posix/$(dirstamp)
$(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/posix/mqueue.h
PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/posix/mqueue.h
@@ -88,10 +92,6 @@ $(PROJECT_INCLUDE)/rtems/posix/onceimpl.h: include/rtems/posix/onceimpl.h $(PROJ
$(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/posix/onceimpl.h
PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/posix/onceimpl.h
-$(PROJECT_INCLUDE)/rtems/posix/posixapi.h: include/rtems/posix/posixapi.h $(PROJECT_INCLUDE)/rtems/posix/$(dirstamp)
- $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/posix/posixapi.h
-PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/posix/posixapi.h
-
$(PROJECT_INCLUDE)/rtems/posix/priorityimpl.h: include/rtems/posix/priorityimpl.h $(PROJECT_INCLUDE)/rtems/posix/$(dirstamp)
$(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/posix/priorityimpl.h
PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/posix/priorityimpl.h
diff --git a/cpukit/posix/src/key.c b/cpukit/posix/src/key.c
index 2b32b50bcf..41bb946521 100644
--- a/cpukit/posix/src/key.c
+++ b/cpukit/posix/src/key.c
@@ -7,7 +7,7 @@
/*
* Copyright (c) 2012 Zhongwei Yao.
- * COPYRIGHT (c) 1989-2008.
+ * COPYRIGHT (c) 1989-2014.
* On-Line Applications Research Corporation (OAR).
*
* The license and distribution terms for this file may be
@@ -19,8 +19,9 @@
#include "config.h"
#endif
+#include <rtems/config.h>
+
#include <rtems/posix/keyimpl.h>
-#include <rtems/posix/config.h>
#include <rtems/score/chainimpl.h>
#include <rtems/score/objectimpl.h>
#include <rtems/score/wkspace.h>
@@ -72,7 +73,7 @@ int _POSIX_Keys_Key_value_lookup_tree_compare_function(
static uint32_t _POSIX_Keys_Get_keypool_bump_count( void )
{
- uint32_t max = Configuration_POSIX_API.maximum_key_value_pairs;
+ uint32_t max = Configuration.maximum_key_value_pairs;
return _Objects_Is_unlimited( max ) ?
_Objects_Maximum_per_allocation( max ) : 0;
@@ -80,7 +81,7 @@ static uint32_t _POSIX_Keys_Get_keypool_bump_count( void )
static uint32_t _POSIX_Keys_Get_initial_keypool_size( void )
{
- uint32_t max = Configuration_POSIX_API.maximum_key_value_pairs;
+ uint32_t max = Configuration.maximum_key_value_pairs;
return _Objects_Maximum_per_allocation( max );
}
@@ -135,7 +136,7 @@ void _POSIX_Key_Manager_initialization(void)
&_POSIX_Keys_Information, /* object information table */
OBJECTS_POSIX_API, /* object API */
OBJECTS_POSIX_KEYS, /* object class */
- Configuration_POSIX_API.maximum_keys,
+ Configuration.maximum_keys,
/* maximum objects of this class */
sizeof( POSIX_Keys_Control ),
/* size of this object's control block */
diff --git a/cpukit/posix/src/keyrundestructors.c b/cpukit/posix/src/keyrundestructors.c
index 2545486940..312cf35e68 100644
--- a/cpukit/posix/src/keyrundestructors.c
+++ b/cpukit/posix/src/keyrundestructors.c
@@ -9,7 +9,7 @@
* Copyright (c) 2012 Zhongwei Yao.
* Copyright (c) 2010 embedded brains GmbH.
*
- * COPYRIGHT (c) 1989-2007.
+ * COPYRIGHT (c) 1989-2014.
* On-Line Applications Research Corporation (OAR).
*
* The license and distribution terms for this file may be
@@ -22,8 +22,8 @@
#endif
#include <rtems/posix/keyimpl.h>
-#include <rtems/posix/threadsup.h>
#include <rtems/score/chainimpl.h>
+#include <rtems/score/thread.h>
/*
* _POSIX_Keys_Run_destructors
@@ -46,9 +46,7 @@ void _POSIX_Keys_Run_destructors(
_Thread_Disable_dispatch();
- chain = &(
- (POSIX_API_Control *)thread->API_Extensions[ THREAD_API_POSIX ]
- )->Key_Chain;
+ chain = &thread->Key_Chain;
iter = (POSIX_Keys_Key_value_pair *) _Chain_First( chain );
while ( !_Chain_Is_tail( chain, &iter->Key_values_per_thread_node ) ) {
next = (POSIX_Keys_Key_value_pair *)
diff --git a/cpukit/posix/src/keysetspecific.c b/cpukit/posix/src/keysetspecific.c
index 5cfa90e4e7..c6e2d30151 100644
--- a/cpukit/posix/src/keysetspecific.c
+++ b/cpukit/posix/src/keysetspecific.c
@@ -7,7 +7,7 @@
/*
* Copyright (c) 2012 Zhongwei Yao.
- * COPYRIGHT (c) 1989-2007.
+ * COPYRIGHT (c) 1989-2014.
* On-Line Applications Research Corporation (OAR).
*
* The license and distribution terms for this file may be
@@ -20,7 +20,7 @@
#endif
#include <rtems/posix/keyimpl.h>
-#include <rtems/posix/threadsup.h>
+#include <rtems/score/thread.h>
#include <rtems/score/chainimpl.h>
#include <errno.h>
@@ -37,7 +37,6 @@ int pthread_setspecific(
POSIX_Keys_Control *the_key;
Objects_Locations location;
POSIX_Keys_Key_value_pair *value_pair_ptr;
- POSIX_API_Control *api;
the_key = _POSIX_Keys_Get( key, &location );
switch ( location ) {
@@ -55,7 +54,7 @@ int pthread_setspecific(
value_pair_ptr->thread_id = _Thread_Executing->Object.id;
value_pair_ptr->value = value;
if ( _RBTree_Insert( &_POSIX_Keys_Key_value_lookup_tree,
- &(value_pair_ptr->Key_value_lookup_node) ) ) {
+ &(value_pair_ptr->Key_value_lookup_node) ) ) {
_Freechain_Put( (Freechain_Control *)&_POSIX_Keys_Keypool,
(void *) value_pair_ptr );
_Objects_Put( &the_key->Object );
@@ -64,9 +63,10 @@ int pthread_setspecific(
}
/** append rb_node to the thread API extension's chain */
- api = (POSIX_API_Control *)\
- (_Thread_Executing->API_Extensions[THREAD_API_POSIX]);
- _Chain_Append_unprotected( &api->Key_Chain, &value_pair_ptr->Key_values_per_thread_node );
+ _Chain_Append_unprotected(
+ &_Thread_Executing->Key_Chain,
+ &value_pair_ptr->Key_values_per_thread_node
+ );
_Objects_Put( &the_key->Object );
diff --git a/cpukit/posix/src/pthread.c b/cpukit/posix/src/pthread.c
index 67b62ae67e..33577a22ac 100644
--- a/cpukit/posix/src/pthread.c
+++ b/cpukit/posix/src/pthread.c
@@ -6,7 +6,7 @@
*/
/*
- * COPYRIGHT (c) 1989-2013.
+ * COPYRIGHT (c) 1989-2014.
* On-Line Applications Research Corporation (OAR).
*
* The license and distribution terms for this file may be
@@ -247,9 +247,6 @@ static bool _POSIX_Threads_Create_extension(
created
);
- /** initialize thread's key vaule node chain */
- _Chain_Initialize_empty( &api->Key_Chain );
-
return true;
}
@@ -275,11 +272,6 @@ static void _POSIX_Threads_Delete_extension(
_POSIX_Threads_cancel_run( deleted );
/*
- * Run all the key destructors
- */
- _POSIX_Keys_Run_destructors( deleted );
-
- /*
* Wakeup all the tasks which joined with this one
*/
value_ptr = (void **) deleted->Wait.return_argument;
diff --git a/cpukit/rtems/src/tasks.c b/cpukit/rtems/src/tasks.c
index 9a2a96f567..41347461ba 100644
--- a/cpukit/rtems/src/tasks.c
+++ b/cpukit/rtems/src/tasks.c
@@ -6,7 +6,7 @@
*/
/*
- * COPYRIGHT (c) 1989-2009.
+ * COPYRIGHT (c) 1989-2014.
* On-Line Applications Research Corporation (OAR).
*
* The license and distribution terms for this file may be
@@ -125,6 +125,11 @@ static void _RTEMS_tasks_Delete_extension(
}
/*
+ * Run all the key destructors
+ */
+ _POSIX_Keys_Run_destructors( deleted );
+
+ /*
* Free API specific memory
*/
diff --git a/cpukit/sapi/include/confdefs.h b/cpukit/sapi/include/confdefs.h
index f016b07254..08b8b5f4d7 100644
--- a/cpukit/sapi/include/confdefs.h
+++ b/cpukit/sapi/include/confdefs.h
@@ -29,7 +29,7 @@
*/
/*
- * COPYRIGHT (c) 1989-2011.
+ * COPYRIGHT (c) 1989-2014.
* On-Line Applications Research Corporation (OAR).
*
* The license and distribution terms for this file may be
@@ -1722,8 +1722,33 @@ const rtems_libio_helper rtems_fs_init_helper =
* POSIX API Configuration Parameters
*/
-#ifdef RTEMS_POSIX_API
+/*
+ * POSIX Keys are available whether or not the POSIX API is enabled.
+ */
+#include <rtems/posix/key.h>
+
+#ifndef CONFIGURE_MAXIMUM_POSIX_KEYS
+ #define CONFIGURE_MAXIMUM_POSIX_KEYS 0
+ #define CONFIGURE_MAXIMUM_POSIX_KEY_VALUE_PAIRS 0
+#else
+ #ifndef CONFIGURE_MAXIMUM_POSIX_KEY_VALUE_PAIRS
+ #define CONFIGURE_MAXIMUM_POSIX_KEY_VALUE_PAIRS \
+ (CONFIGURE_MAXIMUM_POSIX_KEYS * \
+ (CONFIGURE_MAXIMUM_POSIX_THREADS + CONFIGURE_MAXIMUM_TASKS))
+ #endif
+#endif
+#define CONFIGURE_MEMORY_FOR_POSIX_KEYS(_keys, _key_value_pairs) \
+ (_Configure_Object_RAM(_keys, sizeof(POSIX_Keys_Control) ) \
+ + _Configure_From_workspace( \
+ _key_value_pairs * sizeof(POSIX_Keys_Key_value_pair)))
+
+/*
+ * The rest of the POSIX threads API features are only available when
+ * POSIX is enabled.
+ */
+
+#ifdef RTEMS_POSIX_API
#include <sys/types.h>
#include <signal.h>
#include <limits.h>
@@ -1732,7 +1757,6 @@ const rtems_libio_helper rtems_fs_init_helper =
#include <rtems/posix/cond.h>
#include <rtems/posix/mqueue.h>
#include <rtems/posix/mutex.h>
- #include <rtems/posix/key.h>
#include <rtems/posix/psignal.h>
#include <rtems/posix/pthread.h>
#include <rtems/posix/rwlock.h>
@@ -1774,20 +1798,6 @@ const rtems_libio_helper rtems_fs_init_helper =
_Configure_Object_RAM(_condvars, \
sizeof(POSIX_Condition_variables_Control) )
- #ifndef CONFIGURE_MAXIMUM_POSIX_KEYS
- #define CONFIGURE_MAXIMUM_POSIX_KEYS 0
- #define CONFIGURE_MAXIMUM_POSIX_KEY_VALUE_PAIRS 0
- #else
- #ifndef CONFIGURE_MAXIMUM_POSIX_KEY_VALUE_PAIRS
- #define CONFIGURE_MAXIMUM_POSIX_KEY_VALUE_PAIRS \
- CONFIGURE_MAXIMUM_POSIX_KEYS \
- * (CONFIGURE_MAXIMUM_POSIX_THREADS + CONFIGURE_MAXIMUM_TASKS)
- #endif
- #endif
- #define CONFIGURE_MEMORY_FOR_POSIX_KEYS(_keys, _key_value_pairs) \
- (_Configure_Object_RAM(_keys, sizeof(POSIX_Keys_Control) ) \
- + _Configure_From_workspace(_key_value_pairs * sizeof(POSIX_Keys_Key_value_pair)))
-
#ifndef CONFIGURE_MAXIMUM_POSIX_TIMERS
#define CONFIGURE_MAXIMUM_POSIX_TIMERS 0
#endif
@@ -1894,8 +1904,6 @@ const rtems_libio_helper rtems_fs_init_helper =
CONFIGURE_MEMORY_FOR_POSIX_CONDITION_VARIABLES( \
CONFIGURE_MAXIMUM_POSIX_CONDITION_VARIABLES + \
CONFIGURE_MAXIMUM_GO_CHANNELS + CONFIGURE_GO_INIT_CONDITION_VARIABLES) + \
- CONFIGURE_MEMORY_FOR_POSIX_KEYS( CONFIGURE_MAXIMUM_POSIX_KEYS, \
- CONFIGURE_MAXIMUM_POSIX_KEY_VALUE_PAIRS ) + \
CONFIGURE_MEMORY_FOR_POSIX_QUEUED_SIGNALS( \
CONFIGURE_MAXIMUM_POSIX_QUEUED_SIGNALS ) + \
CONFIGURE_MEMORY_FOR_POSIX_MESSAGE_QUEUES( \
@@ -2213,6 +2221,9 @@ const rtems_libio_helper rtems_fs_init_helper =
CONFIGURE_MEMORY_FOR_TASKS( \
CONFIGURE_TOTAL_TASKS_AND_THREADS, CONFIGURE_TOTAL_TASKS_AND_THREADS) + \
CONFIGURE_MEMORY_FOR_CLASSIC + \
+ CONFIGURE_MEMORY_FOR_POSIX_KEYS( \
+ CONFIGURE_MAXIMUM_POSIX_KEYS, \
+ CONFIGURE_MAXIMUM_POSIX_KEY_VALUE_PAIRS ) + \
CONFIGURE_MEMORY_FOR_POSIX + \
CONFIGURE_MEMORY_FOR_STATIC_EXTENSIONS + \
CONFIGURE_MEMORY_FOR_MP + \
@@ -2344,8 +2355,6 @@ const rtems_libio_helper rtems_fs_init_helper =
CONFIGURE_MAXIMUM_POSIX_CONDITION_VARIABLES +
CONFIGURE_MAXIMUM_ADA_TASKS + CONFIGURE_MAXIMUM_FAKE_ADA_TASKS +
CONFIGURE_GO_INIT_CONDITION_VARIABLES + CONFIGURE_MAXIMUM_GO_CHANNELS,
- CONFIGURE_MAXIMUM_POSIX_KEYS,
- CONFIGURE_MAXIMUM_POSIX_KEY_VALUE_PAIRS,
CONFIGURE_MAXIMUM_POSIX_TIMERS,
CONFIGURE_MAXIMUM_POSIX_QUEUED_SIGNALS,
CONFIGURE_MAXIMUM_POSIX_MESSAGE_QUEUES,
@@ -2389,6 +2398,8 @@ const rtems_libio_helper rtems_fs_init_helper =
CONFIGURE_EXECUTIVE_RAM_SIZE, /* required RTEMS workspace */
CONFIGURE_STACK_SPACE_SIZE, /* required stack space */
CONFIGURE_MAXIMUM_USER_EXTENSIONS, /* maximum dynamic extensions */
+ CONFIGURE_MAXIMUM_POSIX_KEYS, /* POSIX keys are always */
+ CONFIGURE_MAXIMUM_POSIX_KEY_VALUE_PAIRS, /* enabled */
CONFIGURE_MICROSECONDS_PER_TICK, /* microseconds per clock tick */
1000 * CONFIGURE_MICROSECONDS_PER_TICK, /* nanoseconds per clock tick */
CONFIGURE_TICKS_PER_TIMESLICE, /* ticks per timeslice quantum */
@@ -2525,11 +2536,13 @@ const rtems_libio_helper rtems_fs_init_helper =
uint32_t BARRIERS;
uint32_t USER_EXTENSIONS;
+ /* POSIX API managers that are always enabled */
+ uint32_t POSIX_KEYS;
+
#ifdef RTEMS_POSIX_API
/* POSIX API Pieces */
uint32_t POSIX_MUTEXES;
uint32_t POSIX_CONDITION_VARIABLES;
- uint32_t POSIX_KEYS;
uint32_t POSIX_TIMERS;
uint32_t POSIX_QUEUED_SIGNALS;
uint32_t POSIX_MESSAGE_QUEUES;
@@ -2580,6 +2593,8 @@ const rtems_libio_helper rtems_fs_init_helper =
CONFIGURE_MEMORY_FOR_PERIODS(CONFIGURE_MAXIMUM_PERIODS),
CONFIGURE_MEMORY_FOR_BARRIERS(CONFIGURE_BARRIERS),
CONFIGURE_MEMORY_FOR_USER_EXTENSIONS(CONFIGURE_MAXIMUM_USER_EXTENSIONS),
+ CONFIGURE_MEMORY_FOR_POSIX_KEYS( CONFIGURE_MAXIMUM_POSIX_KEYS, \
+ CONFIGURE_MAXIMUM_POSIX_KEY_VALUE_PAIRS ),
#ifdef RTEMS_POSIX_API
/* POSIX API Pieces */
@@ -2589,8 +2604,6 @@ const rtems_libio_helper rtems_fs_init_helper =
CONFIGURE_MEMORY_FOR_POSIX_CONDITION_VARIABLES(
CONFIGURE_MAXIMUM_POSIX_CONDITION_VARIABLES +
CONFIGURE_MAXIMUM_GO_CHANNELS + CONFIGURE_GO_INIT_CONDITION_VARIABLES),
- CONFIGURE_MEMORY_FOR_POSIX_KEYS( CONFIGURE_MAXIMUM_POSIX_KEYS, \
- CONFIGURE_MAXIMUM_POSIX_KEY_VALUE_PAIRS ),
CONFIGURE_MEMORY_FOR_POSIX_QUEUED_SIGNALS(
CONFIGURE_MAXIMUM_POSIX_QUEUED_SIGNALS ),
CONFIGURE_MEMORY_FOR_POSIX_MESSAGE_QUEUES(
@@ -2655,13 +2668,15 @@ const rtems_libio_helper rtems_fs_init_helper =
/*
* If an attempt was made to configure POSIX objects and
* the POSIX API was not configured into RTEMS, error out.
+ *
+ * @note POSIX Keys are always available so the parameters
+ * CONFIGURE_MAXIMUM_POSIX_KEYS and
+ * CONFIGURE_MAXIMUM_POSIX_KEY_VALUE_PAIRS are not in this list.
*/
#if !defined(RTEMS_POSIX_API)
#if ((CONFIGURE_MAXIMUM_POSIX_THREADS != 0) || \
(CONFIGURE_MAXIMUM_POSIX_MUTEXES != 0) || \
(CONFIGURE_MAXIMUM_POSIX_CONDITION_VARIABLES != 0) || \
- (CONFIGURE_MAXIMUM_POSIX_KEYS != 0) || \
- (CONFIGURE_MAXIMUM_POSIX_KEY_VALUE_PAIRS != 0) || \
(CONFIGURE_MAXIMUM_POSIX_TIMERS != 0) || \
(CONFIGURE_MAXIMUM_POSIX_QUEUED_SIGNALS != 0) || \
(CONFIGURE_MAXIMUM_POSIX_MESSAGE_QUEUES != 0) || \
@@ -2747,14 +2762,11 @@ const rtems_libio_helper rtems_fs_init_helper =
* POSIX Key pair shouldn't be less than POSIX Key, which is highly
* likely to be error.
*/
-#if defined(RTEMS_POSIX_API)
- #if (CONFIGURE_MAXIMUM_POSIX_KEYS != 0) && \
- (CONFIGURE_MAXIMUM_POSIX_KEY_VALUE_PAIRS != 0)
- #if (CONFIGURE_MAXIMUM_POSIX_KEY_VALUE_PAIRS < \
- CONFIGURE_MAXIMUM_POSIX_KEYS)
- #error "Fewer POSIX Key pairs than POSIX Key!"
- #endif
- #endif
+#if (CONFIGURE_MAXIMUM_POSIX_KEYS != 0) && \
+ (CONFIGURE_MAXIMUM_POSIX_KEY_VALUE_PAIRS != 0)
+ #if (CONFIGURE_MAXIMUM_POSIX_KEY_VALUE_PAIRS < CONFIGURE_MAXIMUM_POSIX_KEYS)
+ #error "Fewer POSIX Key pairs than POSIX Key!"
+ #endif
#endif
#endif
diff --git a/cpukit/sapi/include/rtems/config.h b/cpukit/sapi/include/rtems/config.h
index d25b905ee2..8a77ea3ae6 100644
--- a/cpukit/sapi/include/rtems/config.h
+++ b/cpukit/sapi/include/rtems/config.h
@@ -8,7 +8,7 @@
*/
/*
- * COPYRIGHT (c) 1989-2011.
+ * COPYRIGHT (c) 1989-2014.
* On-Line Applications Research Corporation (OAR).
*
* The license and distribution terms for this file may be
@@ -143,6 +143,22 @@ typedef struct {
*/
uint32_t maximum_extensions;
+ /**
+ * This field contains the maximum number of POSIX API
+ * keys which are configured for this application.
+ */
+ uint32_t maximum_keys;
+
+ /**
+ * This field contains the maximum number of POSIX API
+ * key value pairs which are configured for this application.
+ *
+ * @note There can be potentially be a key/value pair for
+ * every thread to use every key. But normally this
+ * many are not needed in a system.
+ */
+ uint32_t maximum_key_value_pairs;
+
/**
* This field specifies the number of microseconds which elapse
* between clock ticks. This is the basis for RTEMS timing.
diff --git a/cpukit/sapi/src/exinit.c b/cpukit/sapi/src/exinit.c
index 73ebea9929..077a092b0e 100644
--- a/cpukit/sapi/src/exinit.c
+++ b/cpukit/sapi/src/exinit.c
@@ -1,15 +1,13 @@
/**
* @file
*
- * @brief Device Driver Initialization Functions
+ * @brief Initialization Manager
*
* @ingroup ClassicRTEMS
*/
/*
- * Initialization Manager
- *
- * COPYRIGHT (c) 1989-2011.
+ * COPYRIGHT (c) 1989-2014.
* On-Line Applications Research Corporation (OAR).
*
* The license and distribution terms for this file may be
@@ -57,9 +55,7 @@
#include <rtems/rtems/rtemsapi.h>
-#ifdef RTEMS_POSIX_API
- #include <rtems/posix/posixapi.h>
-#endif
+#include <rtems/posix/posixapi.h>
Objects_Information *_Internal_Objects[ OBJECTS_INTERNAL_CLASSES_LAST + 1 ];
@@ -147,9 +143,7 @@ void rtems_initialize_data_structures(void)
_IO_Manager_initialization();
- #ifdef RTEMS_POSIX_API
- _POSIX_API_Initialize();
- #endif
+ _POSIX_API_Initialize();
_System_state_Set( SYSTEM_STATE_BEFORE_MULTITASKING );
diff --git a/cpukit/sapi/src/posixapi.c b/cpukit/sapi/src/posixapi.c
index bcf807eab2..de502ec88d 100644
--- a/cpukit/sapi/src/posixapi.c
+++ b/cpukit/sapi/src/posixapi.c
@@ -7,7 +7,7 @@
*/
/*
- * COPYRIGHT (c) 1989-2010.
+ * COPYRIGHT (c) 1989-2014.
* On-Line Applications Research Corporation (OAR).
*
* The license and distribution terms for this file may be
@@ -22,19 +22,21 @@
#define POSIX_API_INIT
#include <rtems/system.h> /* include this before checking RTEMS_POSIX_API */
-#ifdef RTEMS_POSIX_API
+#include <rtems/config.h>
+#include <rtems/posix/keyimpl.h>
+#include <rtems/posix/posixapi.h>
+
+#ifdef RTEMS_POSIX_API
#include <sys/types.h>
#include <mqueue.h>
#include <rtems/config.h>
#include <rtems/posix/barrierimpl.h>
-#include <rtems/posix/condimpl.h>
#include <rtems/posix/config.h>
-#include <rtems/posix/keyimpl.h>
+#include <rtems/posix/condimpl.h>
#include <rtems/posix/mqueueimpl.h>
#include <rtems/posix/muteximpl.h>
#include <rtems/posix/onceimpl.h>
-#include <rtems/posix/posixapi.h>
#include <rtems/posix/priorityimpl.h>
#include <rtems/posix/psignalimpl.h>
#include <rtems/posix/pthreadimpl.h>
@@ -43,6 +45,7 @@
#include <rtems/posix/semaphoreimpl.h>
#include <rtems/posix/spinlockimpl.h>
#include <rtems/posix/time.h>
+#endif
void _POSIX_Fatal_error( POSIX_Fatal_domain domain, int eno )
{
@@ -68,18 +71,19 @@ void _POSIX_API_Initialize(void)
*/
_Objects_Information_table[OBJECTS_POSIX_API] = _POSIX_Objects;
- _POSIX_signals_Manager_Initialization();
- _POSIX_Threads_Manager_initialization();
- _POSIX_Condition_variables_Manager_initialization();
_POSIX_Key_Manager_initialization();
- _POSIX_Mutex_Manager_initialization();
- _POSIX_Message_queue_Manager_initialization();
- _POSIX_Once_Manager_initialization();
- _POSIX_Semaphore_Manager_initialization();
- _POSIX_Timer_Manager_initialization();
- _POSIX_Barrier_Manager_initialization();
- _POSIX_RWLock_Manager_initialization();
- _POSIX_Spinlock_Manager_initialization();
-}
-#endif
+ #ifdef RTEMS_POSIX_API
+ _POSIX_signals_Manager_Initialization();
+ _POSIX_Threads_Manager_initialization();
+ _POSIX_Condition_variables_Manager_initialization();
+ _POSIX_Mutex_Manager_initialization();
+ _POSIX_Message_queue_Manager_initialization();
+ _POSIX_Once_Manager_initialization();
+ _POSIX_Semaphore_Manager_initialization();
+ _POSIX_Timer_Manager_initialization();
+ _POSIX_Barrier_Manager_initialization();
+ _POSIX_RWLock_Manager_initialization();
+ _POSIX_Spinlock_Manager_initialization();
+ #endif
+}
diff --git a/cpukit/score/include/rtems/score/thread.h b/cpukit/score/include/rtems/score/thread.h
index ed12ad272a..527be58110 100644
--- a/cpukit/score/include/rtems/score/thread.h
+++ b/cpukit/score/include/rtems/score/thread.h
@@ -8,7 +8,7 @@
*/
/*
- * COPYRIGHT (c) 1989-2009.
+ * COPYRIGHT (c) 1989-2014.
* On-Line Applications Research Corporation (OAR).
*
* The license and distribution terms for this file may be
@@ -471,8 +471,19 @@ struct Thread_Control_struct {
void *API_Extensions[ THREAD_API_LAST + 1 ];
/** This field points to the user extension pointers. */
void **extensions;
+
/** This field points to the set of per task variables. */
rtems_task_variable_t *task_variables;
+
+ /**
+ * 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.
+ */
+ Chain_Control Key_Chain;
+
};
#if (CPU_PROVIDES_IDLE_THREAD_BODY == FALSE)
diff --git a/cpukit/score/src/threadinitialize.c b/cpukit/score/src/threadinitialize.c
index acd6636ac8..808c425d33 100644
--- a/cpukit/score/src/threadinitialize.c
+++ b/cpukit/score/src/threadinitialize.c
@@ -2,6 +2,7 @@
* @file
*
* @brief Initialize Thread
+ *
* @ingroup ScoreThread
*/
/*
@@ -233,6 +234,11 @@ bool _Thread_Initialize(
#endif
/*
+ * initialize thread's key vaule node chain
+ */
+ _Chain_Initialize_empty( &the_thread->Key_Chain );
+
+ /*
* Open the object
*/
_Objects_Open( information, &the_thread->Object, name );