[PATCH 1/5] score: Delete _Thread_Maximum_extensions

Joel Sherrill joel.sherrill at OARcorp.com
Fri Apr 4 15:21:27 UTC 2014


On 4/4/2014 10:07 AM, Sebastian Huber wrote:
> Use the Configuration instead.  Fix an off-by-one error in the
> allocation and initialization.
> ---
>  cpukit/sapi/include/confdefs.h                |    2 +-
>  cpukit/score/include/rtems/score/threadimpl.h |    7 -------
>  cpukit/score/src/thread.c                     |    4 ----
>  cpukit/score/src/threadinitialize.c           |   10 ++++------
>  testsuites/sptests/spsize/size.c              |    1 -
>  5 files changed, 5 insertions(+), 19 deletions(-)
>
> diff --git a/cpukit/sapi/include/confdefs.h b/cpukit/sapi/include/confdefs.h
> index 4bfe4e8..1ee3b21 100644
> --- a/cpukit/sapi/include/confdefs.h
> +++ b/cpukit/sapi/include/confdefs.h
> @@ -2080,7 +2080,7 @@ const rtems_libio_helper rtems_fs_init_helper =
>                + CONFIGURE_MEMORY_PER_TASK_FOR_POSIX_API \
>                + CONFIGURE_MEMORY_PER_TASK_FOR_SCHEDULER \
>                + _Configure_From_workspace( \
> -                (CONFIGURE_MAXIMUM_USER_EXTENSIONS + 1) * sizeof(void *) \
> +                CONFIGURE_MAXIMUM_USER_EXTENSIONS * sizeof(void *) \
>                ) \
>            ) \
>        + _Configure_Max_Objects(_number_FP_tasks) \
> diff --git a/cpukit/score/include/rtems/score/threadimpl.h b/cpukit/score/include/rtems/score/threadimpl.h
> index 6d4ca9f..f109d39 100644
> --- a/cpukit/score/include/rtems/score/threadimpl.h
> +++ b/cpukit/score/include/rtems/score/threadimpl.h
> @@ -58,13 +58,6 @@ SCORE_EXTERN void *rtems_ada_self;
>  SCORE_EXTERN Objects_Information _Thread_Internal_information;
>  
>  /**
> - *  The following holds how many user extensions are in the system.  This
> - *  is used to determine how many user extension data areas to allocate
> - *  per thread.
> - */
> -SCORE_EXTERN uint32_t   _Thread_Maximum_extensions;
> -
> -/**
>   *  The following is used to manage the length of a timeslice quantum.
>   */
>  SCORE_EXTERN uint32_t   _Thread_Ticks_per_timeslice;
> diff --git a/cpukit/score/src/thread.c b/cpukit/score/src/thread.c
> index 5063c78..589e474 100644
> --- a/cpukit/score/src/thread.c
> +++ b/cpukit/score/src/thread.c
> @@ -25,8 +25,6 @@ void _Thread_Handler_initialization(void)
>  {
>    uint32_t ticks_per_timeslice =
>      rtems_configuration_get_ticks_per_timeslice();
> -  uint32_t maximum_extensions =
> -    rtems_configuration_get_maximum_extensions();
>    rtems_stack_allocate_init_hook stack_allocate_init_hook =
>      rtems_configuration_get_stack_allocate_init_hook();
>    #if defined(RTEMS_MULTIPROCESSING)
> @@ -52,8 +50,6 @@ void _Thread_Handler_initialization(void)
>    _Thread_Allocated_fp      = NULL;
>  #endif
>  
> -  _Thread_Maximum_extensions = maximum_extensions;
> -
>    _Thread_Ticks_per_timeslice  = ticks_per_timeslice;
>  
>    #if defined(RTEMS_MULTIPROCESSING)
> diff --git a/cpukit/score/src/threadinitialize.c b/cpukit/score/src/threadinitialize.c
> index cf96c24..490fc25 100644
> --- a/cpukit/score/src/threadinitialize.c
> +++ b/cpukit/score/src/threadinitialize.c
> @@ -155,9 +155,9 @@ bool _Thread_Initialize(
>    /*
>     *  Allocate the extensions area for this thread
>     */
> -  if ( _Thread_Maximum_extensions ) {
> +  if ( rtems_configuration_get_maximum_extensions() ) {
>      extensions_area = _Workspace_Allocate(
> -      (_Thread_Maximum_extensions + 1) * sizeof( void * )
> +      rtems_configuration_get_maximum_extensions() * sizeof( void * )
I don't think you can delete the +1 because RTEMS never uses 0 as the
object index. If you configure N extensions, the valid index portion of
the object ID runs from 1 - N.

If those configured at configure time are installed without IDs, then
we may have a conflict in the memory area for dynamically and
statically installed ones.

But FWIW, I think it is bad practice to dynamically create and
install user extensions.

>      );
>      if ( !extensions_area )
>        goto failed;
> @@ -171,10 +171,8 @@ bool _Thread_Initialize(
>     * so they cannot rely on the thread create user extension
>     * call.
>     */
> -  if ( the_thread->extensions ) {
> -    for ( i = 0; i <= _Thread_Maximum_extensions ; i++ )
> -      the_thread->extensions[i] = NULL;
> -  }
> +  for ( i = 0 ; i < rtems_configuration_get_maximum_extensions() ; i++ )
> +    the_thread->extensions[i] = NULL;
>  
>    /*
>     *  General initialization
> diff --git a/testsuites/sptests/spsize/size.c b/testsuites/sptests/spsize/size.c
> index f24bc9b..1d4c96b 100644
> --- a/testsuites/sptests/spsize/size.c
> +++ b/testsuites/sptests/spsize/size.c
> @@ -385,7 +385,6 @@ uninitialized =
>  /*tasksimpl.h*/ (sizeof _RTEMS_tasks_Information)         +
>  
>  /*thread.h*/    (sizeof _Thread_Dispatch_disable_level)   +
> -                (sizeof _Thread_Maximum_extensions)       +
>                  (sizeof _Thread_Ticks_per_timeslice)      +
>                  (sizeof _Thread_Executing)                +
>                  (sizeof _Thread_Heir)                     +

-- 
Joel Sherrill, Ph.D.             Director of Research & Development
joel.sherrill at OARcorp.com        On-Line Applications Research
Ask me about RTEMS: a free RTOS  Huntsville AL 35805
Support Available                (256) 722-9985




More information about the devel mailing list