123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101 |
- /**
- * \file heap.h
- * \author Ioannis Koutras (joko@microlab.ntua.gr)
- * \date September, 2011
- * \brief Basic structures needed for the dmmlib allocator.
- */
- #ifndef HEAP_H
- #define HEAP_H
- #include <stdint.h>
- #include <stdbool.h>
- #ifdef HAVE_LOCKS
- #include <pthread.h>
- #endif /* HAVE_LOCKS */
- #include "block_header.h"
- /**
- * \brief The number of the heaps.
- */
- #define NUM_HEAPS 4
- /**
- * \brief A structure to represent a maptable node.
- */
- typedef struct maptable_node_s {
- unsigned int size; /**< \brief The size of the blocks of the fixed
- list. */
- void *fixed_list_head; /**< \brief Pointer to the head node of the
- fixed list. */
- struct maptable_node_s *next; /**< \brief Pointer to the next node of
- the maptable. */
- } maptable_node_t;
- /**
- * \brief Statistics data structure.
- */
- typedef struct dmmstats_s {
- uint32_t max_mem_allocated; /**< \brief Maximum total memory
- allocated. */
- uint32_t max_mem_requested; /**< \brief Maximum total memory
- requested. */
- uint32_t mem_allocated; /**< \brief Total memory currently
- allocated. */
- uint32_t mem_requested; /**< \brief Total memory currently
- requested. */
- uint32_t mem_reserved; /**< \brief Total memory currently
- reserved. */
- uint32_t live_objects; /**< \brief Number of live objects. */
- uint32_t read_mem_accesses; /**< \brief Number of read accesses. */
- uint32_t write_mem_accesses; /**< \brief Number of write accesses. */
- uint32_t num_malloc; /**< \brief Number of malloc()'s served. */
- uint32_t num_free; /**< \brief Number of free()'s served. */
- } dmmstats_t;
- /**
- * \brief A structure to represent tunable parameters of a heap
- */
- typedef struct dmmknobs_s {
- /** \brief Maximum coalesce size; -1 If coalescing is not supported */
- int32_t max_coalesce_size;
- float frag_threshold; /**< \brief Fragmentation threshold to enable
- coalescing or not. */
- uint32_t mem_threshold; /**< \brief Memory size threshold. */
- uint32_t min_split_size; /**< \brief Minimum split size. */
- float empty_threshold; /**< FIXME Need to find explanation \brief Empty
- Threshold */
- /*
- uint32_t percentage; // FIXME to be investigated if needed
- char frag_state; //FIXME It was in the old code to refresh the frag check
- */
- } dmmknobs_t;
- /**
- * \brief A structure to store heap information.
- */
- typedef struct heap_s {
- maptable_node_t *maptable_head; /**< \brief The head of the maptable list. */
- void *free_list_head; /**< \brief The head of the free list. */
- void *used_blocks_head; /**< \brief The head of the used blocks list. */
- void *rov_ptr; /**< \brief Roving pointer. */
- uint64_t num_objects; /**< \brief Number of objects in the heap. */
- dmmstats_t dmm_stats; /**< \brief Statistics of the heap. */
- dmmknobs_t dmm_knobs; /**< \brief Tunable parameters of the heap. */
- #ifdef HAVE_LOCKS
- pthread_mutex_t mutex;/**< \brief Mutex when POSIX Threads are used. */
- #endif /* HAVE_LOCKS */
- } heap_t;
- /**
- * \brief The allocator structure of dmmlib.
- */
- typedef struct allocator_s {
- heap_t heaps[NUM_HEAPS]; /**< \brief The heaps that the allocator manages. */
- bool initialized; /**< \brief Initialization flag of the allocator. */
- } allocator_t;
- #endif /* HEAP_H */
|