summaryrefslogtreecommitdiffstats
path: root/cpukit/score/include/rtems/score
diff options
context:
space:
mode:
authorSebastian Huber <sebastian.huber@embedded-brains.de>2015-06-24 15:43:19 +0200
committerSebastian Huber <sebastian.huber@embedded-brains.de>2015-07-23 08:01:13 +0200
commitd7665823b208daefb6855591d808e1f3075cedcb (patch)
tree2080d79568c92ae40f9a49f3f82095307766cb1f /cpukit/score/include/rtems/score
parentscore: Introduce Thread_queue_Queue (diff)
downloadrtems-d7665823b208daefb6855591d808e1f3075cedcb.tar.bz2
score: Introduce Thread_queue_Heads
Move the storage for the thread queue heads to the threads. Each thread provides a set of thread queue heads allocated from a dedicated memory pool. In case a thread blocks on a queue, then it lends its heads to the queue. In case the thread unblocks, then it takes a free set of threads from the queue. Since a thread can block on at most one queue this works. This mechanism is used in FreeBSD. The motivation for this change is to reduce the memory demands of the synchronization objects. On a 32-bit uni-processor configuration the Thread_queue_Control size is now 8 bytes, compared to 64 bytes in RTEMS 4.10 (other changes reduced the size as well).
Diffstat (limited to '')
-rw-r--r--cpukit/score/include/rtems/score/objectimpl.h7
-rw-r--r--cpukit/score/include/rtems/score/thread.h2
-rw-r--r--cpukit/score/include/rtems/score/threadimpl.h26
-rw-r--r--cpukit/score/include/rtems/score/threadq.h30
-rw-r--r--cpukit/score/include/rtems/score/threadqimpl.h40
5 files changed, 61 insertions, 44 deletions
diff --git a/cpukit/score/include/rtems/score/objectimpl.h b/cpukit/score/include/rtems/score/objectimpl.h
index a5a3b7ef5f..1919cd1d64 100644
--- a/cpukit/score/include/rtems/score/objectimpl.h
+++ b/cpukit/score/include/rtems/score/objectimpl.h
@@ -718,6 +718,13 @@ Objects_Maximum _Objects_Active_count(
const Objects_Information *information
);
+RTEMS_INLINE_ROUTINE Objects_Maximum _Objects_Extend_size(
+ const Objects_Information *information
+)
+{
+ return information->auto_extend ? information->allocation_size : 0;
+}
+
/**
* This function returns true if the api is valid.
*
diff --git a/cpukit/score/include/rtems/score/thread.h b/cpukit/score/include/rtems/score/thread.h
index f9ba3a030e..2f0b35e1a8 100644
--- a/cpukit/score/include/rtems/score/thread.h
+++ b/cpukit/score/include/rtems/score/thread.h
@@ -349,6 +349,8 @@ typedef struct {
* @see _Thread_Lock_set() and _Thread_Wait_set_operations().
*/
const Thread_queue_Operations *operations;
+
+ Thread_queue_Heads *spare_heads;
} Thread_Wait_information;
/**
diff --git a/cpukit/score/include/rtems/score/threadimpl.h b/cpukit/score/include/rtems/score/threadimpl.h
index 4dcef0b7d8..7b8f89c346 100644
--- a/cpukit/score/include/rtems/score/threadimpl.h
+++ b/cpukit/score/include/rtems/score/threadimpl.h
@@ -32,6 +32,7 @@
#include <rtems/score/sysstate.h>
#include <rtems/score/threadqimpl.h>
#include <rtems/score/todimpl.h>
+#include <rtems/score/freechain.h>
#include <rtems/config.h>
#ifdef __cplusplus
@@ -54,11 +55,17 @@ extern "C" {
*/
SCORE_EXTERN void *rtems_ada_self;
+typedef struct {
+ Objects_Information Objects;
+
+ Freechain_Control Free_thread_queue_heads;
+} Thread_Information;
+
/**
* The following defines the information control block used to
* manage this class of objects.
*/
-SCORE_EXTERN Objects_Information _Thread_Internal_information;
+SCORE_EXTERN Thread_Information _Thread_Internal_information;
/**
* The following points to the thread whose floating point
@@ -89,6 +96,19 @@ SCORE_EXTERN struct _reent **_Thread_libc_reent;
RTEMS_CONTAINER_OF( node, Thread_Control, Resource_node )
#endif
+void _Thread_Initialize_information(
+ Thread_Information *information,
+ Objects_APIs the_api,
+ uint16_t the_class,
+ uint32_t maximum,
+ bool is_string,
+ uint32_t maximum_name_length
+#if defined(RTEMS_MULTIPROCESSING)
+ ,
+ bool supports_global
+#endif
+);
+
/**
* @brief Initialize thread handler.
*
@@ -154,7 +174,7 @@ void _Thread_Stack_Free(
* guaranteed to be of at least minimum size.
*/
bool _Thread_Initialize(
- Objects_Information *information,
+ Thread_Information *information,
Thread_Control *the_thread,
const struct Scheduler_Control *scheduler,
void *stack_area,
@@ -736,7 +756,7 @@ RTEMS_INLINE_ROUTINE uint32_t _Thread_Get_maximum_internal_threads(void)
RTEMS_INLINE_ROUTINE Thread_Control *_Thread_Internal_allocate( void )
{
return (Thread_Control *)
- _Objects_Allocate_unprotected( &_Thread_Internal_information );
+ _Objects_Allocate_unprotected( &_Thread_Internal_information.Objects );
}
/**
diff --git a/cpukit/score/include/rtems/score/threadq.h b/cpukit/score/include/rtems/score/threadq.h
index 599a81c23c..e3aee5869a 100644
--- a/cpukit/score/include/rtems/score/threadq.h
+++ b/cpukit/score/include/rtems/score/threadq.h
@@ -52,6 +52,14 @@ typedef struct {
RBTree_Control Priority;
} Heads;
+ Chain_Control Free_chain;
+
+ Chain_Node Free_node;
+} Thread_queue_Heads;
+
+typedef struct {
+ Thread_queue_Heads *heads;
+
/**
* @brief Lock to protect this thread queue.
*
@@ -80,17 +88,6 @@ typedef void ( *Thread_queue_Priority_change_operation )(
);
/**
- * @brief Thread queue initialize operation.
- *
- * @param[in] queue The actual thread queue.
- *
- * @see _Thread_Wait_set_operations().
- */
-typedef void ( *Thread_queue_Initialize_operation )(
- Thread_queue_Queue *queue
-);
-
-/**
* @brief Thread queue enqueue operation.
*
* @param[in] queue The actual thread queue.
@@ -119,7 +116,7 @@ typedef void ( *Thread_queue_Extract_operation )(
/**
* @brief Thread queue first operation.
*
- * @param[in] queue The actual thread queue.
+ * @param[in] heads The thread queue heads.
*
* @retval NULL No thread is present on the thread queue.
* @retval first The first thread of the thread queue according to the insert
@@ -128,7 +125,7 @@ typedef void ( *Thread_queue_Extract_operation )(
* @see _Thread_Wait_set_operations().
*/
typedef Thread_Control *( *Thread_queue_First_operation )(
- Thread_queue_Queue *queue
+ Thread_queue_Heads *heads
);
/**
@@ -150,13 +147,6 @@ typedef struct {
Thread_queue_Priority_change_operation priority_change;
/**
- * @brief Thread queue initialize operation.
- *
- * Called by object initialization routines.
- */
- Thread_queue_Initialize_operation initialize;
-
- /**
* @brief Thread queue enqueue operation.
*
* Called by object routines to enqueue the thread.
diff --git a/cpukit/score/include/rtems/score/threadqimpl.h b/cpukit/score/include/rtems/score/threadqimpl.h
index 330b18c5bf..e1060e4e82 100644
--- a/cpukit/score/include/rtems/score/threadqimpl.h
+++ b/cpukit/score/include/rtems/score/threadqimpl.h
@@ -33,6 +33,14 @@ extern "C" {
*/
/**@{*/
+RTEMS_INLINE_ROUTINE void _Thread_queue_Queue_initialize(
+ Thread_queue_Queue *queue
+)
+{
+ queue->heads = NULL;
+ _ISR_lock_Initialize( &queue->Lock, "Thread Queue" );
+}
+
RTEMS_INLINE_ROUTINE void _Thread_queue_Queue_acquire_critical(
Thread_queue_Queue *queue,
ISR_lock_Context *lock_context
@@ -322,7 +330,13 @@ RTEMS_INLINE_ROUTINE Thread_Control *_Thread_queue_First_locked(
Thread_queue_Control *the_thread_queue
)
{
- return ( *the_thread_queue->operations->first )( &the_thread_queue->Queue );
+ Thread_queue_Heads *heads = the_thread_queue->Queue.heads;
+
+ if ( heads != NULL ) {
+ return ( *the_thread_queue->operations->first )( heads );
+ } else {
+ return NULL;
+ }
}
/**
@@ -375,9 +389,7 @@ void _Thread_queue_Initialize(
#if defined(RTEMS_SMP)
#define THREAD_QUEUE_FIFO_INITIALIZER( designator, name ) { \
.Queue = { \
- .Heads = { \
- .Fifo = CHAIN_INITIALIZER_EMPTY( designator.Queue.Heads.Fifo ) \
- }, \
+ .heads = NULL, \
.Lock = ISR_LOCK_INITIALIZER( name ), \
}, \
.operations = &_Thread_queue_Operations_FIFO \
@@ -385,33 +397,19 @@ void _Thread_queue_Initialize(
#define THREAD_QUEUE_PRIORITY_INITIALIZER( designator, name ) { \
.Queue = { \
- .Heads = { \
- .Priority = RBTREE_INITIALIZER_EMPTY( \
- designator.Queue.Heads.Priority \
- ) \
- }, \
+ .heads = NULL, \
.Lock = ISR_LOCK_INITIALIZER( name ), \
}, \
.operations = &_Thread_queue_Operations_priority \
}
#else
#define THREAD_QUEUE_FIFO_INITIALIZER( designator, name ) { \
- .Queue = { \
- .Heads = { \
- .Fifo = CHAIN_INITIALIZER_EMPTY( designator.Queue.Heads.Fifo ) \
- } \
- }, \
+ .Queue = { .heads = NULL }, \
.operations = &_Thread_queue_Operations_FIFO \
}
#define THREAD_QUEUE_PRIORITY_INITIALIZER( designator, name ) { \
- .Queue = { \
- .Heads = { \
- .Priority = RBTREE_INITIALIZER_EMPTY( \
- designator.Queue.Heads.Priority \
- ) \
- } \
- }, \
+ .Queue = { .heads = NULL }, \
.operations = &_Thread_queue_Operations_priority \
}
#endif