comparison vmalloc.h @ 222:c88ce1db91ef

Compiles, but does not run properly -- and changed MasterLoop to SchedulingMaster
author Some Random Person <seanhalle@yahoo.com>
date Tue, 13 Mar 2012 10:02:06 -0700
parents eaf7e4c58c9e
children
comparison
equal deleted inserted replaced
23:61d5cd425e16 24:a299f3a7e7ce
12 12
13 #include <malloc.h> 13 #include <malloc.h>
14 #include <inttypes.h> 14 #include <inttypes.h>
15 #include "VMS_primitive_data_types.h" 15 #include "VMS_primitive_data_types.h"
16 16
17 #define SMALL_CHUNK_SIZE 32
18 #define SMALL_CHUNK_COUNT 4
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
21
22 #define LOG54 0.3219280948873623
23 #define LOG128 7
24
17 typedef struct _MallocProlog MallocProlog; 25 typedef struct _MallocProlog MallocProlog;
18 26
19 struct _MallocProlog 27 struct _MallocProlog
20 { 28 {
21 MallocProlog *nextChunkInFreeList; 29 MallocProlog *nextChunkInFreeList;
22 MallocProlog *prevChunkInFreeList; 30 MallocProlog *prevChunkInFreeList;
23 MallocProlog *nextHigherInMem; 31 MallocProlog *nextHigherInMem;
24 MallocProlog *nextLowerInMem; 32 MallocProlog *nextLowerInMem;
25 }; 33 };
26 //MallocProlog 34 //MallocProlog
35
36 typedef struct MallocArrays MallocArrays;
37
38 struct MallocArrays
39 {
40 MallocProlog **smallChunks;
41 MallocProlog **bigChunks;
42 uint64 bigChunksSearchVector[2];
43 void *memSpace;
44 uint32 containerCount;
45 };
46 //MallocArrays
27 47
28 typedef struct 48 typedef struct
29 { 49 {
30 MallocProlog *firstChunkInFreeList; 50 MallocProlog *firstChunkInFreeList;
31 int32 numInList; //TODO not used 51 int32 numInList; //TODO not used
32 } 52 }
33 FreeListHead; 53 FreeListHead;
34 54
35 void * 55 void *
36 VMS_int__malloc( size_t sizeRequested ); 56 VMS_int__malloc( size_t sizeRequested );
57 #define VMS_PI__malloc VMS_int__malloc
58 #define VMS_WL__malloc VMS_int__malloc /*TODO: Bug -- Not protected!! */
59 #define VMS_App__malloc VMS_int__malloc /*TODO: Bug -- Not protected!! */
37 60
38 void * 61 void *
39 VMS_int__malloc_aligned( size_t sizeRequested ); 62 VMS_int__malloc_aligned( size_t sizeRequested );
63 #define VMS_PI__malloc_aligned VMS_int__malloc_aligned
64 #define VMS_WL__malloc_aligned VMS_int__malloc_aligned
40 65
41 void 66 void
42 VMS_int__free( void *ptrToFree ); 67 VMS_int__free( void *ptrToFree );
68 #define VMS_PI__free VMS_int__free
69 #define VMS_WL__free VMS_int__free /*TODO: Bug -- Not protected!! */
70 #define VMS_App__free VMS_int__free /*TODO: Bug -- Not protected!! */
43 71
44 #define VMS_PI__malloc VMS_int__malloc
45 #define VMS_PI__malloc_aligned VMS_int__malloc_aligned
46 #define VMS_PI__free VMS_int__free
47 /* For now, the PI is protected by master lock, so int malloc fine
48 void *
49 VMS_PI__malloc( size_t sizeRequested );
50 72
51 void *
52 VMS_PI__malloc_aligned( size_t sizeRequested );
53
54 void
55 VMS_PI__free( void *ptrToFree );
56 */
57
58 //TODO: protect WL malloc from concurrency!! shared freelist can be corrupted
59 #define VMS_WL__malloc VMS_int__malloc
60 #define VMS_WL__malloc_aligned VMS_int__malloc_aligned
61 #define VMS_WL__free VMS_int__free
62 /*
63 void *
64 VMS_WL__malloc( size_t sizeRequested );
65
66 void *
67 VMS_WL__malloc_aligned( size_t sizeRequested );
68
69 void
70 VMS_WL__free( void *ptrToFree );
71 */
72 73
73 /*Allocates memory from the external system -- higher overhead 74 /*Allocates memory from the external system -- higher overhead
74 */ 75 */
75 void * 76 void *
76 VMS__malloc_in_ext( size_t sizeRequested ); 77 VMS_ext__malloc_in_ext( size_t sizeRequested );
77 78
78 /*Frees memory that was allocated in the external system -- higher overhead 79 /*Frees memory that was allocated in the external system -- higher overhead
79 */ 80 */
80 void 81 void
81 VMS__free_in_ext( void *ptrToFree ); 82 VMS_ext__free_in_ext( void *ptrToFree );
82 83
83 84
84 MallocProlog * 85 MallocArrays *
85 VMS_ext__create_free_list(); 86 VMS_ext__create_free_list();
86 87
87 void 88 void
88 VMS_ext__free_free_list( MallocProlog *freeListHead ); 89 VMS_ext__free_free_list(MallocArrays *freeLists );
89 90
90 #endif 91 #endif