Changeset e4278f2 in rtems


Ignore:
Timestamp:
Oct 12, 2012, 3:02:30 PM (9 years ago)
Author:
Sebastian Huber <sebastian.huber@…>
Branches:
4.11, 5, master
Children:
47a3cd8
Parents:
6ccfe72
git-author:
Sebastian Huber <sebastian.huber@…> (10/12/12 15:02:30)
git-committer:
Sebastian Huber <sebastian.huber@…> (10/25/12 12:54:06)
Message:

score: Append to free list in _Heap_Extend()

Files:
3 edited

Legend:

Unmodified
Added
Removed
  • cpukit/score/inline/rtems/score/heap.inl

    r6ccfe72 re4278f2  
    8686  block_before->next = new_block;
    8787  next->prev = new_block;
     88}
     89
     90RTEMS_INLINE_ROUTINE void _Heap_Free_list_insert_before(
     91  Heap_Block *block_next,
     92  Heap_Block *new_block
     93)
     94{
     95  Heap_Block *prev = block_next->prev;
     96
     97  new_block->next = block_next;
     98  new_block->prev = prev;
     99  prev->next = new_block;
     100  block_next->prev = new_block;
    88101}
    89102
  • cpukit/score/src/heapextend.c

    r6ccfe72 re4278f2  
    2929{
    3030  Heap_Statistics *const stats = &heap->stats;
     31  Heap_Block *first_free;
    3132
    3233  /* Statistics */
     
    3435  --stats->frees;
    3536
    36   _Heap_Free( heap, (void *) _Heap_Alloc_area_of_block( block ));
     37  /*
     38   * The _Heap_Free() will place the block to the head of free list.  We want
     39   * the new block at the end of the free list.  So that initial and earlier
     40   * areas are consumed first.
     41   */
     42  _Heap_Free( heap, (void *) _Heap_Alloc_area_of_block( block ) );
     43  first_free = _Heap_Free_list_first( heap );
     44  _Heap_Free_list_remove( first_free );
     45  _Heap_Free_list_insert_before( _Heap_Free_list_tail( heap ), first_free );
    3746}
    3847
  • testsuites/libtests/malloctest/init.c

    r6ccfe72 re4278f2  
    985985}
    986986
     987static void test_heap_extend_allocation_order(void)
     988{
     989  Heap_Control *heap = &TestHeap;
     990  uintptr_t size = 256;
     991  uintptr_t gap = 256;
     992  uint8_t *init_area_begin = TestHeapMemory;
     993  uint8_t *extend_area_begin = init_area_begin + size + gap;
     994  bool ret;
     995  uint8_t *p;
     996
     997  _Heap_Initialize( heap, init_area_begin, size, 0 );
     998
     999  ret = _Protected_heap_Extend( heap, extend_area_begin, size );
     1000  test_heap_assert( ret, true );
     1001
     1002  p = _Heap_Allocate( heap, 1 );
     1003  rtems_test_assert( (uintptr_t) (p - init_area_begin) < size );
     1004}
     1005
     1006static void test_heap_extend_allocation_order_with_empty_heap(void)
     1007{
     1008  Heap_Control *heap = &TestHeap;
     1009  uintptr_t size = 256;
     1010  uintptr_t gap = 256;
     1011  uint8_t *init_area_begin = TestHeapMemory;
     1012  uint8_t *extend_area_begin = init_area_begin + size + gap;
     1013  bool ret;
     1014  uint8_t *p;
     1015
     1016  _Heap_Initialize( heap, init_area_begin, size, 0 );
     1017
     1018  _Heap_Greedy_allocate( heap, NULL, 0 );
     1019
     1020  ret = _Protected_heap_Extend( heap, extend_area_begin, size );
     1021  test_heap_assert( ret, true );
     1022
     1023  p = _Heap_Allocate( heap, 1 );
     1024  rtems_test_assert( (uintptr_t) (p - extend_area_begin) < size );
     1025}
     1026
    9871027static void test_heap_no_extend(void)
    9881028{
     
    11491189  test_heap_cases_1();
    11501190  test_heap_extend();
     1191  test_heap_extend_allocation_order();
     1192  test_heap_extend_allocation_order_with_empty_heap();
    11511193  test_heap_no_extend();
    11521194  test_heap_info();
Note: See TracChangeset for help on using the changeset viewer.