# HG changeset patch # User Nina Engelhardt # Date 1356607199 -3600 # Node ID 104d0b27de1281633be4c1039b9c79c2c4040a4a # Parent 094ad1bdeaec70efbe90750df3979cc3d7abb2e0 make DEBUG__printf variadic, add realloc, remove some dead code diff -r 094ad1bdeaec -r 104d0b27de12 Defines/VMS_defs__HW_constants.h --- a/Defines/VMS_defs__HW_constants.h Mon Oct 29 17:02:43 2012 +0100 +++ b/Defines/VMS_defs__HW_constants.h Thu Dec 27 12:19:59 2012 +0100 @@ -33,7 +33,7 @@ #define VIRT_PROCR_STACK_SIZE 0x8000 /* 32K */ // memory for VMS_int__malloc -#define MALLOC_ADDITIONAL_MEM_FROM_OS_SIZE 0x8000000 /* 128M */ +#define MALLOC_ADDITIONAL_MEM_FROM_OS_SIZE 0x10000000 /* 256M */ //Frequency of TS counts -- have to do tests to verify //NOTE: turn off (in BIOS) TURBO-BOOST and SPEED-STEP else won't be const diff -r 094ad1bdeaec -r 104d0b27de12 Services_Offered_by_VMS/Debugging/DEBUG__macros.h --- a/Services_Offered_by_VMS/Debugging/DEBUG__macros.h Mon Oct 29 17:02:43 2012 +0100 +++ b/Services_Offered_by_VMS/Debugging/DEBUG__macros.h Thu Dec 27 12:19:59 2012 +0100 @@ -15,10 +15,10 @@ /* */ #ifdef DEBUG__TURN_ON_DEBUG_PRINT - #define DEBUG__printf( bool, msg) \ + #define DEBUG__printf( bool, msg, ...) \ do{\ if(bool)\ - { printf(msg);\ + { printf(msg, ##__VA_ARGS__);\ printf(" | function: %s\n", __FUNCTION__);\ fflush(stdin);\ }\ @@ -51,10 +51,30 @@ }\ }while(0);/*macro magic to isolate var-names*/ + #define DEBUG__printf_w_task(bool, taskStub, msg, ...) \ + do{\ + if(bool)\ + { printf("Task ");\ + if(taskStub->taskID) {\ + int i;\ + for(i=1;itaskID[0];i++)\ + {\ + printf("%d,",taskStub->taskID[i]);\ + }\ + printf("%d: ",taskStub->taskID[i]);\ + } else {\ + printf("%p: ", taskStub);\ + }\ + printf(msg , ##__VA_ARGS__); \ + printf(" | function: %s\n", __FUNCTION__);\ + fflush(stdin);\ + }\ + }while(0) #else - #define DEBUG__printf( bool, msg) + #define DEBUG__printf( bool, msg, ...) #define DEBUG__printf1( bool, msg, param) #define DEBUG__printf2( bool, msg, p1, p2) + #define DEBUG__printf_w_task(bool, taskStub, msg, ...) #endif //============================= ERROR MSGs ============================ diff -r 094ad1bdeaec -r 104d0b27de12 Services_Offered_by_VMS/Memory_Handling/vmalloc.c --- a/Services_Offered_by_VMS/Memory_Handling/vmalloc.c Mon Oct 29 17:02:43 2012 +0100 +++ b/Services_Offered_by_VMS/Memory_Handling/vmalloc.c Thu Dec 27 12:19:59 2012 +0100 @@ -301,7 +301,7 @@ } void * -VMS_WL__malloc( int32 sizeRequested ) +VMS_WL__malloc( size_t sizeRequested ) { void *ret; VMS_int__get_master_lock(); @@ -324,7 +324,7 @@ MallocArrays* freeLists = _VMSMasterEnv->freeLists; MallocProlog *chunkToFree = (MallocProlog*)ptrToFree - 1; uint32 containerIdx; - + //Check for free neighbors if(chunkToFree->nextLowerInMem) { @@ -375,7 +375,39 @@ VMS_int__get_master_lock(); VMS_int__free( ptrToFree ); VMS_int__release_master_lock(); - } +} + +/* + * This is sequential code, meant to only be called from the Master, not from + * any slave Slvs. + */ +void* +VMS_int__realloc(void *oldPtr, size_t sizeRequested) { + + + void* newPtr = VMS_int__malloc(sizeRequested); + + if (oldPtr) { + MallocProlog *chunkToFree = (MallocProlog*) oldPtr - 1; + size_t chunkSize = getChunkSize(chunkToFree); + + memcpy(newPtr,oldPtr,chunkSize); + + VMS_int__free(oldPtr); + } + + return newPtr; +} + +void* +VMS_WL__realloc(void *oldPtr, size_t sizeRequested) + { + + VMS_int__get_master_lock(); + void* newPtr = VMS_int__realloc(oldPtr, sizeRequested); + VMS_int__release_master_lock(); + return newPtr; +} /* * Designed to be called from the main thread outside of VMS, during init @@ -452,7 +484,7 @@ */ void VMS_ext__free_free_list( MallocArrays *freeLists ) - { + { free(freeLists->memSpace); free(freeLists->bigChunks); free(freeLists->smallChunks); diff -r 094ad1bdeaec -r 104d0b27de12 Services_Offered_by_VMS/Memory_Handling/vmalloc.h --- a/Services_Offered_by_VMS/Memory_Handling/vmalloc.h Mon Oct 29 17:02:43 2012 +0100 +++ b/Services_Offered_by_VMS/Memory_Handling/vmalloc.h Thu Dec 27 12:19:59 2012 +0100 @@ -14,7 +14,7 @@ #include "VMS_impl/VMS_primitive_data_types.h" -#define SERVICE__TURN_ON_VALGRIND +//#define SERVICE__TURN_ON_VALGRIND #ifdef SERVICE__TURN_ON_VALGRIND #include "../valgrind/memcheck.h" @@ -63,10 +63,18 @@ #define VMS_PI__malloc VMS_int__malloc void * -VMS_WL__malloc( int32 sizeRequested ); /*BUG: -- get master lock */ +VMS_WL__malloc( size_t sizeRequested ); /*BUG: -- get master lock */ #define VMS_App__malloc VMS_WL__malloc void * +VMS_int__realloc(void *oldPtr, size_t sizeRequested ); +#define VMS_PI__realloc VMS_int__realloc + +void * +VMS_WL__realloc(void *oldPtr, size_t sizeRequested ); /*BUG: -- get master lock */ +#define VMS_App__remalloc VMS_WL__realloc + +void * VMS_int__malloc_aligned( size_t sizeRequested ); #define VMS_PI__malloc_aligned VMS_int__malloc_aligned diff -r 094ad1bdeaec -r 104d0b27de12 Services_Offered_by_VMS/Memory_Handling/vmalloc.supp --- a/Services_Offered_by_VMS/Memory_Handling/vmalloc.supp Mon Oct 29 17:02:43 2012 +0100 +++ b/Services_Offered_by_VMS/Memory_Handling/vmalloc.supp Thu Dec 27 12:19:59 2012 +0100 @@ -27,3 +27,16 @@ ... fun:VMS_int__malloc } + +{ + vmsmalloc + Memcheck:Addr8 + ... + fun:VMS_int__free +} +{ + vmsmalloc + Memcheck:Addr4 + ... + fun:VMS_int__free +} diff -r 094ad1bdeaec -r 104d0b27de12 VMS__startup_and_shutdown.c --- a/VMS__startup_and_shutdown.c Mon Oct 29 17:02:43 2012 +0100 +++ b/VMS__startup_and_shutdown.c Thu Dec 27 12:19:59 2012 +0100 @@ -271,7 +271,6 @@ void create_masterEnv() { MasterEnv *masterEnv; - VMSQueueStruc **readyToAnimateQs; int coreIdx; SlaveVP **masterVPs; AnimSlot ***allAnimSlots; //ptr to array of ptrs @@ -289,8 +288,6 @@ //===================== Only VMS__malloc after this ==================== masterEnv = (MasterEnv*)_VMSMasterEnv; - //Make a readyToAnimateQ for each core controller - readyToAnimateQs = VMS_int__malloc( NUM_CORES * sizeof(VMSQueueStruc *) ); masterVPs = VMS_int__malloc( NUM_CORES * sizeof(SlaveVP *) ); //One array for each core, several in array, core's masterVP scheds all @@ -301,8 +298,6 @@ _VMSMasterEnv->numSlavesCreated = 0; //used by create slave to set ID for( coreIdx = 0; coreIdx < NUM_CORES; coreIdx++ ) { - readyToAnimateQs[ coreIdx ] = makeVMSQ(); - //Q: should give masterVP core-specific info as its init data? masterVPs[ coreIdx ] = VMS_int__create_slaveVP( (TopLevelFnPtr)&animationMaster, (void*)masterEnv ); masterVPs[ coreIdx ]->coreAnimatedBy = coreIdx; @@ -547,6 +542,10 @@ void VMS_SS__cleanup_at_end_of_shutdown() { + int coreIdx; + SlaveVP **masterVPs; + AnimSlot ***allAnimSlots; //ptr to array of ptrs + //Before getting rid of everything, print out any measurements made if( _VMSMasterEnv->measHistsInfo != NULL ) { forAllInDynArrayDo( _VMSMasterEnv->measHistsInfo, (DynArrayFnPtr)&printHist ); @@ -564,20 +563,17 @@ //All the environment data has been allocated with VMS__malloc, so just // free its internal big-chunk and all inside it disappear. /* - readyToAnimateQs = _VMSMasterEnv->readyToAnimateQs; masterVPs = _VMSMasterEnv->masterVPs; allAnimSlots = _VMSMasterEnv->allAnimSlots; for( coreIdx = 0; coreIdx < NUM_CORES; coreIdx++ ) { - freeVMSQ( readyToAnimateQs[ coreIdx ] ); //master Slvs were created external to VMS, so use external free VMS_int__dissipate_slaveVP( masterVPs[ coreIdx ] ); freeAnimSlots( allAnimSlots[ coreIdx ] ); } - VMS_int__free( _VMSMasterEnv->readyToAnimateQs ); VMS_int__free( _VMSMasterEnv->masterVPs ); VMS_int__free( _VMSMasterEnv->allAnimSlots );