changeset 126:d0aa5a796fc5 malloc2

touch memory at start of algorithm to make it comparable
author Merten Sach <msach@mailbox.tu-berlin.de>
date Wed, 07 Sep 2011 14:33:22 +0200
parents 9b2b9bc2c362
children 90cbb7b803ee
files vmalloc.c
diffstat 1 files changed, 8 insertions(+), 0 deletions(-) [+]
line diff
     1.1 --- a/vmalloc.c	Wed Sep 07 14:28:20 2011 +0200
     1.2 +++ b/vmalloc.c	Wed Sep 07 14:33:22 2011 +0200
     1.3 @@ -342,6 +342,14 @@
     1.4     if( firstChunk == NULL ) {printf("Can't allocate initial memory\n"); exit(1);}
     1.5     freeLists->memSpace = firstChunk;
     1.6     
     1.7 +   //Touch memory to avoid page faults
     1.8 +   void *ptr,*endPtr; 
     1.9 +   endPtr = (void*)firstChunk+MALLOC_ADDITIONAL_MEM_FROM_OS_SIZE;
    1.10 +   for(ptr = firstChunk; ptr < endPtr; ptr+=PAGE_SIZE)
    1.11 +   {
    1.12 +       *(char*)ptr = 0;
    1.13 +   }
    1.14 +   
    1.15     firstChunk->nextLowerInMem = NULL;
    1.16     firstChunk->nextHigherInMem = (MallocProlog*)((uintptr_t)firstChunk +
    1.17                          MALLOC_ADDITIONAL_MEM_FROM_OS_SIZE - sizeof(MallocProlog*));