comparison vmalloc.h @ 140:2c8f3cf6c058

Free memory calculation
author Merten Sach <msach@mailbox.tu-berlin.de>
date Mon, 19 Sep 2011 18:43:08 +0200
parents 9b2b9bc2c362 0b49fd35afc1
children 98fc8f3761a2
comparison
equal deleted inserted replaced
12:f1d0e9e10f7b 16:dbabe6cd2d04
4 * 4 *
5 * Author: seanhalle@yahoo.com 5 * Author: seanhalle@yahoo.com
6 * 6 *
7 * Created on November 14, 2009, 9:07 PM 7 * Created on November 14, 2009, 9:07 PM
8 */ 8 */
9
10 #ifndef _VMALLOC_H 9 #ifndef _VMALLOC_H
11 #define _VMALLOC_H 10 #define _VMALLOC_H
12 11
13 #include <malloc.h> 12 #include <malloc.h>
14 #include <inttypes.h> 13 #include <inttypes.h>
15 #include "VMS_primitive_data_types.h" 14 #include "VMS_primitive_data_types.h"
15 #include "ProcrContext.h"
16 16
17 #define SMALL_CHUNK_SIZE 32 17 #define SMALL_CHUNK_SIZE 32
18 #define SMALL_CHUNK_COUNT 4 18 #define SMALL_CHUNK_COUNT 4
19 #define LOWER_BOUND 128 //Biggest chunk size that is created for the small chunks 19 #define LOWER_BOUND 128 //Biggest chunk size that is created for the small chunks
20 #define BIG_LOWER_BOUND 160 //Smallest chunk size that is created for the big chunks 20 #define BIG_LOWER_BOUND 160 //Smallest chunk size that is created for the big chunks
28 { 28 {
29 MallocProlog *nextChunkInFreeList; 29 MallocProlog *nextChunkInFreeList;
30 MallocProlog *prevChunkInFreeList; 30 MallocProlog *prevChunkInFreeList;
31 MallocProlog *nextHigherInMem; 31 MallocProlog *nextHigherInMem;
32 MallocProlog *nextLowerInMem; 32 MallocProlog *nextLowerInMem;
33 }; 33 };
34 //MallocProlog 34 //MallocProlog
35 35
36 typedef struct MallocArrays MallocArrays; 36 typedef struct MallocArrays MallocArrays;
37 37
38 struct MallocArrays 38 struct MallocArrays
39 { 39 {
40 MallocProlog **smallChunks; 40 MallocProlog **smallChunks;
41 MallocProlog **bigChunks; 41 MallocProlog **bigChunks;
42 uint64 bigChunksSearchVector[2]; 42 uint64 bigChunksSearchVector[2];
43 void *memSpace; 43 void *memSpace;
44 uint32 containerCount; 44 uint32 containerCount;
45 }; 45 };
46 //MallocArrays 46 //MallocArray
47
48
49 typedef struct
50 {
51 uintptr_t procrID;
52 MallocProlog *prevChunkInFreeList;
53 MallocProlog *nextHigherInMem;
54 MallocProlog *nextLowerInMem;
55 } MallocPrologAllocated;
56
47 57
48 typedef struct 58 typedef struct
49 { 59 {
50 MallocProlog *firstChunkInFreeList; 60 MallocProlog *firstChunkInFreeList;
51 int32 numInList; //TODO not used 61 int32 numInList; //TODO not used
52 } 62 } FreeListHead;
53 FreeListHead;
54 63
55 void * 64 void *
56 VMS__malloc( size_t sizeRequested ); 65 VMS__malloc_on_core(size_t sizeRequested, int procrID);
57 66
58 void * 67 void *
59 VMS__malloc_aligned( size_t sizeRequested ); 68 VMS__malloc(size_t sizeRequested);
69
70 void *
71 VMS__malloc_in_lib(size_t sizeRequested, VirtProcr *VProc);
60 72
61 void 73 void
62 VMS__free( void *ptrToFree ); 74 VMS__free( void *ptrToFree );
75
76 void
77 VMS__free_in_lib(void *ptrToFree, VirtProcr *VProc);
78
79 void
80 VMS__free_on_core(void *ptrToFree, int procrID);
63 81
64 /*Allocates memory from the external system -- higher overhead 82 /*Allocates memory from the external system -- higher overhead
65 */ 83 */
66 void * 84 void *
67 VMS__malloc_in_ext( size_t sizeRequested ); 85 VMS__malloc_in_ext( size_t sizeRequested );
69 /*Frees memory that was allocated in the external system -- higher overhead 87 /*Frees memory that was allocated in the external system -- higher overhead
70 */ 88 */
71 void 89 void
72 VMS__free_in_ext( void *ptrToFree ); 90 VMS__free_in_ext( void *ptrToFree );
73 91
74
75 MallocArrays * 92 MallocArrays *
76 VMS_ext__create_free_list(); 93 VMS_ext__create_free_list();
77 94
78 void 95 void
79 VMS_ext__free_free_list(MallocArrays *freeLists ); 96 VMS_ext__free_free_list(MallocArrays *freeLists );