Mercurial > cgi-bin > hgwebdir.cgi > VMS > VMS_Implementations > VMS_impls > VMS__MC_shared_impl
view 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 |
line source
1 /*
2 * Copyright 2009 OpenSourceCodeStewardshipFoundation.org
3 * Licensed under GNU General Public License version 2
4 *
5 * Author: seanhalle@yahoo.com
6 *
7 * Created on November 14, 2009, 9:07 PM
8 */
9 #ifndef _VMALLOC_H
10 #define _VMALLOC_H
12 #include <malloc.h>
13 #include <inttypes.h>
14 #include "VMS_primitive_data_types.h"
15 #include "ProcrContext.h"
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
22 #define LOG54 0.3219280948873623
23 #define LOG128 7
25 typedef struct _MallocProlog MallocProlog;
27 struct _MallocProlog
28 {
29 MallocProlog *nextChunkInFreeList;
30 MallocProlog *prevChunkInFreeList;
31 MallocProlog *nextHigherInMem;
32 MallocProlog *nextLowerInMem;
33 };
34 //MallocProlog
36 typedef struct MallocArrays MallocArrays;
38 struct MallocArrays
39 {
40 MallocProlog **smallChunks;
41 MallocProlog **bigChunks;
42 uint64 bigChunksSearchVector[2];
43 void *memSpace;
44 uint32 containerCount;
45 };
46 //MallocArray
49 typedef struct
50 {
51 uintptr_t procrID;
52 MallocProlog *prevChunkInFreeList;
53 MallocProlog *nextHigherInMem;
54 MallocProlog *nextLowerInMem;
55 } MallocPrologAllocated;
58 typedef struct
59 {
60 MallocProlog *firstChunkInFreeList;
61 int32 numInList; //TODO not used
62 } FreeListHead;
64 void *
65 VMS__malloc_on_core(size_t sizeRequested, int procrID);
67 void *
68 VMS__malloc(size_t sizeRequested);
70 void *
71 VMS__malloc_in_lib(size_t sizeRequested, VirtProcr *VProc);
73 void
74 VMS__free( void *ptrToFree );
76 void
77 VMS__free_in_lib(void *ptrToFree, VirtProcr *VProc);
79 void
80 VMS__free_on_core(void *ptrToFree, int procrID);
82 /*Allocates memory from the external system -- higher overhead
83 */
84 void *
85 VMS__malloc_in_ext( size_t sizeRequested );
87 /*Frees memory that was allocated in the external system -- higher overhead
88 */
89 void
90 VMS__free_in_ext( void *ptrToFree );
92 MallocArrays *
93 VMS_ext__create_free_list();
95 void
96 VMS_ext__free_free_list(MallocArrays *freeLists );
98 #endif
