diff VMS.h @ 70:f9b60012fd74

working ucontext version
author Merten Sach <msach@mailbox.tu-berlin.de>
date Fri, 27 May 2011 12:35:40 +0200
parents 11bfe9d136ed
children efb55f1b5fb9
line diff
     1.1 --- a/VMS.h	Wed May 11 16:13:24 2011 +0200
     1.2 +++ b/VMS.h	Fri May 27 12:35:40 2011 +0200
     1.3 @@ -17,9 +17,9 @@
     1.4  #include "Hash_impl/PrivateHash.h"
     1.5  #include "vmalloc.h"
     1.6  
     1.7 -//#include <stdio.h>
     1.8  #include <pthread.h>
     1.9  #include <sys/time.h>
    1.10 +#include <ucontext.h>
    1.11  
    1.12  
    1.13  //===============================  Debug  ===================================
    1.14 @@ -51,9 +51,9 @@
    1.15  #define DEBUG2( bool, msg, p1, p2) \
    1.16  //   if(bool) {printf(msg, p1, p2); fflush(stdin);}
    1.17  
    1.18 -#define ERROR(msg) printf(msg); //fflush(stdin);
    1.19 -#define ERROR1(msg, param) printf(msg, param); fflush(stdin);
    1.20 -#define ERROR2(msg, p1, p2) printf(msg, p1, p2); fflush(stdin);
    1.21 +#define ERROR(msg) printf(msg);
    1.22 +#define ERROR1(msg, param) printf(msg, param);
    1.23 +#define ERROR2(msg, p1, p2) printf(msg, p1, p2);
    1.24  
    1.25  //===========================  STATS =======================
    1.26  
    1.27 @@ -175,13 +175,15 @@
    1.28   { int         procrID;  //for debugging -- count up each time create
    1.29     int         coreAnimatedBy;
    1.30     void       *startOfStack;
    1.31 -   void       *stackPtr;
    1.32 -   void       *framePtr;
    1.33 -   void       *nextInstrPt;
    1.34 +   //void       *stackPtr;
    1.35 +   //void       *framePtr;
    1.36 +   //void       *nextInstrPt;
    1.37 +   ucontext_t    *savedVPStatus;
    1.38     
    1.39 -   void       *coreLoopStartPt;  //allows proto-runtime to be linked later
    1.40 -   void       *coreLoopFramePtr; //restore before jmp back to core loop
    1.41 -   void       *coreLoopStackPtr; //restore before jmp back to core loop
    1.42 +   //void       *coreLoopStartPt;  //allows proto-runtime to be linked later
    1.43 +   //void       *coreLoopFramePtr; //restore before jmp back to core loop
    1.44 +   //void       *coreLoopStackPtr; //restore before jmp back to core loop
    1.45 +   ucontext_t  *savedCoreLoopStatus;
    1.46  
    1.47     void       *initialData;
    1.48  
    1.49 @@ -225,11 +227,11 @@
    1.50     MallocProlog    *freeListHead;
    1.51     int32            amtOfOutstandingMem; //total currently allocated
    1.52  
    1.53 -   void            *coreLoopStartPt;//addr to jump to to re-enter coreLoop
    1.54 -   void            *coreLoopEndPt;  //addr to jump to to shut down a coreLoop
    1.55 +   //void            *coreLoopStartPt;//addr to jump to to re-enter coreLoop
    1.56 +   //void            *coreLoopEndPt;  //addr to jump to to shut down a coreLoop
    1.57  
    1.58     int32            setupComplete;
    1.59 -   int32            masterLock;
    1.60 +   volatile int32            masterLock;
    1.61  
    1.62     int32            numMasterInARow[NUM_CORES];//detect back-to-back masterVP
    1.63     GateStruc       *workStealingGates[ NUM_CORES ]; //concurrent work-steal
    1.64 @@ -278,11 +280,11 @@
    1.65  
    1.66  //=======================  OS Thread related  ===============================
    1.67  
    1.68 -void * coreLoop( void *paramsIn );  //standard PThreads fn prototype
    1.69 +void coreLoop( void *paramsIn );  //standard PThreads fn prototype
    1.70  void * coreLoop_Seq( void *paramsIn );  //standard PThreads fn prototype
    1.71 +void terminateCoreLoop(VirtProcr *currPr);
    1.72  void masterLoop( void *initData, VirtProcr *masterPr );
    1.73  
    1.74 -
    1.75  typedef struct
    1.76   {
    1.77     void           *endThdPt;
    1.78 @@ -296,7 +298,6 @@
    1.79  pthread_cond_t  suspend_cond;
    1.80  
    1.81  
    1.82 -
    1.83  //=====================  Global Vars ===================
    1.84  
    1.85  volatile MasterEnv      *_VMSMasterEnv;
    1.86 @@ -548,6 +549,18 @@
    1.87  
    1.88  //=====
    1.89  
    1.90 +//======= Utilities ======
    1.91 +/*
    1.92 + * This Macro makes the gcc reload all variables from Stack after this function.
    1.93 + * This is necessary because we jmp into the masterLoop and the variables are
    1.94 + * kept in Registers for optimization.
    1.95 + */
    1.96 +#define flushRegisters() \
    1.97 +         asm volatile ("" /*no instr needed*/  \  
    1.98 +                        ::: /*no output and input*/ \
    1.99 +                        "%eax", "%ebx", "%ecx", "%edx", "%edi", "%esi")
   1.100 +//========
   1.101 +
   1.102  #include "SwitchAnimators.h"
   1.103  #include "probes.h"
   1.104  #include "vutilities.h"