summaryrefslogtreecommitdiff
path: root/cpukit/score/src/threadinitialize.c
diff options
context:
space:
mode:
Diffstat (limited to 'cpukit/score/src/threadinitialize.c')
-rw-r--r--cpukit/score/src/threadinitialize.c44
1 files changed, 22 insertions, 22 deletions
diff --git a/cpukit/score/src/threadinitialize.c b/cpukit/score/src/threadinitialize.c
index 691f56388e..4c6d849111 100644
--- a/cpukit/score/src/threadinitialize.c
+++ b/cpukit/score/src/threadinitialize.c
@@ -19,6 +19,7 @@
#endif
#include <rtems/score/threadimpl.h>
+#include <rtems/score/freechainimpl.h>
#include <rtems/score/schedulerimpl.h>
#include <rtems/score/stackimpl.h>
#include <rtems/score/tls.h>
@@ -35,8 +36,8 @@ bool _Thread_Initialize(
uintptr_t tls_size;
bool extension_status;
size_t i;
- char *stack_area;
- size_t stack_size;
+ char *stack_begin;
+ char *stack_end;
Scheduler_Node *scheduler_node;
#if defined(RTEMS_SMP)
Scheduler_Node *scheduler_node_for_index;
@@ -59,8 +60,7 @@ bool _Thread_Initialize(
}
/* Set everything to perform the error case clean up */
- scheduler_index = 0;
- the_thread->Start.allocated_stack = config->allocated_stack;
+ the_thread->Start.stack_free = config->stack_free;
#if defined(RTEMS_SMP)
if (
@@ -82,16 +82,15 @@ bool _Thread_Initialize(
}
#endif
- stack_area = config->stack_area;
- stack_size = config->stack_size;
+ stack_begin = config->stack_area;
+ stack_end = stack_begin + config->stack_size;
/* Allocate floating-point context in stack area */
#if ( CPU_HARDWARE_FP == TRUE ) || ( CPU_SOFTWARE_FP == TRUE )
if ( config->is_fp ) {
- the_thread->fp_context = ( Context_Control_fp *) stack_area;
- the_thread->Start.fp_context = ( Context_Control_fp *) stack_area;
- stack_size -= CONTEXT_FP_SIZE;
- stack_area += CONTEXT_FP_SIZE;
+ stack_end -= CONTEXT_FP_SIZE;
+ the_thread->fp_context = (Context_Control_fp *) stack_end;
+ the_thread->Start.fp_context = (Context_Control_fp *) stack_end;
}
#endif
@@ -101,17 +100,16 @@ bool _Thread_Initialize(
if ( tls_size > 0 ) {
uintptr_t tls_align;
+ stack_end -= tls_size;
tls_align = (uintptr_t) _TLS_Alignment;
the_thread->Start.tls_area = (void *)
- ( ( (uintptr_t) stack_area + tls_align - 1 ) & ~( tls_align - 1 ) );
- stack_size -= tls_size;
- stack_area += tls_size;
+ ( ( (uintptr_t) stack_end + tls_align - 1 ) & ~( tls_align - 1 ) );
}
_Stack_Initialize(
- &the_thread->Start.Initial_stack,
- stack_area,
- stack_size
+ &the_thread->Start.Initial_stack,
+ stack_begin,
+ stack_end - stack_begin
);
/*
@@ -154,6 +152,7 @@ bool _Thread_Initialize(
scheduler_node = NULL;
scheduler_node_for_index = the_thread->Scheduler.nodes;
scheduler_for_index = &_Scheduler_Table[ 0 ];
+ scheduler_index = 0;
while ( scheduler_index < _Scheduler_Count ) {
Priority_Control priority_for_index;
@@ -256,10 +255,6 @@ bool _Thread_Initialize(
if ( extension_status )
return true;
-#if defined(RTEMS_SMP) || CPU_ENABLE_ROBUST_THREAD_DISPATCH == TRUE
-failed:
-#endif
-
#if defined(RTEMS_SMP)
while ( scheduler_index > 0 ) {
scheduler_node_for_index = (Scheduler_Node *)
@@ -274,10 +269,15 @@ failed:
}
#endif
- _Freechain_Put(
+ _Freechain_Push(
&information->Thread_queue_heads.Free,
the_thread->Wait.spare_heads
);
- _Stack_Free( the_thread->Start.allocated_stack );
+
+#if defined(RTEMS_SMP) || CPU_ENABLE_ROBUST_THREAD_DISPATCH == TRUE
+failed:
+#endif
+
+ ( *the_thread->Start.stack_free )( the_thread->Start.Initial_stack.area );
return false;
}