heap.h 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. #ifndef HEAP_H
  2. #define HEAP_H
  3. #include <stdint.h>
  4. #include <pthread.h>
  5. #include "block_header.h"
  6. #define NUM_HEAPS 4
  7. /**
  8. * A structure to represent a maptable node
  9. *
  10. * Heaps contain
  11. */
  12. typedef struct maptable_node_s {
  13. unsigned int size; /**< the size of the blocks of the fixed list */
  14. void *fixed_list_head; /**< pointer to the head node of the fixed list */
  15. struct maptable_node_s *next; /**< pointer to the next node of the maptable */
  16. } maptable_node_t;
  17. typedef struct dmmstats_s {
  18. uint32_t max_mem_allocated; /**< maximum total memory allocated */
  19. uint32_t max_mem_requested; /**< maximum total memory requested */
  20. uint32_t mem_allocated; /**< total memory currently allocated */
  21. uint32_t mem_requested; /**< total memory currently requested */
  22. uint32_t live_objects; /**< number of live objects */
  23. uint32_t read_mem_accesses; /**< number of read accesses */
  24. uint32_t write_mem_accesses; /**< number of write accesses */
  25. uint32_t num_malloc; /**< number of malloc()'s served */
  26. uint32_t num_free; /**< number of free()'s served */
  27. } dmmstats_t;
  28. typedef struct dmmknobs_s {
  29. uint32_t maxCoalesceSize;
  30. uint32_t minSplitSize;
  31. float empty_threshold;
  32. uint32_t percentage;
  33. char frag_state; //FIXME It was in the old code to refresh the frag check
  34. } dmmknobs_t;
  35. typedef struct heap_s {
  36. maptable_node_t *maptable_head;
  37. void *free_list_head;
  38. void *used_blocks_head;
  39. void *rov_ptr;
  40. uint64_t num_objects;
  41. dmmstats_t dmm_stats;
  42. dmmknobs_t dmm_knobs;
  43. pthread_mutex_t mutex;
  44. } heap_t;
  45. typedef struct allocator_s {
  46. heap_t heaps[NUM_HEAPS];
  47. } allocator_t;
  48. #endif /* HEAP_H */