# HG changeset patch # User Sean Halle # Date 1339030798 25200 # Node ID 4c7414df4f0e4a7e37fe71e8f31ce32a167850ee # Parent f1267bc7b3428573f29f5f377614e32c6b5074a4 bug fixes to taking requests out, and core controller diff -r f1267bc7b342 -r 4c7414df4f0e CoreController.c --- a/CoreController.c Wed May 30 14:23:47 2012 -0700 +++ b/CoreController.c Wed Jun 06 17:59:58 2012 -0700 @@ -222,6 +222,17 @@ pthread_exit( NULL ); } +inline uint32_t +randomNumber() + { + _VMSMasterEnv->seed1 = (uint32)(36969 * (_VMSMasterEnv->seed1 & 65535) + + (_VMSMasterEnv->seed1 >> 16) ); + _VMSMasterEnv->seed2 = (uint32)(18000 * (_VMSMasterEnv->seed2 & 65535) + + (_VMSMasterEnv->seed2 >> 16) ); + return (_VMSMasterEnv->seed1 << 16) + _VMSMasterEnv->seed2; + } + + /*Busy-wait for a random number of cycles -- chooses number of cycles * differently than for the too-many-tries-to-get-lock backoff diff -r f1267bc7b342 -r 4c7414df4f0e Defines/VMS_defs__HW_constants.h --- a/Defines/VMS_defs__HW_constants.h Wed May 30 14:23:47 2012 -0700 +++ b/Defines/VMS_defs__HW_constants.h Wed Jun 06 17:59:58 2012 -0700 @@ -31,7 +31,7 @@ #define VIRT_PROCR_STACK_SIZE 0x8000 /* 32K */ // memory for VMS_int__malloc -#define MALLOC_ADDITIONAL_MEM_FROM_OS_SIZE 0x80000000 /* 128M */ +#define MALLOC_ADDITIONAL_MEM_FROM_OS_SIZE 0x8000000 /* 128M */ //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 f1267bc7b342 -r 4c7414df4f0e Services_Offered_by_VMS/Measurement_and_Stats/probes.c --- a/Services_Offered_by_VMS/Measurement_and_Stats/probes.c Wed May 30 14:23:47 2012 -0700 +++ b/Services_Offered_by_VMS/Measurement_and_Stats/probes.c Wed Jun 06 17:59:58 2012 -0700 @@ -163,10 +163,11 @@ VMS_impl__index_probe_by_its_name( int32 probeID, SlaveVP *animSlv ) { IntervalProbe *probe; - //TODO: fix this To be in Master -- race condition + VMS_int__get_master_lock(); probe = _VMSMasterEnv->intervalProbes[ probeID ]; addValueIntoTable(probe->nameStr, probe, _VMSMasterEnv->probeNameHashTbl); + VMS_int__release_master_lock(); } diff -r f1267bc7b342 -r 4c7414df4f0e Services_Offered_by_VMS/Memory_Handling/vmalloc.c --- a/Services_Offered_by_VMS/Memory_Handling/vmalloc.c Wed May 30 14:23:47 2012 -0700 +++ b/Services_Offered_by_VMS/Memory_Handling/vmalloc.c Wed Jun 06 17:59:58 2012 -0700 @@ -163,7 +163,7 @@ uint64 searchVector = freeLists->bigChunksSearchVector[0]; //set small chunk bits to zero searchVector &= MAX_UINT64 << containerIdx; - containerIdx = __builtin_ffsl(searchVector); + containerIdx = __builtin_ffsl(searchVector); //least significant 1 bit if(containerIdx == 0) { @@ -171,6 +171,8 @@ containerIdx = __builtin_ffsl(searchVector); if(containerIdx == 0) { + //TODO: get additional mem and insert into free list + //malloc( MALLOC_ADDITIONAL_MEM_FROM_OS_SIZE ); printf("VMS malloc failed: low memory"); exit(1); } @@ -203,6 +205,7 @@ * This is sequential code, meant to only be called from the Master, not from * any slave Slvs. * + *May 2012 *ToDo: Improve speed, by using built-in leading 1 detector to calc free-list * index. *Change to two separate arrays, one for free-lists of small fixed-size chunks @@ -286,10 +289,12 @@ void * VMS_WL__malloc( int32 sizeRequested ) - { + { void *ret; + VMS_int__get_master_lock(); - VMS_int__malloc( sizeRequested ); + ret = VMS_int__malloc( sizeRequested ); VMS_int__release_master_lock(); + return ret; } diff -r f1267bc7b342 -r 4c7414df4f0e VMS.h --- a/VMS.h Wed May 30 14:23:47 2012 -0700 +++ b/VMS.h Wed Jun 06 17:59:58 2012 -0700 @@ -360,9 +360,11 @@ VMSReqst * VMS_PI__take_next_request_out_of( SlaveVP *slaveWithReq ); +//#define VMS_PI__take_next_request_out_of( slave ) slave->requests -inline void * -VMS_PI__take_sem_reqst_from( VMSReqst *req ); +//inline void * +//VMS_PI__take_sem_reqst_from( VMSReqst *req ); +#define VMS_PI__take_sem_reqst_from( req ) req->semReqData void inline VMS_PI__handle_VMSSemReq( VMSReqst *req, SlaveVP *requestingSlv, void *semEnv, diff -r f1267bc7b342 -r 4c7414df4f0e VMS__PI.c --- a/VMS__PI.c Wed May 30 14:23:47 2012 -0700 +++ b/VMS__PI.c Wed Jun 06 17:59:58 2012 -0700 @@ -30,8 +30,6 @@ handleThrowException( VMSSemReq *semReq, void *semEnv, ResumeSlvFnPtr resumeFn ); //======================================================================= -/*May 2012 - *DEPRECATED -- turn into a macro, that just accesses the request field VMSReqst * VMS_PI__take_next_request_out_of( SlaveVP *slaveWithReq ) @@ -43,12 +41,11 @@ slaveWithReq->requests = slaveWithReq->requests->nextReqst; return req; } -*/ -#define VMS_PI__take_next_request_out_of( slave ) slave->requests + /*May 2012 - *DEPRECATED + *CHANGED IMPL -- now a macro in header file * *Turn function into macro that just accesses the request field * @@ -58,7 +55,6 @@ return req->semReqData; } */ -#define VMS_PI__take_sem_reqst_from( req ) req->semReqData /* This is for OS requests and VMS infrastructure requests, such as to create diff -r f1267bc7b342 -r 4c7414df4f0e VMS__WL.c --- a/VMS__WL.c Wed May 30 14:23:47 2012 -0700 +++ b/VMS__WL.c Wed Jun 06 17:59:58 2012 -0700 @@ -143,6 +143,7 @@ *To throw exception from wrapper lib or application, first turn * it into a request, then send the request */ +void VMS_WL__throw_exception( char *msgStr, SlaveVP *reqstSlv, VMSExcp *excpData ) { VMSReqst req; VMSSemReq semReq; diff -r f1267bc7b342 -r 4c7414df4f0e VMS__int.c --- a/VMS__int.c Wed May 30 14:23:47 2012 -0700 +++ b/VMS__int.c Wed Jun 06 17:59:58 2012 -0700 @@ -250,7 +250,8 @@ } //try to get the lock - gotLock = __sync_bool_compare_and_swap( addrOfMasterLock, UNLOCKED, LOCKED ); + gotLock = __sync_bool_compare_and_swap( addrOfMasterLock, + UNLOCKED, LOCKED ); } MEAS__Capture_Post_Master_Lock_Point; }