summaryrefslogtreecommitdiffstats
path: root/cpukit/score/src/threadcreateidle.c
diff options
context:
space:
mode:
authorSebastian Huber <sebastian.huber@embedded-brains.de>2022-09-30 08:06:18 +0200
committerSebastian Huber <sebastian.huber@embedded-brains.de>2022-10-14 10:48:23 +0200
commit45ee958552ca35b6834985718ecd59b27fc52f86 (patch)
tree5d66e79cf20491f0f1b8f32b292a5a398d386ce4 /cpukit/score/src/threadcreateidle.c
parentstackchk01: Check CPU_STACK_MINIMUM_SIZE (diff)
downloadrtems-45ee958552ca35b6834985718ecd59b27fc52f86.tar.bz2
config: Add CONFIGURE_IDLE_TASK_STORAGE_SIZE
By default, allocate the IDLE task storage areas from the RTEMS Workspace. This avoids having to estimate the thread-local storage size in the default configuration. Add the application configuration option CONFIGURE_IDLE_TASK_STORAGE_SIZE to request a static allocation of the task storage area for IDLE tasks. Update #3835. Update #4524.
Diffstat (limited to '')
-rw-r--r--cpukit/score/src/threadcreateidle.c23
1 files changed, 16 insertions, 7 deletions
diff --git a/cpukit/score/src/threadcreateidle.c b/cpukit/score/src/threadcreateidle.c
index d2037b36f0..04565f910b 100644
--- a/cpukit/score/src/threadcreateidle.c
+++ b/cpukit/score/src/threadcreateidle.c
@@ -53,7 +53,10 @@
#include <string.h>
-static void _Thread_Create_idle_for_CPU( Per_CPU_Control *cpu )
+static void _Thread_Create_idle_for_CPU(
+ Per_CPU_Control *cpu,
+ uintptr_t storage_size
+)
{
Thread_Configuration config;
Thread_Control *idle;
@@ -70,8 +73,7 @@ static void _Thread_Create_idle_for_CPU( Per_CPU_Control *cpu )
config.is_fp = CPU_IDLE_TASK_IS_FP;
config.is_preemptible = true;
config.stack_free = _Objects_Free_nothing;
- config.stack_size = _Thread_Idle_stack_size
- + CPU_IDLE_TASK_IS_FP * CONTEXT_FP_SIZE;
+ config.stack_size = storage_size;
/*
* The IDLE thread stacks may be statically allocated or there may be a
@@ -118,21 +120,28 @@ static void _Thread_Create_idle_for_CPU( Per_CPU_Control *cpu )
void _Thread_Create_idle( void )
{
+ uintptr_t storage_size;
#if defined(RTEMS_SMP)
- uint32_t cpu_max;
- uint32_t cpu_index;
+ uint32_t cpu_max;
+ uint32_t cpu_index;
+#endif
+
+ storage_size = _TLS_Get_allocation_size() +
+ CPU_IDLE_TASK_IS_FP * CONTEXT_FP_SIZE +
+ _Thread_Idle_stack_size;
+#if defined(RTEMS_SMP)
cpu_max = _SMP_Get_processor_maximum();
for ( cpu_index = 0 ; cpu_index < cpu_max ; ++cpu_index ) {
Per_CPU_Control *cpu = _Per_CPU_Get_by_index( cpu_index );
if ( _Per_CPU_Is_processor_online( cpu ) ) {
- _Thread_Create_idle_for_CPU( cpu );
+ _Thread_Create_idle_for_CPU( cpu, storage_size );
}
}
#else
- _Thread_Create_idle_for_CPU( _Per_CPU_Get() );
+ _Thread_Create_idle_for_CPU( _Per_CPU_Get(), storage_size );
#endif
_CPU_Use_thread_local_storage(