summaryrefslogtreecommitdiffstats
path: root/cpukit/score/src/threadinitialize.c
diff options
context:
space:
mode:
authorSebastian Huber <sebastian.huber@embedded-brains.de>2019-12-07 16:50:35 +0100
committerSebastian Huber <sebastian.huber@embedded-brains.de>2020-02-12 09:08:36 +0100
commitfc398fde77d25c086e109403eddd6de267982653 (patch)
treeb05f699063a0095d0d732d67d894d9dcf8376c72 /cpukit/score/src/threadinitialize.c
parentscore: Remove _Stack_Ensure_minimum() call (diff)
downloadrtems-fc398fde77d25c086e109403eddd6de267982653.tar.bz2
score: Simplify FP context allocation
Use the stack area to allocate the FP context. This considerably simplifies the application configuration since the task count no longer influences the configured work space size. With this change the stack space size is overestimated since an FP context for each thread is accounted. Memory constraint applications can use the stack size for fine tuning. Update #3835.
Diffstat (limited to 'cpukit/score/src/threadinitialize.c')
-rw-r--r--cpukit/score/src/threadinitialize.c39
1 files changed, 17 insertions, 22 deletions
diff --git a/cpukit/score/src/threadinitialize.c b/cpukit/score/src/threadinitialize.c
index c6e8abf979..48444824b2 100644
--- a/cpukit/score/src/threadinitialize.c
+++ b/cpukit/score/src/threadinitialize.c
@@ -43,9 +43,6 @@ bool _Thread_Initialize(
)
{
uintptr_t tls_size = _TLS_Get_size();
- #if ( CPU_HARDWARE_FP == TRUE ) || ( CPU_SOFTWARE_FP == TRUE )
- void *fp_area = NULL;
- #endif
bool extension_status;
size_t i;
Scheduler_Node *scheduler_node;
@@ -91,6 +88,13 @@ bool _Thread_Initialize(
if ( stack_area == NULL ) {
#endif
stack_size = _Stack_Ensure_minimum( stack_size );
+
+#if ( CPU_HARDWARE_FP == TRUE ) || ( CPU_SOFTWARE_FP == TRUE )
+ if ( is_fp ) {
+ stack_size += CONTEXT_FP_SIZE;
+ }
+#endif
+
stack_area = _Stack_Allocate( stack_size );
if ( stack_area == NULL ) {
@@ -102,6 +106,16 @@ bool _Thread_Initialize(
}
#endif
+ /* Allocate floating-point context in stack area */
+#if ( CPU_HARDWARE_FP == TRUE ) || ( CPU_SOFTWARE_FP == TRUE )
+ if ( is_fp ) {
+ the_thread->fp_context = stack_area;
+ the_thread->Start.fp_context = stack_area;
+ stack_size -= CONTEXT_FP_SIZE;
+ stack_area = (char *) stack_area + CONTEXT_FP_SIZE;
+ }
+#endif
+
_Stack_Initialize(
&the_thread->Start.Initial_stack,
stack_area,
@@ -124,19 +138,6 @@ bool _Thread_Initialize(
}
/*
- * Allocate the floating point area for this thread
- */
- #if ( CPU_HARDWARE_FP == TRUE ) || ( CPU_SOFTWARE_FP == TRUE )
- if ( is_fp ) {
- fp_area = _Workspace_Allocate( CONTEXT_FP_SIZE );
- if ( !fp_area )
- goto failed;
- }
- the_thread->fp_context = fp_area;
- the_thread->Start.fp_context = fp_area;
- #endif
-
- /*
* Get thread queue heads
*/
the_thread->Wait.spare_heads = _Freechain_Get(
@@ -301,16 +302,10 @@ failed:
#endif
_Workspace_Free( the_thread->Start.tls_area );
-
_Freechain_Put(
&information->Thread_queue_heads.Free,
the_thread->Wait.spare_heads
);
-
- #if ( CPU_HARDWARE_FP == TRUE ) || ( CPU_SOFTWARE_FP == TRUE )
- _Workspace_Free( fp_area );
- #endif
-
_Stack_Free( the_thread->Start.allocated_stack );
return false;
}