Browse Source

Merge some comments.

Ioannis Koutras 13 years ago
parent
commit
d1e0da3239
4 changed files with 142 additions and 42 deletions
  1. 4 4
      Doxyfile
  2. 6 0
      block_header.c
  3. 71 7
      block_header.h
  4. 61 31
      heap.h

+ 4 - 4
Doxyfile

@@ -25,7 +25,7 @@ DOXYFILE_ENCODING      = UTF-8
 # The PROJECT_NAME tag is a single word (or a sequence of words surrounded
 # by quotes) that should identify the project.
 
-PROJECT_NAME           =
+PROJECT_NAME           = ddmlib
 
 # The PROJECT_NUMBER tag can be used to enter a project or revision number.
 # This could be handy for archiving the generated documentation or
@@ -199,7 +199,7 @@ ALIASES                =
 # For instance, some of the names that are used will be different. The list
 # of all members will be omitted, etc.
 
-OPTIMIZE_OUTPUT_FOR_C  = NO
+OPTIMIZE_OUTPUT_FOR_C  = YES
 
 # Set the OPTIMIZE_OUTPUT_JAVA tag to YES if your project consists of Java
 # sources only. Doxygen will then generate output that is more tailored for
@@ -640,7 +640,7 @@ RECURSIVE              = NO
 # excluded from the INPUT source files. This way you can easily exclude a
 # subdirectory from a directory tree whose root is specified with the INPUT tag.
 
-EXCLUDE                =
+EXCLUDE                = test.c lran2.h larson.c
 
 # The EXCLUDE_SYMLINKS tag can be used select whether or not files or
 # directories that are symbolic links (a Unix file system feature) are excluded
@@ -1541,7 +1541,7 @@ HIDE_UNDOC_RELATIONS   = YES
 # toolkit from AT&T and Lucent Bell Labs. The other options in this section
 # have no effect if this option is set to NO (the default)
 
-HAVE_DOT               = NO
+HAVE_DOT               = YES
 
 # The DOT_NUM_THREADS specifies the number of dot invocations doxygen is
 # allowed to run in parallel. When set to 0 (the default) doxygen will

+ 6 - 0
block_header.c

@@ -1,5 +1,10 @@
 #include "block_header.h"
 
+/**
+ * \brief Get the address of the block header of a memory block.
+ *
+ * \param ptr The data part of the memory block.
+ */
 block_header_t * get_header(void *ptr);
 
 block_header_t * get_header(void *ptr) {
@@ -42,6 +47,7 @@ void remove_block(void *block, void *starting_node) {
 
     void *current_node, *previous_node;
 
+    // Traverse a list starting from the starting node until block is found.
     for(current_node = starting_node; current_node != NULL; 
             current_node = get_next(current_node)) {
         if(current_node == block) {

+ 71 - 7
block_header.h

@@ -1,38 +1,102 @@
+/**
+ * \file 	block_header.h
+ * \author 	Ioannis Koutras (joko@microlab.ntua.gr)
+ * \date 	September, 2011
+ * \brief 	Block header structure and functions, and memory block functions.
+ */
+
 #ifndef BLOCK_HEADER_H
 #define BLOCK_HEADER_H
 
 #include <stddef.h>
 #include <stdbool.h>
 
+/**
+ * \brief The header structure of every memory block inside a heap.
+ */
 typedef struct block_header_s {
-	size_t size;
-	size_t requested_size;
-	size_t previous_size;
-	void *next;
+	size_t size; /**< \brief The size of the data part. */
+	size_t requested_size; /**< \brief The requested size of the data part */
+	size_t previous_size; /**< \brief The size of the data part of the
+				previous block in the memory space */
+	void *next; /**< \brief The next memory block in the list that the
+		      current block belongs to */
 } block_header_t;
 
+/**
+ * \brief The size of the header in number of bytes
+ */
 #define HEADER_SIZE sizeof(block_header_t)
 
+/**
+ * \brief Get the next memory block.
+ *
+ * \param ptr The pointer to the data part of the current memory block.
+ *
+ * \return The pointer of the data part of the next (in list) memory block.
+ * \retval NULL There is no next memory block in the list.
+ */
 void * get_next(void *ptr);
 
+/**
+ * \brief Get the size of the memory block's data
+ *
+ * \param ptr The pointer to the data part of the current memory block.
+ *
+ * \return The size of the data part of the current memory block.
+ */
 size_t get_size(void *ptr);
 
+/**
+ * \brief Set the size of the memory block's data
+ *
+ * \param ptr 	The pointer to the data part of the current memory block.
+ * \param size 	The size of the data part of the current memory block.
+ */
 void set_size(void *ptr, size_t size);
+
+/**
+ * \brief Set the requested size of memory block's data
+ *
+ * \param ptr 	The pointer to the data part of the current memory block.
+ * \param size 	The requested size for the data part of the current memory
+ * block.
+ */
 void set_requested_size(void *ptr, size_t size);
 
+/**
+ * \brief Set the next memory block of a block
+ *
+ * \param block 	The pointer to the data part of the current memory
+ * block.
+ * \param next_block 	The pointer to the data part of the next memory block.
+ */
 void set_next(void *block, void *next_block);
 
+/**
+ * \brief Check if previous block (in the memory space) belongs to a free list
+ */
 bool is_previous_free(void *ptr);
 
+/**
+ * \brief Get the size of the previous block (in the memory space) 
+ *
+ * \param ptr 	The pointer to the data part of the current memory block.
+ */
 size_t get_previous_size(void *ptr);
 
+/**
+ * \brief Get the previous memory block (in the memory space)
+ *
+ * \param ptr 	The pointer to the data part of the current memory block.
+ */
 void * get_previous(void *ptr);
 
 /**
- * Removes a memory block from a singly linked list of memory blocks.
+ * \brief Removes a memory block from a singly linked list of memory blocks.
  *
- * @param *block The block to be removed.
- * @param *starting_node The starting memory block of the list.
+ * \param *block The block to be removed.
+ * \param *starting_node The starting memory block of the list.
  */
 void remove_block(void *block, void *starting_node);
 

+ 61 - 31
heap.h

@@ -1,3 +1,10 @@
+/**
+ * \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
 
@@ -8,60 +15,83 @@
 
 #include "block_header.h"
 
+/**
+ * \brief The number of the heaps.
+ */
 #define NUM_HEAPS 4
 
 /**
- * A structure to represent a maptable node
+ * \brief A structure to represent a maptable node.
  */
 typedef struct maptable_node_s {
-	unsigned int size; /**< the size of the blocks of the fixed list */
-	void *fixed_list_head; /**< pointer to the head node of the fixed list */
-	struct maptable_node_s *next; /**< pointer to the next node of the maptable */
+	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; /**< maximum total memory allocated */
-	uint32_t max_mem_requested; /**< maximum total memory requested */
-	uint32_t mem_allocated; /**< total memory currently allocated */
-	uint32_t mem_requested; /**< total memory currently requested */
-	uint32_t mem_reserved; /**< total memory currently reserved */
-	uint32_t live_objects; /**< number of live objects */
-	uint32_t read_mem_accesses; /**< number of read accesses */
-	uint32_t write_mem_accesses; /**< number of write accesses */
-	uint32_t num_malloc; /**< number of malloc()'s served */
-	uint32_t num_free; /**< number of free()'s served */
+	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;
 
 /**
- * A structure to represent tunable parameters of a heap
+ * \brief A structure to represent tunable parameters of a heap
  */
 typedef struct dmmknobs_s {
-	int32_t max_coalesce_size; /**< maximum coalesce size; -1 if coalescing
-				     is not supported */
-	float frag_threshold; /**< fragmentation threshold to enable
-				coalescing or not */ 
-	uint32_t mem_threshold; /**< memory size threshold */
-	uint32_t min_split_size; // FIXME to be investigated if needed
-	float empty_threshold; // FIXME to be investigated if needed
+	/** \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;
-	void *free_list_head;
-	void *used_blocks_head;
-	void *rov_ptr;
-	uint64_t num_objects;
-	dmmstats_t dmm_stats;
-	dmmknobs_t dmm_knobs;
+	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;
+	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];
+	heap_t heaps[NUM_HEAPS]; /**< \brief The heaps that the allocator manages. */
 } allocator_t;
 
 #endif /* HEAP_H */