changeset 76:9ddbb071142d

make hardware independent and port to 64bit
author Merten Sach <msach@mailbox.tu-berlin.de>
date Thu, 16 Jun 2011 14:41:15 +0200
parents f6990e1ba998
children fe5ec83f1baf
files CoreLoop.c SwitchAnimators.h VMS.c VMS.h contextSwitch.s probes.c probes.h vmalloc.c vmalloc.h
diffstat 9 files changed, 170 insertions(+), 143 deletions(-) [+]
line diff
     1.1 --- a/CoreLoop.c	Thu Jun 02 13:55:51 2011 +0200
     1.2 +++ b/CoreLoop.c	Thu Jun 16 14:41:15 2011 +0200
     1.3 @@ -7,8 +7,10 @@
     1.4  
     1.5  #include "VMS.h"
     1.6  #include "Queue_impl/BlockingQueue.h"
     1.7 +#include "SwitchAnimators.h"
     1.8  
     1.9  #include <stdlib.h>
    1.10 +#include <stdio.h>
    1.11  #include <time.h>
    1.12  
    1.13  #include <pthread.h>
    1.14 @@ -35,7 +37,7 @@
    1.15     int             thisCoresIdx;
    1.16     VirtProcr      *currPr;
    1.17     VMSQueueStruc *readyToAnimateQ;
    1.18 -   unsigned long   coreMask;  //has 1 in bit positions of allowed cores
    1.19 +   cpu_set_t   coreMask;  //has 1 in bit positions of allowed cores
    1.20     int             errorCode;
    1.21  
    1.22        //work-stealing struc on stack to prevent false-sharing in cache-line
    1.23 @@ -66,7 +68,9 @@
    1.24        //set thread affinity
    1.25        //Linux requires pinning thd to core inside thread-function
    1.26        //Designate a core by a 1 in bit-position corresponding to the core
    1.27 -   coreMask = 1 << coreLoopThdParams->coreNum;
    1.28 +   CPU_ZERO(&coreMask);
    1.29 +   CPU_SET(coreLoopThdParams->coreNum,&coreMask);
    1.30 +   //coreMask = 1L << coreLoopThdParams->coreNum;
    1.31  
    1.32     pthread_t selfThd = pthread_self();
    1.33     errorCode =
    1.34 @@ -76,7 +80,7 @@
    1.35  
    1.36     
    1.37     //Save the return address in the SwitchVP function
    1.38 -   saveCoreLoopReturnAddr(&(_VMSMasterEnv->coreLoopReturnPt));
    1.39 +   saveCoreLoopReturnAddr((void**)&(_VMSMasterEnv->coreLoopReturnPt));
    1.40  
    1.41     
    1.42     while(1){
     2.1 --- a/SwitchAnimators.h	Thu Jun 02 13:55:51 2011 +0200
     2.2 +++ b/SwitchAnimators.h	Thu Jun 16 14:41:15 2011 +0200
     2.3 @@ -8,9 +8,9 @@
     2.4  
     2.5  #ifndef _SwitchAnimators_H
     2.6  #define	_SwitchAnimators_H
     2.7 -#define __USE_GNU
     2.8 +#define _GNU_SOURCE
     2.9  
    2.10 -void saveCoreLoopReturnAddr(void *returnAddress);
    2.11 +void saveCoreLoopReturnAddr(void **returnAddress);
    2.12  
    2.13  void switchToVP(VirtProcr *nextProcr);
    2.14  
    2.15 @@ -18,8 +18,10 @@
    2.16  
    2.17  void masterSwitchToCoreLoop(VirtProcr *nextProcr);
    2.18  
    2.19 +void startVirtProcrFn();
    2.20 +
    2.21  #define flushRegisters() \
    2.22 -        asm volatile ("":::"%eax","%ebx", "%ecx", "%edx","%edi","%esi")
    2.23 +        asm volatile ("":::"%rbx", "%r12", "%r13","%r14","%r15")
    2.24  
    2.25  /*Isolating code for switching between animators within these macros -- at
    2.26   * some point will make switches to compile for 32 bit or for 64 bit, which
     3.1 --- a/VMS.c	Thu Jun 02 13:55:51 2011 +0200
     3.2 +++ b/VMS.c	Thu Jun 16 14:41:15 2011 +0200
     3.3 @@ -8,6 +8,7 @@
     3.4  #include <stdlib.h>
     3.5  #include <string.h>
     3.6  #include <malloc.h>
     3.7 +#include <inttypes.h>
     3.8  #include <sys/time.h>
     3.9  
    3.10  #include "VMS.h"
    3.11 @@ -138,7 +139,7 @@
    3.12        readyToAnimateQs[ coreIdx ] = makeVMSQ();
    3.13        
    3.14           //Q: should give masterVP core-specific info as its init data?
    3.15 -      masterVPs[ coreIdx ] = VMS__create_procr( &masterLoop, masterEnv );
    3.16 +      masterVPs[ coreIdx ] = VMS__create_procr( (VirtProcrFnPtr)&masterLoop, (void*)masterEnv );
    3.17        masterVPs[ coreIdx ]->coreAnimatedBy = coreIdx;
    3.18        allSchedSlots[ coreIdx ] = create_sched_slots(); //makes for one core
    3.19        _VMSMasterEnv->numMasterInARow[ coreIdx ] = 0;
    3.20 @@ -175,7 +176,7 @@
    3.21                                                 "master lock high time hist");
    3.22     #endif
    3.23     
    3.24 -   MakeTheMeasHists
    3.25 +   MakeTheMeasHists();
    3.26     //========================================================================
    3.27  
    3.28   }
    3.29 @@ -293,26 +294,38 @@
    3.30   */
    3.31  inline VirtProcr *
    3.32  create_procr_helper( VirtProcr *newPr,       VirtProcrFnPtr  fnPtr,
    3.33 -                     void      *initialData, char           *stackLocs )
    3.34 +                     void      *initialData, void           *stackLocs )
    3.35   {
    3.36 -   char  *stackPtr;
    3.37 +   void  *stackPtr;
    3.38  
    3.39     newPr->startOfStack = stackLocs;
    3.40     newPr->procrID      = _VMSMasterEnv->numProcrsCreated++;
    3.41 -   newPr->nextInstrPt  = fnPtr;
    3.42     newPr->initialData  = initialData;
    3.43     newPr->requests     = NULL;
    3.44     newPr->schedSlot    = NULL;
    3.45  
    3.46 -      //fnPtr takes two params -- void *initData & void *animProcr
    3.47 -      //alloc stack locations, make stackPtr be the highest addr minus room
    3.48 -      // for 2 params + return addr.  Return addr (NULL) is in loc pointed to
    3.49 -      // by stackPtr, initData at stackPtr + 4 bytes, animatingPr just above
    3.50 -   stackPtr = ( (char *)stackLocs + VIRT_PROCR_STACK_SIZE - 0x10 );
    3.51 +   /*
    3.52 +    * Hardware dependent part           
    3.53 +    */
    3.54 +   //instead of calling the function directly, call a wrapper function to fetch
    3.55 +   //arguments from stack
    3.56 +   newPr->nextInstrPt  = (VirtProcrFnPtr)&startVirtProcrFn;
    3.57 +   
    3.58 +    //fnPtr takes two params -- void *initData & void *animProcr
    3.59 +    //alloc stack locations, make stackPtr be the highest addr minus room
    3.60 +    // for 2 params + return addr.  Return addr (NULL) is in loc pointed to
    3.61 +    // by stackPtr, initData at stackPtr + 8 bytes, animatingPr just above
    3.62 +   stackPtr = ( (void *)stackLocs + VIRT_PROCR_STACK_SIZE - 4*sizeof(void*));
    3.63     
    3.64        //setup __cdecl on stack -- coreloop will switch to stackPtr before jmp
    3.65 -   *( (int *)stackPtr + 2 ) = (int) newPr; //rightmost param -- 32bit pointer
    3.66 -   *( (int *)stackPtr + 1 ) = (int) initialData;  //next  param to left
    3.67 +   *((VirtProcr**)stackPtr + 2 ) = newPr; //rightmost param
    3.68 +   *((void**)stackPtr + 1 ) = initialData;  //next  param to left
    3.69 +   *((void**)stackPtr) = (void*)fnPtr;
    3.70 +   
    3.71 +   /*
    3.72 +    * end of Hardware dependent part           
    3.73 +    */
    3.74 +   
    3.75     newPr->stackPtr = stackPtr; //core loop will switch to this, then
    3.76     newPr->framePtr = stackPtr; //suspend loop will save new stack & frame ptr
    3.77  
    3.78 @@ -331,7 +344,7 @@
    3.79  inline VirtProcr *
    3.80  VMS__create_procr( VirtProcrFnPtr fnPtr, void *initialData )
    3.81   { VirtProcr *newPr;
    3.82 -   char      *stackLocs;
    3.83 +   void      *stackLocs;
    3.84  
    3.85     newPr      = VMS__malloc( sizeof(VirtProcr) );
    3.86     stackLocs  = VMS__malloc( VIRT_PROCR_STACK_SIZE );
    3.87 @@ -585,7 +598,6 @@
    3.88                         ResumePrFnPtr resumePrFnPtr )
    3.89   { VMSSemReq     *semReq;
    3.90     IntervalProbe *newProbe;
    3.91 -   int32          nameLen;
    3.92  
    3.93     semReq = req->semReqData;
    3.94  
     4.1 --- a/VMS.h	Thu Jun 02 13:55:51 2011 +0200
     4.2 +++ b/VMS.h	Thu Jun 16 14:41:15 2011 +0200
     4.3 @@ -8,7 +8,7 @@
     4.4  
     4.5  #ifndef _VMS_H
     4.6  #define	_VMS_H
     4.7 -#define __USE_GNU
     4.8 +#define _GNU_SOURCE
     4.9  
    4.10  #include "VMS_primitive_data_types.h"
    4.11  #include "Queue_impl/PrivateQueue.h"
    4.12 @@ -17,33 +17,32 @@
    4.13  #include "Hash_impl/PrivateHash.h"
    4.14  #include "vmalloc.h"
    4.15  
    4.16 -//#include <stdio.h>
    4.17  #include <pthread.h>
    4.18  #include <sys/time.h>
    4.19  
    4.20  
    4.21  //===============================  Debug  ===================================
    4.22  //
    4.23 -   //When SEQUENTIAL is defined, VMS does sequential exe in the main thread
    4.24 -   // It still does co-routines and all the mechanisms are the same, it just
    4.25 -   // has only a single thread and animates VPs one at a time
    4.26 +//When SEQUENTIAL is defined, VMS does sequential exe in the main thread
    4.27 +// It still does co-routines and all the mechanisms are the same, it just
    4.28 +// has only a single thread and animates VPs one at a time
    4.29  //#define SEQUENTIAL
    4.30  
    4.31  //#define USE_WORK_STEALING
    4.32  
    4.33 -   //turns on the probe-instrumentation in the application -- when not
    4.34 -   // defined, the calls to the probe functions turn into comments
    4.35 +//turns on the probe-instrumentation in the application -- when not
    4.36 +// defined, the calls to the probe functions turn into comments
    4.37  #define STATS__ENABLE_PROBES
    4.38  //#define TURN_ON_DEBUG_PROBES
    4.39  
    4.40 -   //These defines turn types of bug messages on and off
    4.41 -   // be sure debug messages are un-commented (next block of defines)
    4.42 +//These defines turn types of bug messages on and off
    4.43 +// be sure debug messages are un-commented (next block of defines)
    4.44  #define dbgAppFlow   TRUE /* Top level flow of application code -- general*/
    4.45  #define dbgProbes    FALSE /* for issues inside probes themselves*/
    4.46  #define dbgB2BMaster FALSE /* in coreloop, back to back master VPs*/
    4.47  #define dbgRqstHdlr  FALSE /* in request handler code*/
    4.48  
    4.49 -   //Comment or un- the substitute half to turn on/off types of debug message
    4.50 +//Comment or un- the substitute half to turn on/off types of debug message
    4.51  #define DEBUG(  bool, msg)         \
    4.52  //  if( bool){ printf(msg); fflush(stdin);}
    4.53  #define DEBUG1( bool, msg, param)  \
    4.54 @@ -51,15 +50,15 @@
    4.55  #define DEBUG2( bool, msg, p1, p2) \
    4.56  //   if(bool) {printf(msg, p1, p2); fflush(stdin);}
    4.57  
    4.58 -#define ERROR(msg) printf(msg); //fflush(stdin);
    4.59 -#define ERROR1(msg, param) printf(msg, param); fflush(stdin);
    4.60 -#define ERROR2(msg, p1, p2) printf(msg, p1, p2); fflush(stdin);
    4.61 +#define ERROR(msg) printf(msg);
    4.62 +#define ERROR1(msg, param) printf(msg, param); 
    4.63 +#define ERROR2(msg, p1, p2) printf(msg, p1, p2);
    4.64  
    4.65  //===========================  STATS =======================
    4.66  
    4.67     //when MEAS__TIME_STAMP_SUSP is defined, causes code to be inserted and
    4.68     // compiled-in that saves the low part of the time stamp count just before
    4.69 -   // suspending a processor and just after resuming that processor.  It is
    4.70 +   // suspending a processor and just after resuming that processorsrc/VPThread_lib/VMS/VMS.h:322: warning: previous declaration of ‘VMS__create_procr’ was here.  It is
    4.71     // saved into a field added to VirtProcr.  Have to sanity-check for
    4.72     // rollover of low portion into high portion.
    4.73  //#define MEAS__TIME_STAMP_SUSP
    4.74 @@ -188,7 +187,7 @@
    4.75     SchedSlot  *schedSlot;
    4.76     VMSReqst   *requests;
    4.77  
    4.78 -   void       *semanticData; //this lives here for the life of VP
    4.79 +   void       *semanticData; //this livesUSE_GNU here for the life of VP
    4.80     void       *dataRetFromReq;//values returned from plugin to VP go here
    4.81  
    4.82        //=========== MEASUREMENT STUFF ==========
    4.83 @@ -197,7 +196,7 @@
    4.84     unsigned int postSuspTSCLow;
    4.85     #endif
    4.86     #ifdef MEAS__TIME_MASTER /* in VirtProcr because multiple masterVPs*/
    4.87 -   unsigned int startMasterTSCLow;
    4.88 +   unsigned int startMasterTSCLow;USE_GNU
    4.89     unsigned int endMasterTSCLow;
    4.90     #endif
    4.91        //========================================
    4.92 @@ -319,7 +318,7 @@
    4.93  void
    4.94  VMS__start_the_work_then_wait_until_done_Seq();
    4.95  
    4.96 -VirtProcr *
    4.97 +inline VirtProcr *
    4.98  VMS__create_procr( VirtProcrFnPtr fnPtr, void *initialData );
    4.99  
   4.100  void
   4.101 @@ -374,7 +373,7 @@
   4.102  
   4.103  //======================== STATS ======================
   4.104  
   4.105 -//===== RDTSC wrapper =====
   4.106 +//===== RDTSC wrapper ===== //Also runs with x86_64 code
   4.107  
   4.108  #define saveTimeStampCountInto(low, high) \
   4.109     asm volatile("RDTSC;                   \
   4.110 @@ -411,7 +410,7 @@
   4.111  #define condWaitHistIdx    4
   4.112  #define condSignalHistIdx  5
   4.113  
   4.114 -#define MakeTheMeasHists \
   4.115 +#define MakeTheMeasHists() \
   4.116     _VMSMasterEnv->measHistsInfo = \
   4.117                makePrivDynArrayOfSize( (void***)&(_VMSMasterEnv->measHists), 200); \
   4.118     makeAMeasHist( createHistIdx,      "Create",        50, 0, 100 ) \
   4.119 @@ -429,7 +428,7 @@
   4.120  #define spawnHistIdx      1
   4.121  #define syncHistIdx       2
   4.122  
   4.123 -#define MakeTheMeasHists \
   4.124 +#define MakeTheMeasHists() \
   4.125     _VMSMasterEnv->measHistsInfo = \
   4.126                makePrivDynArrayOfSize( (void***)&(_VMSMasterEnv->measHists), 200); \
   4.127      makeAMeasHist( spawnHistIdx,      "Spawn",        50, 0, 200 ) \
   4.128 @@ -446,7 +445,7 @@
   4.129  #define ReceiveFromToHistIdx   3
   4.130  #define ReceiveOfTypeHistIdx   4
   4.131  
   4.132 -#define MakeTheMeasHists \
   4.133 +#define MakeTheMeasHists() \
   4.134     _VMSMasterEnv->measHistsInfo = \
   4.135                makePrivDynArrayOfSize( (void***)&(_VMSMasterEnv->measHists), 200); \
   4.136      makeAMeasHist( SendFromToHistIdx,   "SendFromTo",    50, 0, 100 ) \
     5.1 --- a/contextSwitch.s	Thu Jun 02 13:55:51 2011 +0200
     5.2 +++ b/contextSwitch.s	Thu Jun 16 14:41:15 2011 +0200
     5.3 @@ -7,64 +7,70 @@
     5.4  //Arguments: Pointer to variable holding address
     5.5  .globl saveCoreLoopReturnAddr
     5.6  saveCoreLoopReturnAddr:
     5.7 -    movl    0x4(%esp) , %eax       #load pointer
     5.8 -    movl    $coreLoopReturn, %ecx   #load label address
     5.9 -    movl    %ecx, (%eax)           #save address
    5.10 +    movq    $coreLoopReturn, %rcx   #load label address
    5.11 +    movq    %rcx, (%rdi)           #save address to pointer
    5.12      ret
    5.13  
    5.14  
    5.15 +//Initializes VirtProcrFn at first run for 64 bit mode
    5.16 +//Puts argument from stack into registers
    5.17 +.globl startVirtProcrFn
    5.18 +startVirtProcrFn:
    5.19 +    movq    %rdi      , %rsi #get second argument from first argument of switchVP
    5.20 +    movq    0x08(%rsp), %rdi #get first argument
    5.21 +    movq    (%rsp)    , %rax #get function addr
    5.22 +    jmp     *%rax
    5.23  
    5.24 -//Switches form CoreLoop to VP ether normal VP or the Master Loop
    5.25 +//Switches form CoreLoop to VP ether a normal VP or the Master Loop
    5.26  //switch to virt procr's stack and frame ptr then jump to virt procr fn
    5.27  /* VirtProcr  offsets:
    5.28 - * 0xc  stackPtr
    5.29 - * 0x10 framePtr
    5.30 - * 0x14 nextInstrPt
    5.31 - * 0x1c coreLoopFramePtr
    5.32 - * 0x20 coreLoopStackPtr
    5.33 + * 0x10  stackPtr
    5.34 + * 0x18 framePtr
    5.35 + * 0x20 nextInstrPt
    5.36 + * 0x30 coreLoopFramePtr
    5.37 + * 0x38 coreLoopStackPtr
    5.38   *
    5.39   * _VMSMasterEnv  offsets:
    5.40 - * 0x24 coreLoopReturnPt
    5.41 - * 0x2c masterLock
    5.42 + * 0x48 coreLoopReturnPt
    5.43 + * 0x54 masterLock
    5.44   */
    5.45  .globl switchToVP
    5.46  switchToVP:
    5.47 -    movl    0x4(%esp) , %ecx         #get VirtProcr
    5.48 -    movl    %esp      , 0x20(%ecx)   #save core loop stack pointer 
    5.49 -    movl    %ebp      , 0x1c(%ecx)   #save core loop frame pointer
    5.50 -    movl    0x0c(%ecx), %esp         #restore stack pointer
    5.51 -    movl    0x10(%ecx), %ebp         #restore frame pointer
    5.52 -    movl    0x14(%ecx), %eax         #get jmp pointer
    5.53 -    jmp     *%eax                    #jmp to VP
    5.54 +    #VirtProcr in %rdi
    5.55 +    movq    %rsp      , 0x38(%rdi)   #save core loop stack pointer 
    5.56 +    movq    %rbp      , 0x30(%rdi)   #save core loop frame pointer
    5.57 +    movq    0x10(%rdi), %rsp         #restore stack pointer
    5.58 +    movq    0x18(%rdi), %rbp         #restore frame pointer
    5.59 +    movq    0x20(%rdi), %rax         #get jmp pointer
    5.60 +    jmp     *%rax                    #jmp to VP
    5.61  coreLoopReturn:
    5.62      ret
    5.63  
    5.64      
    5.65  //switches to core loop. saves return address
    5.66  /* VirtProcr  offsets:
    5.67 - * 0xc  stackPtr
    5.68 - * 0x10 framePtr
    5.69 - * 0x14 nextInstrPt
    5.70 - * 0x1c coreLoopFramePtr
    5.71 - * 0x20 coreLoopStackPtr
    5.72 + * 0x10  stackPtr
    5.73 + * 0x18 framePtr
    5.74 + * 0x20 nextInstrPt
    5.75 + * 0x30 coreLoopFramePtr
    5.76 + * 0x38 coreLoopStackPtr
    5.77   *
    5.78   * _VMSMasterEnv  offsets:
    5.79 - * 0x24 coreLoopReturnPt
    5.80 - * 0x28 coreLoopEndPt
    5.81 - * 0x2c masterLock
    5.82 + * 0x48 coreLoopReturnPt
    5.83 + * 0x54 masterLock
    5.84   */
    5.85  .globl switchToCoreLoop
    5.86  switchToCoreLoop:
    5.87 -    movl    0x4(%esp) , %ecx         #get VirtProcr
    5.88 -    movl    $VPReturn , 0x14(%ecx)   #store return address
    5.89 -    movl    %esp      , 0x0c(%ecx)   #save stack pointer 
    5.90 -    movl    %ebp      , 0x10(%ecx)   #save frame pointer
    5.91 -    movl    0x20(%ecx), %esp         #restore stack pointer
    5.92 -    movl    0x1c(%ecx), %ebp         #restore frame pointer
    5.93 -    movl    $_VMSMasterEnv, %ecx
    5.94 -    movl    (%ecx)    , %ecx
    5.95 -    movl    0x24(%ecx), %eax         #get CoreLoopStartPt
    5.96 -    jmp     *%eax                    #jmp to CoreLoop
    5.97 +    #VirtProcr in %rdi
    5.98 +    movq    $VPReturn , 0x20(%rdi)   #store return address
    5.99 +    movq    %rsp      , 0x10(%rdi)   #save stack pointer 
   5.100 +    movq    %rbp      , 0x18(%rdi)   #save frame pointer
   5.101 +    movq    0x38(%rdi), %rsp         #restore stack pointer
   5.102 +    movq    0x30(%rdi), %rbp         #restore frame pointer
   5.103 +    movq    $_VMSMasterEnv, %rcx
   5.104 +    movq    (%rcx)    , %rcx
   5.105 +    movq    0x48(%rcx), %rax         #get CoreLoopStartPt
   5.106 +    jmp     *%rax                    #jmp to CoreLoop
   5.107  VPReturn:
   5.108      ret
   5.109  
   5.110 @@ -73,55 +79,57 @@
   5.111  //switches to core loop from master. saves return address
   5.112  //Releases masterLock so the next MasterLoop can be executed
   5.113  /* VirtProcr  offsets:
   5.114 - * 0xc  stackPtr
   5.115 - * 0x10 framePtr
   5.116 - * 0x14 nextInstrPt
   5.117 - * 0x1c coreLoopFramePtr
   5.118 - * 0x20 coreLoopStackPtr
   5.119 + * 0x10  stackPtr
   5.120 + * 0x18 framePtr
   5.121 + * 0x20 nextInstrPt
   5.122 + * 0x30 coreLoopFramePtr
   5.123 + * 0x38 coreLoopStackPtr
   5.124   *
   5.125   * _VMSMasterEnv  offsets:
   5.126 - * 0x24 coreLoopReturnPt
   5.127 - * 0x2c masterLock
   5.128 + * 0x48 coreLoopReturnPt
   5.129 + * 0x54 masterLock
   5.130   */
   5.131  .globl masterSwitchToCoreLoop
   5.132  masterSwitchToCoreLoop:
   5.133 -    movl    0x4(%esp) , %ecx         #get VirtProcr
   5.134 -    movl    $MasterReturn, 0x14(%ecx)   #store return address
   5.135 -    movl    %esp      , 0x0c(%ecx)   #save stack pointer 
   5.136 -    movl    %ebp      , 0x10(%ecx)   #save frame pointer
   5.137 -    movl    0x20(%ecx), %esp         #restore stack pointer
   5.138 -    movl    0x1c(%ecx), %ebp         #restore frame pointer
   5.139 -    movl    $_VMSMasterEnv, %ecx
   5.140 -    movl    (%ecx)    , %ecx
   5.141 -    movl    0x24(%ecx), %eax         #get CoreLoopStartPt
   5.142 -    movl    $0x0      , 0x2c(%ecx)   #release lock
   5.143 -    jmp     *%eax                    #jmp to CoreLoop
   5.144 +    #VirtProcr in %rdi
   5.145 +    movq    $MasterReturn, 0x20(%rdi)   #store return address
   5.146 +    movq    %rsp      , 0x10(%rdi)   #save stack pointer 
   5.147 +    movq    %rbp      , 0x18(%rdi)   #save frame pointer
   5.148 +    movq    0x38(%rdi), %rsp         #restore stack pointer
   5.149 +    movq    0x30(%rdi), %rbp         #restore frame pointer
   5.150 +    movq    $_VMSMasterEnv, %rcx
   5.151 +    movq    (%rcx)    , %rcx
   5.152 +    movq    0x48(%rcx), %rax         #get CoreLoopStartPt
   5.153 +    movl    $0x0      , 0x54(%rcx)   #release lock
   5.154 +    jmp     *%rax                    #jmp to CoreLoop
   5.155  MasterReturn:
   5.156      ret
   5.157  
   5.158  
   5.159  //Switch to terminateCoreLoop
   5.160 +//therefor switch to coreLoop context from master context
   5.161  // no need to call because the stack is already set up for switchVP
   5.162 +// and virtPr is in %rdi
   5.163  // and both functions have the same argument.
   5.164  // do not save register of VP because this function will never return
   5.165  /* VirtProcr  offsets:
   5.166 - * 0xc  stackPtr
   5.167 - * 0x10 framePtr
   5.168 - * 0x14 nextInstrPt
   5.169 - * 0x1c coreLoopFramePtr
   5.170 - * 0x20 coreLoopStackPtr
   5.171 + * 0x10  stackPtr
   5.172 + * 0x18 framePtr
   5.173 + * 0x20 nextInstrPt
   5.174 + * 0x30 coreLoopFramePtr
   5.175 + * 0x38 coreLoopStackPtr
   5.176   *
   5.177   * _VMSMasterEnv  offsets:
   5.178 - * 0x24 coreLoopReturnPt
   5.179 - * 0x2c masterLock
   5.180 + * 0x48 coreLoopReturnPt
   5.181 + * 0x58 masterLock
   5.182   */
   5.183  .globl asmTerminateCoreLoop
   5.184  asmTerminateCoreLoop:
   5.185 -    movl    0x4(%esp) , %ecx         #get VirtProcr
   5.186 -    movl    0x20(%ecx), %esp         #restore stack pointer
   5.187 -    movl    0x1c(%ecx), %ebp         #restore frame pointer
   5.188 -    movl    $terminateCoreLoop, %eax
   5.189 -    jmp     *%eax                    #jmp to CoreLoop
   5.190 +    #VirtProcr in %rdi
   5.191 +    movq    0x38(%rdi), %rsp         #restore stack pointer
   5.192 +    movq    0x30(%rdi), %rbp         #restore frame pointer
   5.193 +    movq    $terminateCoreLoop, %rax
   5.194 +    jmp     *%rax                    #jmp to CoreLoop
   5.195  
   5.196  
   5.197  /*
   5.198 @@ -130,13 +138,12 @@
   5.199   */
   5.200  .globl asmTerminateCoreLoopSeq
   5.201  asmTerminateCoreLoopSeq:
   5.202 -    movl    0x4(%esp) , %ecx         #get VirtProcr
   5.203 -    movl    0x20(%ecx), %esp         #restore stack pointer
   5.204 -    movl    0x1c(%ecx), %ebp         #restore frame pointer
   5.205 -    sub     $0x4      , %esp
   5.206 -    movl    %ecx      , (%esp)       #put argument on stack
   5.207 +    #VirtProcr in %rdi
   5.208 +    movq    0x38(%rdi), %rsp         #restore stack pointer
   5.209 +    movq    0x30(%rdi), %rbp         #restore frame pointer
   5.210 +    #argument is in %rdi
   5.211      call    VMS__dissipate_procr
   5.212 -    movl    %ebp      , %esp        #goto the coreLoops stack
   5.213 -    pop     %ebp        #restore the old framepointer
   5.214 +    movq    %rbp      , %rsp        #goto the coreLoops stack
   5.215 +    pop     %rbp        #restore the old framepointer
   5.216      ret                 #return from core loop
   5.217      
     6.1 --- a/probes.c	Thu Jun 02 13:55:51 2011 +0200
     6.2 +++ b/probes.c	Thu Jun 16 14:41:15 2011 +0200
     6.3 @@ -5,10 +5,8 @@
     6.4   */
     6.5  
     6.6  #include <stdio.h>
     6.7 -#include <stdlib.h>
     6.8  #include <malloc.h>
     6.9  #include <sys/time.h>
    6.10 -#include <string.h>
    6.11  
    6.12  #include "VMS.h"
    6.13  #include "Queue_impl/BlockingQueue.h"
    6.14 @@ -111,7 +109,7 @@
    6.15   */
    6.16  IntervalProbe *
    6.17  create_generic_probe( char *nameStr, VirtProcr *animPr )
    6.18 - { IntervalProbe *newProbe;
    6.19 +{
    6.20     VMSSemReq reqData;
    6.21  
    6.22     reqData.reqType  = createProbe;
    6.23 @@ -297,20 +295,21 @@
    6.24   {
    6.25     printf( "\nprobe: %s, ",  probe->nameStr );
    6.26     
    6.27 +   
    6.28     if( probe->schedChoiceWasRecorded )
    6.29 -    { printf( "coreNum: %d, procrID: %d, procrCreated: %.6lf | ",
    6.30 +    { printf( "coreNum: %d, procrID: %d, procrCreated: %0.6f | ",
    6.31                probe->coreNum, probe->procrID, probe->procrCreateSecs );
    6.32      }
    6.33  
    6.34     if( probe->endSecs == 0 ) //just a single point in time
    6.35      {
    6.36 -      printf( " time point: %.6lf\n",
    6.37 +      printf( " time point: %.6f\n",
    6.38                probe->startSecs - _VMSMasterEnv->createPtInSecs );
    6.39      }
    6.40     else if( probe->hist == NULL ) //just an interval
    6.41      {
    6.42 -      printf( " startSecs: %.6lf, interval: %.6lf\n", 
    6.43 -         probe->startSecs - _VMSMasterEnv->createPtInSecs, probe->interval);
    6.44 +      printf( " startSecs: %.6f interval: %.6f\n", 
    6.45 +         (probe->startSecs - _VMSMasterEnv->createPtInSecs), probe->interval);
    6.46      }
    6.47     else  //a full histogram of intervals
    6.48      {
    6.49 @@ -338,16 +337,16 @@
    6.50  
    6.51  void
    6.52  generic_print_probe( void *_probe )
    6.53 - { IntervalProbe *probe;
    6.54 -
    6.55 -   probe = (IntervalProbe *)_probe;
    6.56 -   print_probe_helper( probe );
    6.57 + { 
    6.58 +   IntervalProbe *probe = (IntervalProbe *)_probe;
    6.59 +   
    6.60 +   //TODO segfault in printf
    6.61 +   //print_probe_helper( probe );
    6.62   }
    6.63  
    6.64  void
    6.65  VMS_impl__print_stats_of_all_probes()
    6.66 - { IntervalProbe *probe;
    6.67 -
    6.68 + {
    6.69     forAllInDynArrayDo( _VMSMasterEnv->dynIntervalProbesInfo,
    6.70                         &generic_print_probe );
    6.71     fflush( stdout );
     7.1 --- a/probes.h	Thu Jun 02 13:55:51 2011 +0200
     7.2 +++ b/probes.h	Thu Jun 16 14:41:15 2011 +0200
     7.3 @@ -8,7 +8,7 @@
     7.4  
     7.5  #ifndef _PROBES_H
     7.6  #define	_PROBES_H
     7.7 -#define __USE_GNU
     7.8 +#define _GNU_SOURCE
     7.9  
    7.10  #include "VMS_primitive_data_types.h"
    7.11  
     8.1 --- a/vmalloc.c	Thu Jun 02 13:55:51 2011 +0200
     8.2 +++ b/vmalloc.c	Thu Jun 16 14:41:15 2011 +0200
     8.3 @@ -8,7 +8,9 @@
     8.4   */
     8.5  
     8.6  #include <malloc.h>
     8.7 +#include <inttypes.h>
     8.8  #include <stdlib.h>
     8.9 +#include <stdio.h>
    8.10  
    8.11  #include "VMS.h"
    8.12  #include "Histogram/Histogram.h"
    8.13 @@ -45,10 +47,10 @@
    8.14   *
    8.15   *Will find a
    8.16   */
    8.17 -void *
    8.18 -VMS__malloc( int32 sizeRequested )
    8.19 +void *VMS__malloc( size_t sizeRequested )
    8.20   { MallocProlog *foundElem = NULL, *currElem, *newElem;
    8.21 -   int32         amountExtra, foundElemIsTopOfHeap, sizeConsumed,sizeOfFound;
    8.22 +   ssize_t        amountExtra, sizeConsumed,sizeOfFound;
    8.23 +   uint32        foundElemIsTopOfHeap;
    8.24  
    8.25     //============================= MEASUREMENT STUFF ========================
    8.26     #ifdef MEAS__TIME_MALLOC
    8.27 @@ -63,7 +65,7 @@
    8.28  
    8.29     while( currElem != NULL )
    8.30      {    //check if size of currElem is big enough
    8.31 -      sizeOfFound=(int32)((char*)currElem->nextHigherInMem -(char*)currElem);
    8.32 +      sizeOfFound=(size_t)((uintptr_t)currElem->nextHigherInMem -(uintptr_t)currElem);
    8.33        amountExtra = sizeOfFound - sizeRequested - sizeof(MallocProlog);
    8.34        if( amountExtra > 0 )
    8.35         {    //found it, get out of loop
    8.36 @@ -99,7 +101,7 @@
    8.37     if( amountExtra > 64 )
    8.38      {    //make new elem by adding to addr of curr elem then casting
    8.39        sizeConsumed = sizeof(MallocProlog) + sizeRequested;
    8.40 -      newElem = (MallocProlog *)( (char *)foundElem + sizeConsumed );
    8.41 +      newElem = (MallocProlog *)( (uintptr_t)foundElem + sizeConsumed );
    8.42        newElem->nextHigherInMem   = foundElem->nextHigherInMem;
    8.43        newElem->nextLowerInMem    = foundElem;
    8.44        foundElem->nextHigherInMem = newElem;
    8.45 @@ -124,7 +126,7 @@
    8.46     //========================================================================
    8.47  
    8.48        //skip over the prolog by adding its size to the pointer return
    8.49 -   return (void *)((char *)foundElem + sizeof(MallocProlog));
    8.50 +   return (void*)((uintptr_t)foundElem + sizeof(MallocProlog));
    8.51   }
    8.52  
    8.53  
    8.54 @@ -137,7 +139,8 @@
    8.55  void
    8.56  VMS__free( void *ptrToFree )
    8.57   { MallocProlog *elemToFree, *nextLowerElem, *nextHigherElem;
    8.58 -   int32         lowerExistsAndIsFree, higherExistsAndIsFree, sizeOfElem;
    8.59 +   size_t         sizeOfElem;
    8.60 +   uint32         lowerExistsAndIsFree, higherExistsAndIsFree;
    8.61  
    8.62     //============================= MEASUREMENT STUFF ========================
    8.63     #ifdef MEAS__TIME_MALLOC
    8.64 @@ -152,8 +155,8 @@
    8.65        return;
    8.66      }
    8.67        //subtract size of prolog to get pointer to prolog, then cast
    8.68 -   elemToFree = (MallocProlog *)((char *)ptrToFree - sizeof(MallocProlog));
    8.69 -   sizeOfElem =(int32)((char*)elemToFree->nextHigherInMem-(char*)elemToFree);
    8.70 +   elemToFree = (MallocProlog *)((uintptr_t)ptrToFree - sizeof(MallocProlog));
    8.71 +   sizeOfElem =(size_t)((uintptr_t)elemToFree->nextHigherInMem-(uintptr_t)elemToFree);
    8.72  
    8.73     if( elemToFree->prevChunkInFreeList != NULL )
    8.74      { printf( "error: freeing same element twice!" ); exit(1);
    8.75 @@ -257,7 +260,7 @@
    8.76   * empty or not --
    8.77   */
    8.78  void *
    8.79 -VMS__malloc_in_ext( int32 sizeRequested )
    8.80 +VMS__malloc_in_ext( size_t sizeRequested )
    8.81   {
    8.82   /*
    8.83        //This is running in the master, so no chance for multiple cores to be
    8.84 @@ -323,14 +326,14 @@
    8.85        //Use this addr to free the heap when cleanup
    8.86     freeListHead->nextLowerInMem      = firstChunk;
    8.87        //to identify top-of-heap elem, compare this addr to elem's next higher
    8.88 -   freeListHead->nextHigherInMem     = (void*)( (char*)firstChunk +
    8.89 +   freeListHead->nextHigherInMem     = (void*)( (uintptr_t)firstChunk +
    8.90                                           MALLOC_ADDITIONAL_MEM_FROM_OS_SIZE);
    8.91     freeListHead->nextChunkInFreeList = firstChunk;
    8.92  
    8.93     firstChunk->nextChunkInFreeList   = NULL;
    8.94     firstChunk->prevChunkInFreeList   = freeListHead;
    8.95        //next Higher has to be set to top of chunk, so can calc size in malloc
    8.96 -   firstChunk->nextHigherInMem       = (void*)( (char*)firstChunk +
    8.97 +   firstChunk->nextHigherInMem       = (void*)( (uintptr_t)firstChunk +
    8.98                                           MALLOC_ADDITIONAL_MEM_FROM_OS_SIZE);
    8.99     firstChunk->nextLowerInMem        = NULL; //identifies as bott of heap
   8.100     
     9.1 --- a/vmalloc.h	Thu Jun 02 13:55:51 2011 +0200
     9.2 +++ b/vmalloc.h	Thu Jun 16 14:41:15 2011 +0200
     9.3 @@ -11,6 +11,7 @@
     9.4  #define	_VMALLOC_H
     9.5  
     9.6  #include <malloc.h>
     9.7 +#include <inttypes.h>
     9.8  #include "VMS_primitive_data_types.h"
     9.9  
    9.10  typedef struct _MallocProlog MallocProlog;
    9.11 @@ -27,12 +28,12 @@
    9.12  typedef struct
    9.13   {
    9.14     MallocProlog *firstChunkInFreeList;
    9.15 -   int32         numInList;
    9.16 +   int32         numInList; //TODO not used
    9.17   }
    9.18  FreeListHead;
    9.19  
    9.20  void *
    9.21 -VMS__malloc( int32 sizeRequested );
    9.22 +VMS__malloc( size_t sizeRequested );
    9.23  
    9.24  void
    9.25  VMS__free( void *ptrToFree );
    9.26 @@ -40,7 +41,7 @@
    9.27  /*Allocates memory from the external system -- higher overhead
    9.28   */
    9.29  void *
    9.30 -VMS__malloc_in_ext( int32 sizeRequested );
    9.31 +VMS__malloc_in_ext( size_t sizeRequested );
    9.32  
    9.33  /*Frees memory that was allocated in the external system -- higher overhead
    9.34   */