Changeset d0d357ed in rtems


Ignore:
Timestamp:
Jun 25, 2013, 10:09:50 AM (6 years ago)
Author:
Sebastian Huber <sebastian.huber@…>
Branches:
4.11, master
Children:
3948a0b
Parents:
c497657
git-author:
Sebastian Huber <sebastian.huber@…> (06/25/13 10:09:50)
git-committer:
Sebastian Huber <sebastian.huber@…> (06/25/13 15:03:22)
Message:

heap: Add _Heap_Greedy_allocate_all_except_largest

Add rtems_workspace_greedy_allocate_all_except_largest() and
rtems_heap_greedy_allocate_all_except_largest().

Location:
cpukit
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • cpukit/libcsupport/include/rtems/malloc.h

    rc497657 rd0d357ed  
    225225 * @brief Greedy allocate that empties the heap.
    226226 *
    227  * Afterward the heap has at most @a block_count allocatable blocks of sizes
     227 * Afterwards the heap has at most @a block_count allocatable blocks of sizes
    228228 * specified by @a block_sizes.  The @a block_sizes must point to an array with
    229229 * @a block_count members.  All other blocks are used.
     
    237237
    238238/**
     239 * @brief Greedy allocate all blocks except the largest free block.
     240 *
     241 * Afterwards the heap has at most one allocatable block.  This block is the
     242 * largest free block if it exists.  The allocatable size of this block is
     243 * stored in @a allocatable_size.  All other blocks are used.
     244 *
     245 * @see rtems_heap_greedy_free().
     246 */
     247void *rtems_heap_greedy_allocate_all_except_largest(
     248  uintptr_t *allocatable_size
     249);
     250
     251/**
    239252 * @brief Frees space of a greedy allocation.
    240253 *
    241254 * The @a opaque argument must be the return value of
    242  * rtems_heap_greedy_allocate().
     255 * rtems_heap_greedy_allocate() or
     256 * rtems_heap_greedy_allocate_all_except_largest().
    243257 */
    244258void rtems_heap_greedy_free( void *opaque );
  • cpukit/libcsupport/src/rtems_heap_greedy.c

    rc497657 rd0d357ed  
    4040}
    4141
     42void *rtems_heap_greedy_allocate_all_except_largest(
     43  uintptr_t *allocatable_size
     44)
     45{
     46  void *opaque;
     47
     48  _RTEMS_Lock_allocator();
     49  opaque = _Heap_Greedy_allocate_all_except_largest(
     50    RTEMS_Malloc_Heap,
     51    allocatable_size
     52  );
     53  _RTEMS_Unlock_allocator();
     54
     55  return opaque;
     56}
     57
    4258void rtems_heap_greedy_free( void *opaque )
    4359{
  • cpukit/rtems/include/rtems/rtems/support.h

    rc497657 rd0d357ed  
    100100 * @brief Greedy allocate that empties the workspace.
    101101 *
    102  * Afterward the heap has at most @a block_count allocateable blocks of sizes
     102 * Afterwards the heap has at most @a block_count allocatable blocks of sizes
    103103 * specified by @a block_sizes.  The @a block_sizes must point to an array with
    104104 * @a block_count members.  All other blocks are used.
     
    112112
    113113/**
     114 * @brief Greedy allocate all blocks except the largest free block.
     115 *
     116 * Afterwards the heap has at most one allocatable block.  This block is the
     117 * largest free block if it exists.  The allocatable size of this block is
     118 * stored in @a allocatable_size.  All other blocks are used.
     119 *
     120 * @see rtems_workspace_greedy_free().
     121 */
     122void *rtems_workspace_greedy_allocate_all_except_largest(
     123  uintptr_t *allocatable_size
     124);
     125
     126/**
    114127 * @brief Frees space of a greedy allocation.
    115128 *
    116129 * The @a opaque argument must be the return value of
    117  * rtems_workspace_greedy_allocate().
     130 * rtems_workspace_greedy_allocate() or
     131 * rtems_workspace_greedy_allocate_all_except_largest().
    118132 */
    119133void rtems_workspace_greedy_free( void *opaque );
  • cpukit/rtems/src/workspacegreedy.c

    rc497657 rd0d357ed  
    4141}
    4242
     43void *rtems_workspace_greedy_allocate_all_except_largest(
     44  uintptr_t *allocatable_size
     45)
     46{
     47  void *opaque;
     48
     49  _Thread_Disable_dispatch();
     50  opaque = _Heap_Greedy_allocate_all_except_largest(
     51    &_Workspace_Area,
     52    allocatable_size
     53  );
     54  _Thread_Enable_dispatch();
     55
     56  return opaque;
     57}
     58
    4359void rtems_workspace_greedy_free( void *opaque )
    4460{
  • cpukit/score/include/rtems/score/heap.h

    rc497657 rd0d357ed  
    596596 * @brief Greedy allocate that empties the heap.
    597597 *
    598  * Afterward the heap has at most @a block_count allocateable blocks of sizes
     598 * Afterwards the heap has at most @a block_count allocatable blocks of sizes
    599599 * specified by @a block_sizes.  The @a block_sizes must point to an array with
    600600 * @a block_count members.  All other blocks are used.
     
    606606  const uintptr_t *block_sizes,
    607607  size_t block_count
     608);
     609
     610/**
     611 * @brief Greedy allocate all blocks except the largest free block.
     612 *
     613 * Afterwards the heap has at most one allocatable block.  This block is the
     614 * largest free block if it exists.  The allocatable size of this block is
     615 * stored in @a allocatable_size.  All other blocks are used.
     616 *
     617 * @see _Heap_Greedy_free().
     618 */
     619Heap_Block *_Heap_Greedy_allocate_all_except_largest(
     620  Heap_Control *heap,
     621  uintptr_t *allocatable_size
    608622);
    609623
  • cpukit/score/src/heapgreedy.c

    rc497657 rd0d357ed  
    7676}
    7777
     78Heap_Block *_Heap_Greedy_allocate_all_except_largest(
     79  Heap_Control *heap,
     80  uintptr_t *allocatable_size
     81)
     82{
     83  Heap_Information info;
     84
     85  _Heap_Get_free_information( heap, &info );
     86  *allocatable_size = info.largest - HEAP_BLOCK_HEADER_SIZE + HEAP_ALLOC_BONUS;
     87
     88  return _Heap_Greedy_allocate( heap, allocatable_size, 1 );
     89}
     90
    7891void _Heap_Greedy_free(
    7992  Heap_Control *heap,
Note: See TracChangeset for help on using the changeset viewer.