score: Simplify thread stack allocation

Remove superfluous Thread_Control::Start::stack member.

Update #3835.
This commit is contained in:
Sebastian Huber
2019-12-07 16:00:58 +01:00
parent bf39a9e2a8
commit a0211fc9f9
5 changed files with 29 additions and 57 deletions

View File

@@ -105,6 +105,16 @@ RTEMS_INLINE_ROUTINE size_t _Stack_Ensure_minimum (
return _Stack_Minimum();
}
/**
* @brief Allocate the requested stack space.
*
* @param stack_size The stack space that is requested.
*
* @retval stack_area The allocated stack area.
* @retval NULL The allocation failed.
*/
void *_Stack_Allocate( size_t stack_size );
/** @} */
#ifdef __cplusplus

View File

@@ -209,8 +209,6 @@ typedef struct {
/** This field is the initial FP context area address. */
Context_Control_fp *fp_context;
#endif
/** This field is the initial stack area address. */
void *stack;
/** The thread-local storage (TLS) area */
void *tls_area;
} Thread_Start_information;

View File

@@ -124,23 +124,6 @@ void _Thread_Create_idle(void);
*/
void _Thread_Start_multitasking( void ) RTEMS_NO_RETURN;
/**
* @brief Allocates the requested stack space for the thread.
*
* Allocate the requested stack space for the thread.
* Set the Start.stack field to the address of the stack.
*
* @param[out] the_thread The thread where the stack space is requested.
* @param stack_size The stack space that is requested.
*
* @retval actual Size allocated after any adjustment.
* @retval zero The allocation failed.
*/
size_t _Thread_Stack_Allocate(
Thread_Control *the_thread,
size_t stack_size
);
/**
* @brief Deallocates thread stack.
*

View File

@@ -43,8 +43,6 @@ bool _Thread_Initialize(
)
{
uintptr_t tls_size = _TLS_Get_size();
size_t actual_stack_size = 0;
void *stack = NULL;
#if ( CPU_HARDWARE_FP == TRUE ) || ( CPU_SOFTWARE_FP == TRUE )
void *fp_area = NULL;
#endif
@@ -92,30 +90,31 @@ bool _Thread_Initialize(
* Allocate and Initialize the stack for this thread.
*/
#if !defined(RTEMS_SCORE_THREAD_ENABLE_USER_PROVIDED_STACK_VIA_API)
actual_stack_size = _Thread_Stack_Allocate( the_thread, stack_size );
if ( !actual_stack_size || actual_stack_size < stack_size )
return false; /* stack allocation failed */
stack_size = _Stack_Ensure_minimum( stack_size );
stack_area = _Stack_Allocate( stack_size );
stack = the_thread->Start.stack;
if ( stack_area == NULL ) {
return false;
}
#else
if ( !stack_area ) {
actual_stack_size = _Thread_Stack_Allocate( the_thread, stack_size );
if ( !actual_stack_size || actual_stack_size < stack_size )
return false; /* stack allocation failed */
if ( stack_area == NULL ) {
stack_size = _Stack_Ensure_minimum( stack_size );
stack_area = _Stack_Allocate( stack_size );
if ( stack_area == NULL ) {
return false;
}
stack = the_thread->Start.stack;
the_thread->Start.core_allocated_stack = true;
} else {
stack = stack_area;
actual_stack_size = stack_size;
the_thread->Start.core_allocated_stack = false;
}
#endif
_Stack_Initialize(
&the_thread->Start.Initial_stack,
stack,
actual_stack_size
stack_area,
stack_size
);
scheduler_index = 0;

View File

@@ -1,11 +1,11 @@
/**
* @file
*
*
* @ingroup RTEMSScoreStack
*
* @brief Stack Allocate Helper
* @ingroup RTEMSScoreThread
*/
/*
* COPYRIGHT (c) 1989-2010.
* On-Line Applications Research Corporation (OAR).
@@ -19,28 +19,10 @@
#include "config.h"
#endif
#include <rtems/score/threadimpl.h>
#include <rtems/score/stackimpl.h>
#include <rtems/config.h>
size_t _Thread_Stack_Allocate(
Thread_Control *the_thread,
size_t stack_size
)
void *_Stack_Allocate( size_t stack_size )
{
void *stack_addr = 0;
size_t the_stack_size;
rtems_stack_allocate_hook stack_allocate_hook =
rtems_configuration_get_stack_allocate_hook();
the_stack_size = _Stack_Ensure_minimum( stack_size );
stack_addr = (*stack_allocate_hook)( the_stack_size );
if ( !stack_addr )
the_stack_size = 0;
the_thread->Start.stack = stack_addr;
return the_stack_size;
return ( *rtems_configuration_get_stack_allocate_hook() )( stack_size );
}