Stack allocator change was Re: change log for rtems (2011-12-14)

Joel Sherrill joel.sherrill at OARcorp.com
Wed Dec 14 14:06:33 UTC 2011


This change necessitates changes to doc/user/conf.t
and adds a user visible configuration change that needs
to be noted in the evolving 4.11 release notes:

http://www.rtems.org/wiki/index.php/4.11_Release_Notes

--joel

On 12/14/2011 07:31 AM, rtems-vc at rtems.org wrote:
> *sh*
> 2011-12-14	Sebastian Huber<sebastian.huber at embedded-brains.de>
>
> 	PR 1924/cpukit
> 	* sapi/include/rtems/config.h: Added stack_allocate_init_hook to
> 	rtems_configuration_table.
> 	* sapi/include/confdefs.h: Added CONFIGURE_TASK_STACK_FROM_ALLOCATOR
> 	and CONFIGURE_TASK_STACK_ALLOCATOR_INIT defines.  Set default stack
> 	allocator and free hook to _Workspace_Allocate() and _Workspace_Free()
> 	respectively.
> 	* score/src/thread.c, score/src/threadstackallocate.c,
> 	score/src/threadstackfree.c: Update due to API changes.
> M 
> <http://www.rtems.com/cgi-bin/viewcvs.cgi//rtems/cpukit/ChangeLog.diff?r1=text&tr1=1.3093&r2=text&tr2=1.3094&diff_format=h> 
> 	1.3094 	cpukit/ChangeLog
> M 
> <http://www.rtems.com/cgi-bin/viewcvs.cgi//rtems/cpukit/sapi/include/confdefs.h.diff?r1=text&tr1=1.178&r2=text&tr2=1.179&diff_format=h> 
> 	1.179 	cpukit/sapi/include/confdefs.h
> M 
> <http://www.rtems.com/cgi-bin/viewcvs.cgi//rtems/cpukit/sapi/include/rtems/config.h.diff?r1=text&tr1=1.57&r2=text&tr2=1.58&diff_format=h> 
> 	1.58 	cpukit/sapi/include/rtems/config.h
> M 
> <http://www.rtems.com/cgi-bin/viewcvs.cgi//rtems/cpukit/score/src/thread.c.diff?r1=text&tr1=1.68&r2=text&tr2=1.69&diff_format=h> 
> 	1.69 	cpukit/score/src/thread.c
> M 
> <http://www.rtems.com/cgi-bin/viewcvs.cgi//rtems/cpukit/score/src/threadstackallocate.c.diff?r1=text&tr1=1.15&r2=text&tr2=1.16&diff_format=h> 
> 	1.16 	cpukit/score/src/threadstackallocate.c
> M 
> <http://www.rtems.com/cgi-bin/viewcvs.cgi//rtems/cpukit/score/src/threadstackfree.c.diff?r1=text&tr1=1.8&r2=text&tr2=1.9&diff_format=h> 
> 	1.9 	cpukit/score/src/threadstackfree.c
>
> diff -u rtems/cpukit/ChangeLog:1.3093 rtems/cpukit/ChangeLog:1.3094
> --- rtems/cpukit/ChangeLog:1.3093	Wed Dec 14 03:22:42 2011
> +++ rtems/cpukit/ChangeLog	Wed Dec 14 07:17:18 2011
> @@ -1,5 +1,17 @@
>   2011-12-14	Sebastian Huber<sebastian.huber at embedded-brains.de>
>
> +	PR 1924/cpukit
> +	* sapi/include/rtems/config.h: Added stack_allocate_init_hook to
> +	rtems_configuration_table.
> +	* sapi/include/confdefs.h: Added CONFIGURE_TASK_STACK_FROM_ALLOCATOR
> +	and CONFIGURE_TASK_STACK_ALLOCATOR_INIT defines.  Set default stack
> +	allocator and free hook to _Workspace_Allocate() and _Workspace_Free()
> +	respectively.
> +	* score/src/thread.c, score/src/threadstackallocate.c,
> +	score/src/threadstackfree.c: Update due to API changes.
> +
> +2011-12-14	Sebastian Huber<sebastian.huber at embedded-brains.de>
> +
>   	* libcsupport/src/termios_setinitialbaud.c: Fixed typo.
>
>   2011-12-14	Sebastian Huber<sebastian.huber at embedded-brains.de>
>
> diff -u rtems/cpukit/sapi/include/confdefs.h:1.178 rtems/cpukit/sapi/include/confdefs.h:1.179
> --- rtems/cpukit/sapi/include/confdefs.h:1.178	Tue Dec 13 08:37:03 2011
> +++ rtems/cpukit/sapi/include/confdefs.h	Wed Dec 14 07:17:19 2011
> @@ -44,6 +44,7 @@
>    */
>   #include<rtems.h>
>   #include<rtems/score/apimutex.h>
> +#include<rtems/score/wkspace.h>
>
>   #ifdef __cplusplus
>   extern "C" {
> @@ -823,17 +824,24 @@
>   #endif
>
>   /**
> - *  Configure the very much optional task stack allocator
> + *  Configure the very much optional task stack allocator initialization
>    */
> -#ifndef CONFIGURE_TASK_STACK_ALLOCATOR
> -  #define CONFIGURE_TASK_STACK_ALLOCATOR NULL
> +#ifndef CONFIGURE_TASK_STACK_ALLOCATOR_INIT
> +  #define CONFIGURE_TASK_STACK_ALLOCATOR_INIT NULL
>   #endif
>
> -/**
> - *  Configure the very much optional task stack deallocator
> +/*
> + *  Configure the very much optional task stack allocator and deallocator.
>    */
> -#ifndef CONFIGURE_TASK_STACK_DEALLOCATOR
> -  #define CONFIGURE_TASK_STACK_DEALLOCATOR NULL
> +#if !defined(CONFIGURE_TASK_STACK_ALLOCATOR) \
> +&&  !defined(CONFIGURE_TASK_STACK_DEALLOCATOR)
> +  #define CONFIGURE_TASK_STACK_ALLOCATOR _Workspace_Allocate
> +  #define CONFIGURE_TASK_STACK_DEALLOCATOR _Workspace_Free
> +#elif (defined(CONFIGURE_TASK_STACK_ALLOCATOR) \
> +&&  !defined(CONFIGURE_TASK_STACK_DEALLOCATOR)) \
> +    || (!defined(CONFIGURE_TASK_STACK_ALLOCATOR) \
> +&&  defined(CONFIGURE_TASK_STACK_DEALLOCATOR))
> +  #error "CONFIGURE_TASK_STACK_ALLOCATOR and CONFIGURE_TASK_STACK_DEALLOCATOR must be both defined or both undefined"
>   #endif
>
>   /**
> @@ -869,7 +877,6 @@
>     #endif
>
>     #ifdef CONFIGURE_UNIFIED_WORK_AREAS
> -    #include<rtems/score/wkspace.h>
>       Heap_Control  *RTEMS_Malloc_Heap =&_Workspace_Area;
>     #else
>       Heap_Control   RTEMS_Malloc_Area;
> @@ -929,6 +936,19 @@
>     (ssize_t)((_size) + HEAP_BLOCK_HEADER_SIZE + CPU_HEAP_ALIGNMENT - 1)
>
>   /**
> + *  This is a helper macro used in stack space calculations in this file.  It
> + *  may be provided by the application in case a special task stack allocator
> + *  is used.  The default is allocation from the RTEMS Workspace.
> + */
> +#ifdef CONFIGURE_TASK_STACK_FROM_ALLOCATOR
> +  #define _Configure_From_stackspace(_stack_size) \
> +    CONFIGURE_TASK_STACK_FROM_ALLOCATOR(_stack_size)
> +#else
> +  #define _Configure_From_stackspace(_stack_size) \
> +    _Configure_From_workspace(_stack_size)
> +#endif
> +
> +/**
>    *  Do not use the unlimited bit as part of the multiplication
>    *  for memory usage.
>    */
> @@ -2051,23 +2071,23 @@
>
>   #define CONFIGURE_IDLE_TASKS_STACK \
>     (CONFIGURE_IDLE_TASKS_COUNT * \
> -    _Configure_From_workspace( CONFIGURE_IDLE_TASK_STACK_SIZE ) )
> +    _Configure_From_stackspace( CONFIGURE_IDLE_TASK_STACK_SIZE ) )
>
>   #define CONFIGURE_TASKS_STACK \
>     (_Configure_Max_Objects( CONFIGURE_MAXIMUM_TASKS ) * \
> -    _Configure_From_workspace( CONFIGURE_MINIMUM_TASK_STACK_SIZE ) )
> +    _Configure_From_stackspace( CONFIGURE_MINIMUM_TASK_STACK_SIZE ) )
>
>   #define CONFIGURE_POSIX_THREADS_STACK \
>     (_Configure_Max_Objects( CONFIGURE_MAXIMUM_POSIX_THREADS ) * \
> -    _Configure_From_workspace( CONFIGURE_MINIMUM_POSIX_THREAD_STACK_SIZE ) )
> +    _Configure_From_stackspace( CONFIGURE_MINIMUM_POSIX_THREAD_STACK_SIZE ) )
>
>   #define CONFIGURE_GOROUTINES_STACK \
>     (_Configure_Max_Objects( CONFIGURE_MAXIMUM_GOROUTINES ) * \
> -    _Configure_From_workspace( CONFIGURE_MINIMUM_POSIX_THREAD_STACK_SIZE ) )
> +    _Configure_From_stackspace( CONFIGURE_MINIMUM_POSIX_THREAD_STACK_SIZE ) )
>
>   #define CONFIGURE_ADA_TASKS_STACK \
>     (_Configure_Max_Objects( CONFIGURE_MAXIMUM_ADA_TASKS ) * \
> -    _Configure_From_workspace( CONFIGURE_MINIMUM_POSIX_THREAD_STACK_SIZE ) )
> +    _Configure_From_stackspace( CONFIGURE_MINIMUM_POSIX_THREAD_STACK_SIZE ) )
>
>   #else /* CONFIGURE_EXECUTIVE_RAM_SIZE */
>
> @@ -2180,6 +2200,7 @@
>       CONFIGURE_IDLE_TASK_BODY,                 /* user's IDLE task */
>       CONFIGURE_IDLE_TASK_STACK_SIZE,           /* IDLE task stack size */
>       CONFIGURE_INTERRUPT_STACK_SIZE,           /* interrupt stack size */
> +    CONFIGURE_TASK_STACK_ALLOCATOR_INIT,      /* stack allocator init */
>       CONFIGURE_TASK_STACK_ALLOCATOR,           /* stack allocator */
>       CONFIGURE_TASK_STACK_DEALLOCATOR,         /* stack deallocator */
>       CONFIGURE_ZERO_WORKSPACE_AUTOMATICALLY,   /* true to clear memory */
>
> diff -u rtems/cpukit/sapi/include/rtems/config.h:1.57 rtems/cpukit/sapi/include/rtems/config.h:1.58
> --- rtems/cpukit/sapi/include/rtems/config.h:1.57	Thu Nov 10 08:40:13 2011
> +++ rtems/cpukit/sapi/include/rtems/config.h	Wed Dec 14 07:17:19 2011
> @@ -84,6 +84,30 @@
>   } rtems_multiprocessing_table;
>   #endif
>
> +/**
> + * @brief Task stack allocator initialization hook.
> + *
> + * @param[in] stack_space_size Size of the stack space in bytes.
> + */
> +typedef void (*rtems_stack_allocate_init_hook)( size_t stack_space_size );
> +
> +/**
> + * @brief Task stack allocator hook.
> + *
> + * @param[in] stack_size Size of the task stack in bytes.
> + *
> + * @retval NULL Not enough memory.
> + * @retval other Pointer to task stack.
> + */
> +typedef void *(*rtems_stack_allocate_hook)( size_t stack_size );
> +
> +/**
> + * @brief Task stack deallocator hook.
> + *
> + * @param[in] addr Pointer to previously allocated task stack.
> + */
> +typedef void (*rtems_stack_free_hook)( void *addr );
> +
>   /*
>    *  The following records define the Configuration Table.  The
>    *  information contained in this table is required in all
> @@ -139,15 +163,20 @@
>      */
>     uint32_t                       interrupt_stack_size;
>
> -  /** The BSP may want to provide it's own stack allocation routines.
> -   *  In this case, the BSP will provide this stack allocation hook.
> +  /**
> +   * @brief Optional task stack allocator initialization hook.
>      */
> -  void *                       (*stack_allocate_hook)( size_t );
> +  rtems_stack_allocate_init_hook stack_allocate_init_hook;
>
> -  /** The BSP may want to provide it's own stack free routines.
> -   *  In this case, the BSP will provide this stack free hook.
> +  /**
> +   * @brief Optional task stack allocator hook.
>      */
> -  void                         (*stack_free_hook)( void *);
> +  rtems_stack_allocate_hook      stack_allocate_hook;
> +
> +  /**
> +   * @brief Optional task stack free hook.
> +   */
> +  rtems_stack_free_hook          stack_free_hook;
>
>     /** If this element is TRUE, then RTEMS will zero the Executive Workspace.
>      *  When this element is FALSE, it is assumed that the BSP or invoking
> @@ -268,6 +297,9 @@
>   #define rtems_configuration_get_interrupt_stack_size() \
>           (Configuration.interrupt_stack_size)
>
> +#define rtems_configuration_get_stack_allocate_init_hook() \
> +        (Configuration.stack_allocate_init_hook)
> +
>   #define rtems_configuration_get_stack_allocate_hook() \
>           (Configuration.stack_allocate_hook)
>
>
> diff -u rtems/cpukit/score/src/thread.c:1.68 rtems/cpukit/score/src/thread.c:1.69
> --- rtems/cpukit/score/src/thread.c:1.68	Mon Apr  4 11:40:00 2011
> +++ rtems/cpukit/score/src/thread.c	Wed Dec 14 07:17:19 2011
> @@ -49,30 +49,29 @@
>
>   void _Thread_Handler_initialization(void)
>   {
> -  uint32_t     ticks_per_timeslice;
> -  uint32_t     maximum_extensions;
> +  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();
>     uint32_t     maximum_internal_threads;
>     #if defined(RTEMS_MULTIPROCESSING)
> -    uint32_t   maximum_proxies;
> +    uint32_t maximum_proxies =
> +      _Configuration_MP_table->maximum_proxies;
>     #endif
>
> -  ticks_per_timeslice = Configuration.ticks_per_timeslice;
> -  maximum_extensions  = Configuration.maximum_extensions;
> -  #if defined(RTEMS_MULTIPROCESSING)
> -    maximum_proxies   =  _Configuration_MP_table->maximum_proxies;
> -  #endif
> -  /*
> -   * BOTH stacks hooks must be set or both must be NULL.
> -   * Do not allow mixture.
> -   */
> -    if ( !( (!Configuration.stack_allocate_hook)
> -            == (!Configuration.stack_free_hook) ) )
> +  if ( rtems_configuration_get_stack_allocate_hook() == NULL ||
> +       rtems_configuration_get_stack_free_hook() == NULL)
>       _Internal_error_Occurred(
>         INTERNAL_ERROR_CORE,
>         true,
>         INTERNAL_ERROR_BAD_STACK_HOOK
>       );
>
> +  if ( stack_allocate_init_hook != NULL )
> +    (*stack_allocate_init_hook)( rtems_configuration_get_stack_space_size() );
> +
>     _Thread_Dispatch_necessary = false;
>     _Thread_Executing         = NULL;
>     _Thread_Heir              = NULL;
>
> diff -u rtems/cpukit/score/src/threadstackallocate.c:1.15 rtems/cpukit/score/src/threadstackallocate.c:1.16
> --- rtems/cpukit/score/src/threadstackallocate.c:1.15	Sun Jul 24 18:55:14 2011
> +++ rtems/cpukit/score/src/threadstackallocate.c	Wed Dec 14 07:17:19 2011
> @@ -46,33 +46,24 @@
>   {
>     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 );
>
>     /*
> -   * Call ONLY the CPU table stack allocate hook, _or_ the
> -   * the RTEMS workspace allocate.  This is so the stack free
> -   * routine can call the correct deallocation routine.
> +   *  Pad the requested size so we allocate enough memory
> +   *  so the context initialization can align it properly.  The address
> +   *  returned the workspace allocate must be directly stored in the
> +   *  stack control block because it is later used in the free sequence.
> +   *
> +   *  Thus it is the responsibility of the CPU dependent code to
> +   *  get and keep the stack adjust factor, the stack alignment, and
> +   *  the context initialization sequence in sync.
>      */
> +  the_stack_size = _Stack_Adjust_size( the_stack_size );
>
> -  if ( Configuration.stack_allocate_hook ) {
> -    stack_addr = (*Configuration.stack_allocate_hook)( the_stack_size );
> -  } else {
> -
> -    /*
> -     *  First pad the requested size so we allocate enough memory
> -     *  so the context initialization can align it properly.  The address
> -     *  returned the workspace allocate must be directly stored in the
> -     *  stack control block because it is later used in the free sequence.
> -     *
> -     *  Thus it is the responsibility of the CPU dependent code to
> -     *  get and keep the stack adjust factor, the stack alignment, and
> -     *  the context initialization sequence in sync.
> -     */
> -
> -    the_stack_size = _Stack_Adjust_size( the_stack_size );
> -    stack_addr = _Workspace_Allocate( the_stack_size );
> -  }
> +  stack_addr = (*stack_allocate_hook)( the_stack_size );
>
>     if ( !stack_addr )
>       the_stack_size = 0;
>
> diff -u rtems/cpukit/score/src/threadstackfree.c:1.8 rtems/cpukit/score/src/threadstackfree.c:1.9
> --- rtems/cpukit/score/src/threadstackfree.c:1.8	Fri Jan 28 14:24:54 2011
> +++ rtems/cpukit/score/src/threadstackfree.c	Wed Dec 14 07:17:19 2011
> @@ -41,6 +41,9 @@
>     Thread_Control *the_thread
>   )
>   {
> +  rtems_stack_free_hook stack_free_hook =
> +    rtems_configuration_get_stack_free_hook();
> +
>     #if defined(RTEMS_SCORE_THREAD_ENABLE_USER_PROVIDED_STACK_VIA_API)
>       /*
>        *  If the API provided the stack space, then don't free it.
> @@ -55,8 +58,5 @@
>      * routine properly matches the allocation of the stack.
>      */
>
> -  if ( Configuration.stack_free_hook )
> -    (*Configuration.stack_free_hook)( the_thread->Start.Initial_stack.area );
> -  else
> -    _Workspace_Free( the_thread->Start.Initial_stack.area );
> +  (*stack_free_hook)( the_thread->Start.Initial_stack.area );
>   }
>
> *sh*
> 2011-12-14	Sebastian Huber<sebastian.huber at embedded-brains.de>
>
> 	PR 1924/cpukit
> 	* spstkalloc02/.cvsignore, spstkalloc02/Makefile.am,
> 	spstkalloc02/init.c, spstkalloc02/spstkalloc02.doc,
> 	spstkalloc02/spstkalloc02.scn: New files.
> 	* Makefile.am, configure.ac: Reflect changes above.
> M 
> <http://www.rtems.com/cgi-bin/viewcvs.cgi//rtems/testsuites/sptests/ChangeLog.diff?r1=text&tr1=1.503&r2=text&tr2=1.504&diff_format=h> 
> 	1.504 	testsuites/sptests/ChangeLog
> M 
> <http://www.rtems.com/cgi-bin/viewcvs.cgi//rtems/testsuites/sptests/Makefile.am.diff?r1=text&tr1=1.117&r2=text&tr2=1.118&diff_format=h> 
> 	1.118 	testsuites/sptests/Makefile.am
> M 
> <http://www.rtems.com/cgi-bin/viewcvs.cgi//rtems/testsuites/sptests/configure.ac.diff?r1=text&tr1=1.124&r2=text&tr2=1.125&diff_format=h> 
> 	1.125 	testsuites/sptests/configure.ac
> A 
> <http://www.rtems.com/cgi-bin/viewcvs.cgi//rtems/testsuites/sptests/spstkalloc02/.cvsignore?rev=1.1&content-type=text/vnd.viewcvs-markup> 
> 	1.1 	testsuites/sptests/spstkalloc02/.cvsignore
> A 
> <http://www.rtems.com/cgi-bin/viewcvs.cgi//rtems/testsuites/sptests/spstkalloc02/Makefile.am?rev=1.1&content-type=text/vnd.viewcvs-markup> 
> 	1.1 	testsuites/sptests/spstkalloc02/Makefile.am
> A 
> <http://www.rtems.com/cgi-bin/viewcvs.cgi//rtems/testsuites/sptests/spstkalloc02/init.c?rev=1.1&content-type=text/vnd.viewcvs-markup> 
> 	1.1 	testsuites/sptests/spstkalloc02/init.c
> A 
> <http://www.rtems.com/cgi-bin/viewcvs.cgi//rtems/testsuites/sptests/spstkalloc02/spstkalloc02.doc?rev=1.1&content-type=text/vnd.viewcvs-markup> 
> 	1.1 	testsuites/sptests/spstkalloc02/spstkalloc02.doc
> A 
> <http://www.rtems.com/cgi-bin/viewcvs.cgi//rtems/testsuites/sptests/spstkalloc02/spstkalloc02.scn?rev=1.1&content-type=text/vnd.viewcvs-markup> 
> 	1.1 	testsuites/sptests/spstkalloc02/spstkalloc02.scn
>
> diff -u rtems/testsuites/sptests/ChangeLog:1.503 rtems/testsuites/sptests/ChangeLog:1.504
> --- rtems/testsuites/sptests/ChangeLog:1.503	Tue Dec 13 04:02:30 2011
> +++ rtems/testsuites/sptests/ChangeLog	Wed Dec 14 07:18:01 2011
> @@ -1,3 +1,11 @@
> +2011-12-14	Sebastian Huber<sebastian.huber at embedded-brains.de>
> +
> +	PR 1924/cpukit
> +	* spstkalloc02/.cvsignore, spstkalloc02/Makefile.am,
> +	spstkalloc02/init.c, spstkalloc02/spstkalloc02.doc,
> +	spstkalloc02/spstkalloc02.scn: New files.
> +	* Makefile.am, configure.ac: Reflect changes above.
> +
>   2011-12-13	Ralf Corsépius<ralf.corsepius at rtems.org>
>
>   	* sp31/task1.c: Make Do_nothing static.
>
> diff -u rtems/testsuites/sptests/Makefile.am:1.117 rtems/testsuites/sptests/Makefile.am:1.118
> --- rtems/testsuites/sptests/Makefile.am:1.117	Wed Sep 28 11:01:53 2011
> +++ rtems/testsuites/sptests/Makefile.am	Wed Dec 14 07:18:01 2011
> @@ -17,7 +17,7 @@
>       sp70 sp71 sp72 sp73 sp74 sp75 sp76 sp2038 \
>       spassoc01 spchain spclockget spcoverage spobjgetnext \
>       spnotepad01 spprintk spprivenv01 sprbtree01 spsize spstkalloc \
> -		spthreadq01 spwatchdog spwkspace \
> +    spstkalloc02 spthreadq01 spwatchdog spwkspace \
>       sperror01 sperror02 sperror03 \
>       spfatal01 spfatal02 spfatal03 spfatal04 spfatal05 spfatal06 spfatal07 \
>       spfatal08 spfatal09 spfatal10 spfatal11 spfatal12 spfatal13 spfatal14 \
>
> diff -u rtems/testsuites/sptests/configure.ac:1.124 rtems/testsuites/sptests/configure.ac:1.125
> --- rtems/testsuites/sptests/configure.ac:1.124	Thu Sep 29 20:55:27 2011
> +++ rtems/testsuites/sptests/configure.ac	Wed Dec 14 07:18:01 2011
> @@ -180,6 +180,7 @@
>   spsimplesched03/Makefile
>   spsize/Makefile
>   spstkalloc/Makefile
> +spstkalloc02/Makefile
>   spthreadq01/Makefile
>   spwatchdog/Makefile
>   spwkspace/Makefile
>
> diff -u /dev/null rtems/testsuites/sptests/spstkalloc02/.cvsignore:1.1
> --- /dev/null	Wed Dec 14 07:31:33 2011
> +++ rtems/testsuites/sptests/spstkalloc02/.cvsignore	Wed Dec 14 07:18:01 2011
> @@ -0,0 +1,2 @@
> +Makefile
> +Makefile.in
>
> diff -u /dev/null rtems/testsuites/sptests/spstkalloc02/Makefile.am:1.1
> --- /dev/null	Wed Dec 14 07:31:33 2011
> +++ rtems/testsuites/sptests/spstkalloc02/Makefile.am	Wed Dec 14 07:18:01 2011
> @@ -0,0 +1,26 @@
> +##
> +## $Id$
> +##
> +
> +
> +rtems_tests_PROGRAMS = spstkalloc02
> +spstkalloc02_SOURCES = init.c
> +
> +dist_rtems_tests_DATA = spstkalloc02.scn
> +dist_rtems_tests_DATA += spstkalloc02.doc
> +
> +include $(RTEMS_ROOT)/make/custom/@RTEMS_BSP at .cfg
> +include $(top_srcdir)/../automake/compile.am
> +include $(top_srcdir)/../automake/leaf.am
> +
> +
> +AM_CPPFLAGS += -I$(top_srcdir)/../support/include
> +
> +LINK_OBJS = $(spstkalloc02_OBJECTS)
> +LINK_LIBS = $(spstkalloc02_LDLIBS)
> +
> +spstkalloc02$(EXEEXT): $(spstkalloc02_OBJECTS) $(spstkalloc02_DEPENDENCIES)
> +	@rm -f spstkalloc02$(EXEEXT)
> +	$(make-exe)
> +
> +include $(top_srcdir)/../automake/local.am
>
> diff -u /dev/null rtems/testsuites/sptests/spstkalloc02/init.c:1.1
> --- /dev/null	Wed Dec 14 07:31:33 2011
> +++ rtems/testsuites/sptests/spstkalloc02/init.c	Wed Dec 14 07:18:01 2011
> @@ -0,0 +1,162 @@
> +/**
> + * @file
> + *
> + * @ingroup sptests
> + *
> + * @brief Test that the task stack allocator works.
> + */
> +
> +/*
> + * Copyright (c) 2011 embedded brains GmbH.  All rights reserved.
> + *
> + *  embedded brains GmbH
> + *  Obere Lagerstr. 30
> + *  82178 Puchheim
> + *  Germany
> + *<rtems at embedded-brains.de>
> + *
> + * The license and distribution terms for this file may be
> + * found in the file LICENSE in this distribution or at
> + * http://www.rtems.com/license/LICENSE.
> + *
> + * $Id$
> + */
> +
> +#ifdef HAVE_CONFIG_H
> +  #include "config.h"
> +#endif
> +
> +#include<tmacros.h>
> +
> +#include<stdio.h>
> +#include<inttypes.h>
> +
> +#include<rtems/score/heap.h>
> +
> +#define TASK_COUNT 5
> +
> +#define PAGE_SIZE 1024
> +
> +static Heap_Control task_stack_heap;
> +
> +static void task_stack_init(size_t stack_space_size);
> +
> +static void *task_stack_allocate(size_t stack_size);
> +
> +static void task_stack_free(void *addr);
> +
> +static void print_info(void)
> +{
> +  Heap_Information_block info;
> +
> +  _Heap_Get_information(&task_stack_heap,&info);
> +
> +  printf(
> +    "used blocks = %" PRIu32 ", "
> +    "largest used block = %" PRIu32 ", "
> +    "used space = %" PRIu32 "\n"
> +    "free blocks = %" PRIu32 ", "
> +    "largest free block = %" PRIu32 ", "
> +    "free space = %" PRIu32 "\n",
> +    info.Used.number,
> +    info.Used.largest,
> +    info.Used.total,
> +    info.Free.number,
> +    info.Free.largest,
> +    info.Free.total
> +  );
> +}
> +
> +static rtems_task Init(rtems_task_argument argument)
> +{
> +  rtems_status_code sc = RTEMS_SUCCESSFUL;
> +  rtems_name name = rtems_build_name('S', 'T', 'K', 'A');
> +  rtems_id id = RTEMS_ID_NONE;
> +  int i = 0;
> +
> +  puts("\n\n*** POSIX TEST STKALLOC 02 ***");
> +
> +  print_info();
> +
> +  for (i = 2; i<  TASK_COUNT; ++i) {
> +    sc = rtems_task_create(
> +      name,
> +      RTEMS_MINIMUM_PRIORITY,
> +      RTEMS_MINIMUM_STACK_SIZE,
> +      RTEMS_DEFAULT_MODES,
> +      RTEMS_DEFAULT_ATTRIBUTES,
> +&id
> +    );
> +    directive_failed(sc, "rtems_task_create");
> +  }
> +
> +  sc = rtems_task_create(
> +    name,
> +    RTEMS_MINIMUM_PRIORITY,
> +    2 * RTEMS_MINIMUM_STACK_SIZE,
> +    RTEMS_DEFAULT_MODES,
> +    RTEMS_DEFAULT_ATTRIBUTES,
> +&id
> +  );
> +  fatal_directive_status(sc, RTEMS_UNSATISFIED, "rtems_task_create");
> +
> +  sc = rtems_task_create(
> +    name,
> +    RTEMS_MINIMUM_PRIORITY,
> +    RTEMS_MINIMUM_STACK_SIZE,
> +    RTEMS_DEFAULT_MODES,
> +    RTEMS_DEFAULT_ATTRIBUTES,
> +&id
> +  );
> +  directive_failed(sc, "rtems_task_create");
> +
> +  print_info();
> +
> +  puts("*** END OF POSIX TEST STKALLOC 02 ***");
> +
> +  rtems_test_exit(0);
> +}
> +
> +#define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
> +#define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
> +
> +#define CONFIGURE_MAXIMUM_TASKS TASK_COUNT
> +
> +#define CONFIGURE_TASK_STACK_ALLOCATOR_INIT task_stack_init
> +#define CONFIGURE_TASK_STACK_ALLOCATOR task_stack_allocate
> +#define CONFIGURE_TASK_STACK_DEALLOCATOR task_stack_free
> +#define CONFIGURE_TASK_STACK_ALLOCATOR_AVOIDS_WORK_SPACE
> +#define CONFIGURE_TASK_STACK_FROM_ALLOCATOR(stack_size) \
> +  ((stack_size) + HEAP_BLOCK_HEADER_SIZE + PAGE_SIZE - 1)
> +
> +#define CONFIGURE_RTEMS_INIT_TASKS_TABLE
> +
> +#define CONFIGURE_INIT
> +
> +#include<rtems/confdefs.h>
> +
> +static char task_stack_space
> +  [CONFIGURE_TASK_STACK_FROM_ALLOCATOR(CONFIGURE_STACK_SPACE_SIZE)];
> +
> +static void task_stack_init(size_t stack_space_size)
> +{
> +  bool ok = _Heap_Initialize(
> +&task_stack_heap,
> +    task_stack_space,
> +    sizeof(task_stack_space),
> +    PAGE_SIZE
> +  );
> +
> +  rtems_test_assert(stack_space_size == CONFIGURE_STACK_SPACE_SIZE);
> +  rtems_test_assert(ok);
> +}
> +
> +static void *task_stack_allocate(size_t stack_size)
> +{
> +  return _Heap_Allocate(&task_stack_heap, stack_size);
> +}
> +
> +static void task_stack_free(void *addr)
> +{
> +  _Heap_Free(&task_stack_heap, addr);
> +}
>
> diff -u /dev/null rtems/testsuites/sptests/spstkalloc02/spstkalloc02.doc:1.1
> --- /dev/null	Wed Dec 14 07:31:33 2011
> +++ rtems/testsuites/sptests/spstkalloc02/spstkalloc02.doc	Wed Dec 14 07:18:01 2011
> @@ -0,0 +1,19 @@
> +#
> +#  $Id$
> +#
> +#  Copyright (c) 2011 embedded brains GmbH.
> +#
> +#  The license and distribution terms for this file may be
> +#  found in the file LICENSE in this distribution or at
> +#  http://www.rtems.com/license/LICENSE.
> +#
> +
> +This file describes the directives and concepts tested by this test set.
> +
> +test set name:  spstkalloc01
> +
> +directives:
> +
> +concepts:
> +
> ++ Ensure that the task stack allocator works.
>
> diff -u /dev/null rtems/testsuites/sptests/spstkalloc02/spstkalloc02.scn:1.1
> --- /dev/null	Wed Dec 14 07:31:33 2011
> +++ rtems/testsuites/sptests/spstkalloc02/spstkalloc02.scn	Wed Dec 14 07:18:01 2011
> @@ -0,0 +1,6 @@
> +*** POSIX TEST STKALLOC 02 ***
> +used blocks = 2, largest used block = 5120, used space = 10240
> +free blocks = 1, largest free block = 20480, free space = 20480
> +used blocks = 6, largest used block = 5120, used space = 30720
> +free blocks = 0, largest free block = 0, free space = 0
> +*** END OF POSIX TEST STKALLOC 02 ***
>
> *sh*
> Typo.
> M 
> <http://www.rtems.com/cgi-bin/viewcvs.cgi//rtems/testsuites/sptests/spstkalloc02/init.c.diff?r1=text&tr1=1.1&r2=text&tr2=1.2&diff_format=h> 
> 	1.2 	testsuites/sptests/spstkalloc02/init.c
> M 
> <http://www.rtems.com/cgi-bin/viewcvs.cgi//rtems/testsuites/sptests/spstkalloc02/spstkalloc02.scn.diff?r1=text&tr1=1.1&r2=text&tr2=1.2&diff_format=h> 
> 	1.2 	testsuites/sptests/spstkalloc02/spstkalloc02.scn
>
> diff -u rtems/testsuites/sptests/spstkalloc02/init.c:1.1 rtems/testsuites/sptests/spstkalloc02/init.c:1.2
> --- rtems/testsuites/sptests/spstkalloc02/init.c:1.1	Wed Dec 14 07:18:01 2011
> +++ rtems/testsuites/sptests/spstkalloc02/init.c	Wed Dec 14 07:19:52 2011
> @@ -74,7 +74,7 @@
>     rtems_id id = RTEMS_ID_NONE;
>     int i = 0;
>
> -  puts("\n\n*** POSIX TEST STKALLOC 02 ***");
> +  puts("\n\n*** TEST STKALLOC 02 ***");
>
>     print_info();
>
> @@ -112,7 +112,7 @@
>
>     print_info();
>
> -  puts("*** END OF POSIX TEST STKALLOC 02 ***");
> +  puts("*** END OF TEST STKALLOC 02 ***");
>
>     rtems_test_exit(0);
>   }
>
> diff -u rtems/testsuites/sptests/spstkalloc02/spstkalloc02.scn:1.1 rtems/testsuites/sptests/spstkalloc02/spstkalloc02.scn:1.2
> --- rtems/testsuites/sptests/spstkalloc02/spstkalloc02.scn:1.1	Wed Dec 14 07:18:01 2011
> +++ rtems/testsuites/sptests/spstkalloc02/spstkalloc02.scn	Wed Dec 14 07:19:52 2011
> @@ -1,6 +1,6 @@
> -*** POSIX TEST STKALLOC 02 ***
> +*** TEST STKALLOC 02 ***
>   used blocks = 2, largest used block = 5120, used space = 10240
>   free blocks = 1, largest free block = 20480, free space = 20480
>   used blocks = 6, largest used block = 5120, used space = 30720
>   free blocks = 0, largest free block = 0, free space = 0
> -*** END OF POSIX TEST STKALLOC 02 ***
> +*** END OF TEST STKALLOC 02 ***
>
> --
> Generated by Deluxe Loginfo 
> <http://www.codewiz.org/projects/index.html#loginfo> 2.122 by Bernardo 
> Innocenti <bernie at develer.com>
>


-- 
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