diff options
author | Jennifer Averett <Jennifer.Averett@OARcorp.com> | 2005-05-13 17:13:09 +0000 |
---|---|---|
committer | Jennifer Averett <Jennifer.Averett@OARcorp.com> | 2005-05-13 17:13:09 +0000 |
commit | c3f26834d613ddb96fcb81fdad4b11dd957f9304 (patch) | |
tree | 90bdd6f6b46686d6dfa1237f98e0ed7e7e05c09c | |
parent | 2005-05-13 Jennifer Averett <jennifer.averett@oarcorp.com> (diff) | |
download | rtems-c3f26834d613ddb96fcb81fdad4b11dd957f9304.tar.bz2 |
2005-05-13 Jennifer Averett <jennifer.averett@oarcorp.com>
PR 786/rtems
Backport mallocfreespace optimization.
* Makefile.am, include/rtems/score/heap.h, src/heapgetinfo.c:
* src/heapgetfreeinfo.c: New file.
-rw-r--r-- | cpukit/score/ChangeLog | 7 | ||||
-rw-r--r-- | cpukit/score/Makefile.am | 2 | ||||
-rw-r--r-- | cpukit/score/include/rtems/score/heap.h | 16 | ||||
-rw-r--r-- | cpukit/score/src/heapgetfreeinfo.c | 28 | ||||
-rw-r--r-- | cpukit/score/src/heapgetinfo.c | 3 |
5 files changed, 35 insertions, 21 deletions
diff --git a/cpukit/score/ChangeLog b/cpukit/score/ChangeLog index 1583c095d0..f1fe0f362c 100644 --- a/cpukit/score/ChangeLog +++ b/cpukit/score/ChangeLog @@ -1,3 +1,10 @@ +2005-05-13 Jennifer Averett <jennifer.averett@oarcorp.com> + + PR 786/rtems + Backport mallocfreespace optimization. + * Makefile.am, include/rtems/score/heap.h, src/heapgetinfo.c: + * src/heapgetfreeinfo.c: New file. + 2005-03-17 Joel Sherrill <joel@OARcorp.com> * include/rtems/score/object.h, src/objectinitializeinformation.c: Fix diff --git a/cpukit/score/Makefile.am b/cpukit/score/Makefile.am index 3a8e844f00..bbcd1a6b2d 100644 --- a/cpukit/score/Makefile.am +++ b/cpukit/score/Makefile.am @@ -125,7 +125,7 @@ CORE_SEMAPHORE_C_FILES = src/coresem.c src/coresemflush.c src/coresemseize.c \ src/coresemsurrender.c HEAP_C_FILES = src/heap.c src/heapallocate.c src/heapextend.c src/heapfree.c \ - src/heapsizeofuserarea.c src/heapwalk.c src/heapgetinfo.c + src/heapsizeofuserarea.c src/heapwalk.c src/heapgetinfo.c src/heapgetfreeinfo.c OBJECT_C_FILES = src/object.c src/objectallocate.c src/objectallocatebyindex.c \ src/objectclearname.c src/objectcomparenameraw.c src/objectcomparenamestring.c \ diff --git a/cpukit/score/include/rtems/score/heap.h b/cpukit/score/include/rtems/score/heap.h index a0d477ed25..4fa52b581b 100644 --- a/cpukit/score/include/rtems/score/heap.h +++ b/cpukit/score/include/rtems/score/heap.h @@ -46,6 +46,18 @@ typedef enum { } Heap_Get_information_status; /* + * Information block returned by the Heap routines used to + * obtain statistics. This information is returned about + * either free or used blocks. + */ + +typedef struct { + unsigned32 number; /* Number of blocks */ + unsigned32 largest; /* Largest blocks */ + unsigned32 total; /* Total size of the blocks */ +} Heap_Information; + +/* * Information block returned by _Heap_Get_information */ @@ -256,6 +268,10 @@ Heap_Get_information_status _Heap_Get_information( Heap_Information_block *the_info ); +void _Heap_Get_free_information( + Heap_Control *the_heap, + Heap_Information *info +); #ifndef __RTEMS_APPLICATION__ #include <rtems/score/heap.inl> diff --git a/cpukit/score/src/heapgetfreeinfo.c b/cpukit/score/src/heapgetfreeinfo.c index b53931414b..5c1d0a5097 100644 --- a/cpukit/score/src/heapgetfreeinfo.c +++ b/cpukit/score/src/heapgetfreeinfo.c @@ -11,9 +11,6 @@ * $Id$ */ -#if HAVE_CONFIG_H -#include "config.h" -#endif #include <rtems/system.h> #include <rtems/score/sysstate.h> @@ -40,24 +37,19 @@ void _Heap_Get_free_information( ) { Heap_Block *the_block; - Heap_Block *const tail = _Heap_Tail(the_heap); - info->number = 0; + info->number = 0; info->largest = 0; - info->total = 0; - - for(the_block = _Heap_First(the_heap); - the_block != tail; - the_block = the_block->next) - { - uint32_t const the_size = _Heap_Block_size(the_block); - - /* As we always coalesce free blocks, prev block must have been used. */ - _HAssert(_Heap_Is_prev_used(the_block)); + info->total = 0; + for ( the_block = the_heap->first ; ; the_block = the_block->next ) { + if ( the_block == _Heap_Tail( the_heap ) ) + return; + info->number++; - info->total += the_size; - if ( info->largest < the_size ) - info->largest = the_size; + info->total += the_block->front_flag; + + if ( the_block->front_flag > info->largest ) + info->largest = the_block->front_flag; } } diff --git a/cpukit/score/src/heapgetinfo.c b/cpukit/score/src/heapgetinfo.c index c2a8c06003..313ccfddc9 100644 --- a/cpukit/score/src/heapgetinfo.c +++ b/cpukit/score/src/heapgetinfo.c @@ -91,10 +91,9 @@ Heap_Get_information_status _Heap_Get_information( } } + the_block = next_block; if ( the_block->front_flag == HEAP_DUMMY_FLAG ) notdone = 0; - else - the_block = next_block; } /* while(notdone) */ return HEAP_GET_INFORMATION_SUCCESSFUL; |