comparison vmalloc.c @ 175:de5e7c522f1f

aligned memory allocation
author Merten Sach <msach@mailbox.tu-berlin.de>
date Tue, 20 Dec 2011 19:17:11 +0100
parents c3f458403cd6
children 0320b49ca013
comparison
equal deleted inserted replaced
30:e211ad3f1708 31:605b2ff5f7ce
139 */ 139 */
140 inline 140 inline
141 MallocProlog *divideChunk(MallocProlog* chunk, size_t newSize) 141 MallocProlog *divideChunk(MallocProlog* chunk, size_t newSize)
142 { 142 {
143 MallocProlog* newChunk = (MallocProlog*)((uintptr_t)chunk->nextHigherInMem - 143 MallocProlog* newChunk = (MallocProlog*)((uintptr_t)chunk->nextHigherInMem -
144 newSize - sizeof(MallocProlog)); 144 newSize);
145
146 newChunk = __align_adress((uintptr_t)newChunk+CACHELINE_SIZE-1)-sizeof(MallocProlog);
145 147
146 newChunk->nextLowerInMem = chunk; 148 newChunk->nextLowerInMem = chunk;
147 newChunk->nextHigherInMem = chunk->nextHigherInMem; 149 newChunk->nextHigherInMem = chunk->nextHigherInMem;
148 150
149 chunk->nextHigherInMem->nextLowerInMem = newChunk; 151 chunk->nextHigherInMem->nextLowerInMem = newChunk;
210 int32 startStamp, endStamp; 212 int32 startStamp, endStamp;
211 saveLowTimeStampCountInto( startStamp ); 213 saveLowTimeStampCountInto( startStamp );
212 #endif 214 #endif
213 //======================================================================== 215 //========================================================================
214 216
215 sizeRequested += CACHELINE_SIZE; //Allocate more than cacheline_size to avoid false sharing 217 sizeRequested += (2*CACHELINE_SIZE); //Allocate more than cacheline_size to avoid false sharing
216 218
217 MallocArrays* freeLists = _VMSMasterEnv->freeLists; 219 MallocArrays* freeLists = _VMSMasterEnv->freeLists;
218 MallocProlog* foundChunk; 220 MallocProlog* foundChunk;
219 221
220 //Return a small chunk if the requested size is smaller than 128B 222 //Return a small chunk if the requested size is smaller than 128B