Mercurial > cgi-bin > hgwebdir.cgi > VMS > VMS_Implementations > VMS_impls > VMS__MC_shared_impl
annotate vmalloc.h @ 116:35547e66b971
malloc: multiple small chunk allocation
| author | Merten Sach <msach@mailbox.tu-berlin.de> |
|---|---|
| date | Mon, 29 Aug 2011 17:09:00 +0200 |
| parents | 62c59f2ac9f1 |
| children | 07e679ee2095 |
| rev | line source |
|---|---|
| Me@50 | 1 /* |
| Me@50 | 2 * Copyright 2009 OpenSourceCodeStewardshipFoundation.org |
| Me@50 | 3 * Licensed under GNU General Public License version 2 |
| Me@50 | 4 * |
| Me@50 | 5 * Author: seanhalle@yahoo.com |
| Me@50 | 6 * |
| Me@50 | 7 * Created on November 14, 2009, 9:07 PM |
| Me@50 | 8 */ |
| Me@50 | 9 |
| Me@65 | 10 #ifndef _VMALLOC_H |
| Me@65 | 11 #define _VMALLOC_H |
| Me@65 | 12 |
| Me@50 | 13 #include <malloc.h> |
| msach@76 | 14 #include <inttypes.h> |
| Me@50 | 15 #include "VMS_primitive_data_types.h" |
| Me@50 | 16 |
| msach@101 | 17 #define SMALL_CHUNK_SIZE 32 |
| msach@101 | 18 #define SMALL_CHUNK_COUNT 4 |
| msach@101 | 19 #define LOWER_BOUND 128 |
| msach@101 | 20 #define CHUNK_INCREASE_RATE 1.25 |
| msach@102 | 21 #define MAX_SMALL_CHUNKS 20 |
| msach@102 | 22 #define SMALL_CHUNKS_ALLOCATION 5 |
| msach@101 | 23 |
| msach@101 | 24 #define LOG54 0.096910013 |
| msach@101 | 25 #define LOG128 2.10720997 |
| msach@101 | 26 |
| Me@50 | 27 typedef struct _MallocProlog MallocProlog; |
| Me@50 | 28 |
| Me@50 | 29 struct _MallocProlog |
| Me@50 | 30 { |
| Me@50 | 31 MallocProlog *nextChunkInFreeList; |
| Me@50 | 32 MallocProlog *prevChunkInFreeList; |
| Me@50 | 33 MallocProlog *nextHigherInMem; |
| Me@50 | 34 MallocProlog *nextLowerInMem; |
| Me@50 | 35 }; |
| Me@50 | 36 //MallocProlog |
| msach@101 | 37 |
| msach@101 | 38 typedef struct MallocArrays MallocArrays; |
| msach@101 | 39 |
| msach@101 | 40 struct MallocArrays |
| msach@101 | 41 { |
| msach@101 | 42 MallocProlog **smallChunks; |
| msach@102 | 43 uint32 smallChunkCount[SMALL_CHUNK_COUNT]; |
| msach@101 | 44 MallocProlog **bigChunks; |
| msach@116 | 45 uint64 bigChunksSearchVector[2]; |
| msach@102 | 46 void *memSpace; |
| msach@101 | 47 uint32 containerCount; |
| msach@101 | 48 }; |
| msach@101 | 49 //MallocArrays |
| Me@50 | 50 |
| Me@50 | 51 typedef struct |
| Me@50 | 52 { |
| Me@50 | 53 MallocProlog *firstChunkInFreeList; |
| msach@76 | 54 int32 numInList; //TODO not used |
| Me@50 | 55 } |
| Me@50 | 56 FreeListHead; |
| Me@50 | 57 |
| Me@50 | 58 void * |
| msach@76 | 59 VMS__malloc( size_t sizeRequested ); |
| Me@50 | 60 |
| msach@78 | 61 void * |
| msach@78 | 62 VMS__malloc_aligned( size_t sizeRequested ); |
| msach@78 | 63 |
| Me@50 | 64 void |
| Me@50 | 65 VMS__free( void *ptrToFree ); |
| Me@50 | 66 |
| Me@53 | 67 /*Allocates memory from the external system -- higher overhead |
| Me@53 | 68 */ |
| Me@53 | 69 void * |
| msach@76 | 70 VMS__malloc_in_ext( size_t sizeRequested ); |
| Me@53 | 71 |
| Me@53 | 72 /*Frees memory that was allocated in the external system -- higher overhead |
| Me@53 | 73 */ |
| Me@53 | 74 void |
| Me@53 | 75 VMS__free_in_ext( void *ptrToFree ); |
| Me@53 | 76 |
| Me@53 | 77 |
| msach@101 | 78 MallocArrays * |
| Me@53 | 79 VMS_ext__create_free_list(); |
| Me@50 | 80 |
| Me@50 | 81 void |
| msach@102 | 82 VMS_ext__free_free_list(MallocArrays *freeLists ); |
| Me@65 | 83 |
| Me@65 | 84 #endif |
