diff VPThread.h @ 1:1d3157ac56c4

Updated to Nov 8 version of VMS -- added singleton, trans, etc
author SeanHalle
date Thu, 11 Nov 2010 04:29:10 -0800
parents 4aca264971b5
children e960a8d18f7c
line diff
     1.1 --- a/VPThread.h	Fri Sep 17 11:34:02 2010 -0700
     1.2 +++ b/VPThread.h	Thu Nov 11 04:29:10 2010 -0800
     1.3 @@ -14,14 +14,21 @@
     1.4  #include "VMS/DynArray/DynArray.h"
     1.5  
     1.6  
     1.7 +/*This header defines everything specific to the VPThread semantic plug-in
     1.8 + */
     1.9 +
    1.10 +
    1.11  //===========================================================================
    1.12  #define INIT_NUM_MUTEX 10000
    1.13  #define INIT_NUM_COND  10000
    1.14 +
    1.15 +#define NUM_STRUCS_IN_SEM_ENV 1000
    1.16  //===========================================================================
    1.17  
    1.18 -/*This header defines everything specific to the VPThread semantic plug-in
    1.19 - */
    1.20 -typedef struct _VPThreadSemReq   VPThreadSemReq;
    1.21 +//===========================================================================
    1.22 +typedef struct _VPThreadSemReq   VPThdSemReq;
    1.23 +typedef void  (*PtrToAtomicFn )   ( void * ); //executed atomically in master
    1.24 +//===========================================================================
    1.25  
    1.26  
    1.27  /*Semantic layer-specific data sent inside a request from lib called in app
    1.28 @@ -35,7 +42,13 @@
    1.29     make_cond,
    1.30     cond_wait,
    1.31     cond_signal,
    1.32 -   make_procr
    1.33 +   make_procr,
    1.34 +   malloc_req,
    1.35 +   free_req,
    1.36 +   singleton,
    1.37 +   atomic,
    1.38 +   trans_start,
    1.39 +   trans_end
    1.40   };
    1.41  
    1.42  struct _VPThreadSemReq
    1.43 @@ -43,28 +56,55 @@
    1.44     VirtProcr           *requestingPr;
    1.45     int32                mutexIdx;
    1.46     int32                condIdx;
    1.47 +
    1.48     void                *initData;
    1.49     VirtProcrFnPtr       fnPtr;
    1.50 +   int32                coreToScheduleOnto;
    1.51 +
    1.52 +   int32                sizeToMalloc;
    1.53 +   void                *ptrToFree;
    1.54 +
    1.55 +   int32              singletonID;
    1.56 +   void              *endJumpPt;
    1.57 +
    1.58 +   PtrToAtomicFn      fnToExecInMaster;
    1.59 +   void              *dataForFn;
    1.60 +
    1.61 +   int32              transID;
    1.62   }
    1.63  /* VPThreadSemReq */;
    1.64  
    1.65 +
    1.66 +typedef struct
    1.67 + {
    1.68 +   VirtProcr      *VPCurrentlyExecuting;
    1.69 +   PrivQueueStruc *waitingVPQ;
    1.70 + }
    1.71 +VPThdTrans;
    1.72 +
    1.73 +
    1.74  typedef struct
    1.75   {
    1.76        //Standard stuff will be in most every semantic env
    1.77 -   PrivQueueStruc **readyVPQs;
    1.78 -   int32            numVirtPr;
    1.79 -   int32            nextCoreToGetNewPr;
    1.80 +   PrivQueueStruc  **readyVPQs;
    1.81 +   int32             numVirtPr;
    1.82 +   int32             nextCoreToGetNewPr;
    1.83 +   int32             primitiveStartTime;
    1.84  
    1.85        //Specific to this semantic layer
    1.86 -   int32            currMutexIdx;
    1.87 -   DynArray32      *mutexDynArray;
    1.88 -   
    1.89 -   int32            currCondIdx;
    1.90 -   DynArray32      *condDynArray;
    1.91 +   VPThdMutex      **mutexDynArray;
    1.92 +   PrivDynArrayInfo *mutexDynArrayInfo;
    1.93  
    1.94 -   void            *applicationGlobals;
    1.95 +   VPThdCond       **condDynArray;
    1.96 +   PrivDynArrayInfo *condDynArrayInfo;
    1.97 +
    1.98 +   void             *applicationGlobals;
    1.99 +
   1.100 +                       //fix limit on num with dynArray
   1.101 +   int32             singletonHasBeenExecutedFlags[NUM_STRUCS_IN_SEM_ENV];
   1.102 +   VPThdTrans        transactionStrucs[NUM_STRUCS_IN_SEM_ENV];
   1.103   }
   1.104 -VPThreadSemEnv;
   1.105 +VPThdSemEnv;
   1.106  
   1.107  
   1.108  typedef struct
   1.109 @@ -73,21 +113,36 @@
   1.110     VirtProcr      *holderOfLock;
   1.111     PrivQueueStruc *waitingQueue;
   1.112   }
   1.113 -VPTMutex;
   1.114 +VPThdMutex;
   1.115  
   1.116  
   1.117  typedef struct
   1.118   {
   1.119     int32           condIdx;
   1.120     PrivQueueStruc *waitingQueue;
   1.121 -   VPTMutex       *partnerMutex;
   1.122 +   VPThdMutex       *partnerMutex;
   1.123   }
   1.124 -VPTCond;
   1.125 +VPThdCond;
   1.126 +
   1.127 +typedef struct _TransListElem TransListElem;
   1.128 +struct _TransListElem
   1.129 + {
   1.130 +   int32          transID;
   1.131 +   TransListElem *nextTrans;
   1.132 + };
   1.133 +//TransListElem
   1.134 +
   1.135 +typedef struct
   1.136 + {
   1.137 +   int32          highestTransEntered;
   1.138 +   TransListElem *lastTransEntered;
   1.139 + }
   1.140 +VPThdSemData;
   1.141  
   1.142  
   1.143  //===========================================================================
   1.144  
   1.145 -void
   1.146 +inline void
   1.147  VPThread__create_seed_procr_and_do_work( VirtProcrFnPtr fn, void *initData );
   1.148  
   1.149  //=======================
   1.150 @@ -96,50 +151,54 @@
   1.151  VPThread__create_thread( VirtProcrFnPtr fnPtr, void *initData,
   1.152                            VirtProcr *creatingPr );
   1.153  
   1.154 -void
   1.155 +inline VirtProcr *
   1.156 +VPThread__create_thread_with_affinity( VirtProcrFnPtr fnPtr, void *initData,
   1.157 +                          VirtProcr *creatingPr,  int32  coreToScheduleOnto );
   1.158 +
   1.159 +inline void
   1.160  VPThread__dissipate_thread( VirtProcr *procrToDissipate );
   1.161  
   1.162  //=======================
   1.163 -void
   1.164 +inline void
   1.165  VPThread__set_globals_to( void *globals );
   1.166  
   1.167 -void *
   1.168 +inline void *
   1.169  VPThread__give_globals();
   1.170  
   1.171  //=======================
   1.172 -int32
   1.173 +inline int32
   1.174  VPThread__make_mutex( VirtProcr *animPr );
   1.175  
   1.176 -void
   1.177 +inline void
   1.178  VPThread__mutex_lock( int32 mutexIdx, VirtProcr *acquiringPr );
   1.179                                                      
   1.180 -void
   1.181 +inline void
   1.182  VPThread__mutex_unlock( int32 mutexIdx, VirtProcr *releasingPr );
   1.183  
   1.184  
   1.185  //=======================
   1.186 -int32
   1.187 +inline int32
   1.188  VPThread__make_cond( int32 ownedMutexIdx, VirtProcr *animPr);
   1.189  
   1.190 -void
   1.191 +inline void
   1.192  VPThread__cond_wait( int32 condIdx, VirtProcr *waitingPr);
   1.193  
   1.194 -void *
   1.195 +inline void *
   1.196  VPThread__cond_signal( int32 condIdx, VirtProcr *signallingPr );
   1.197  
   1.198  
   1.199  
   1.200  
   1.201  //=========================  Internal use only  =============================
   1.202 -void
   1.203 +inline void
   1.204  VPThread__Request_Handler( VirtProcr *requestingPr, void *_semEnv );
   1.205  
   1.206 -VirtProcr *
   1.207 +inline VirtProcr *
   1.208  VPThread__schedule_virt_procr( void *_semEnv, int coreNum );
   1.209  
   1.210  //=======================
   1.211 -void
   1.212 -VPThread__free_semantic_request( VPThreadSemReq *semReq );
   1.213 +inline void
   1.214 +VPThread__free_semantic_request( VPThdSemReq *semReq );
   1.215  
   1.216  //=======================
   1.217