Mercurial > cgi-bin > hgwebdir.cgi > VMS > VMS_Implementations > VMS_impls > VMS__MC_shared_impl
comparison VMS.h @ 5:6c518bda83fe
About to chg to win thds -- good except for that
| author | Me |
|---|---|
| date | Mon, 31 May 2010 19:15:14 -0700 |
| parents | a5fe730dfc2e |
| children | f96e4b3b35c7 |
comparison
equal
deleted
inserted
replaced
| 0:dba3068a8e4c | 1:7c4299dec858 |
|---|---|
| 7 */ | 7 */ |
| 8 | 8 |
| 9 #ifndef _VMS_H | 9 #ifndef _VMS_H |
| 10 #define _VMS_H | 10 #define _VMS_H |
| 11 | 11 |
| 12 | |
| 13 #include "VMS_primitive_data_types.h" | 12 #include "VMS_primitive_data_types.h" |
| 14 #include "Queue_impl/BlockingQueue.h" | 13 #include "Queue_impl/BlockingQueue.h" |
| 15 | 14 |
| 16 //This value is the number of hardware threads in the shared memory | 15 //This value is the number of hardware threads in the shared memory |
| 17 // machine | 16 // machine -- make double that number scheduling slots, plus extra for master |
| 18 #define NUM_WORKERS 4 | 17 #define NUM_WORKERS 4 |
| 19 #define NUM_SLAVES 8 | 18 #define NUM_SCHED_SLOTS 9 |
| 20 | 19 |
| 21 #define SUCCESS 0 | 20 #define SUCCESS 0 |
| 22 | 21 |
| 23 #define thdAttrs NULL | 22 #define thdAttrs NULL |
| 24 | 23 |
| 25 typedef struct WorkUnit WorkUnit; | 24 typedef struct _WorkUnit WorkUnit; |
| 26 typedef struct VMSProcr VMSProcr; | 25 typedef struct _VirtProcr VirtProcr; |
| 27 typedef struct SlaveReqst SlaveReqst; | 26 typedef struct _SlaveReqst SlaveReqst; |
| 27 typedef struct _SchedSlot SchedSlot; | |
| 28 | 28 |
| 29 typedef bool8 (*SlaveScheduler) ( void * ); | 29 typedef bool8 (*SlaveScheduler) ( SchedSlot *, void * ); |
| 30 typedef void (*RequestHandler) ( SlaveReqst * ); | 30 typedef void (*RequestHandler) ( SlaveReqst * ); |
| 31 typedef void (*VirtProcrFnPtr) ( void *, VirtProcr * ); | |
| 32 typedef void VirtProcrFn( void *, VirtProcr * ); | |
| 31 | 33 |
| 32 typedef struct | 34 typedef struct |
| 33 { | 35 { |
| 34 QueueStruc *workQ; | 36 QueueStruc *workQ; |
| 35 unsigned int id; | 37 unsigned int id; |
| 36 } | 38 } |
| 37 ThdParams; | 39 ThdParams; |
| 38 | 40 |
| 39 //This is application-level data of the scheduler that runs in the master | 41 struct _SchedSlot |
| 40 // virtual processor. This data is at a higher level than the slave data- | 42 { |
| 41 // struc, which is part of the virtualization infrastructure.. this | 43 int workIsDone; |
| 42 // MasterEnv sits on top of that level | 44 int needsProcrAssigned; |
| 45 VirtProcr *procrAssignedToSlot; | |
| 46 }; | |
| 47 | |
| 48 | |
| 49 struct _VirtProcr | |
| 50 { | |
| 51 void *stackPtr; | |
| 52 void *framePtr; | |
| 53 void *nextInstrPt; | |
| 54 void *coreLoopStartPt; //allows proto-runtime to be linked later | |
| 55 | |
| 56 void *initialData; | |
| 57 | |
| 58 SchedSlot *schedSlot; | |
| 59 SlaveReqst *requests; | |
| 60 | |
| 61 void *semanticData; | |
| 62 }; | |
| 63 | |
| 64 | |
| 65 //When optimize make a separate flat array in here for each flag in SchedSlot | |
| 66 //So that polling done flags is fast.. not sure even worth it, though.. | |
| 43 typedef struct | 67 typedef struct |
| 44 { | 68 { |
| 45 VMSProcr virtSlaves[ NUM_SLAVES ]; | 69 SlaveScheduler slaveScheduler; |
| 46 VMSProcr virtMaster; | 70 RequestHandler requestHandler; |
| 47 | 71 |
| 48 SlaveScheduler slaveScheduler; | 72 SchedSlot **schedSlots; |
| 49 RequestHandler requestHandler; | 73 SchedSlot **filledSlots; |
| 50 | 74 int numFilled; |
| 75 | |
| 51 int stillRunning; | 76 int stillRunning; |
| 52 WorkUnit *masterWorkUnit; | |
| 53 | 77 |
| 54 VMSProcr **scheduledSlaves; | 78 VirtProcr *masterVirtPr; |
| 55 int numScheduled; | |
| 56 | |
| 57 void *OSEventStruc; | |
| 58 void *semanticEnv; | 79 void *semanticEnv; |
| 80 void *OSEventStruc; //for future, when add I/O to BLIS | |
| 59 } | 81 } |
| 60 MasterEnv; | 82 MasterEnv; |
| 61 | 83 |
| 62 | 84 |
| 63 struct WorkUnit | 85 |
| 86 struct _SlaveReqst | |
| 64 { | 87 { |
| 65 VMSProcr *slaveAssignedTo; | 88 VirtProcr *slaveFrom; |
| 66 void *addrToJumpTo; | 89 int reqType; //for future when have I/O and OS services |
| 67 void *workData; | 90 void *semReqData; |
| 68 | |
| 69 void *pluginSpecific; | |
| 70 }; | |
| 71 | |
| 72 | |
| 73 struct VMSProcr | |
| 74 { | |
| 75 WorkUnit *workUnitToDo; | |
| 76 SlaveReqst *requestsToMaster; | |
| 77 int workIsDone; | |
| 78 int needsWorkAssigned; | |
| 79 }; | |
| 80 | |
| 81 struct SlaveReqst | |
| 82 { | |
| 83 VMSProcr *slaveFrom; | |
| 84 int reqType; | |
| 85 void *reqData; | |
| 86 | 91 |
| 87 SlaveReqst *nextRequest; | 92 SlaveReqst *nextRequest; |
| 88 }; | 93 }; |
| 89 | 94 |
| 90 | 95 |
| 92 void * coreLoop( void *paramsIn ); //standard PThreads fn prototype | 97 void * coreLoop( void *paramsIn ); //standard PThreads fn prototype |
| 93 | 98 |
| 94 | 99 |
| 95 //===================== Global Vars =================== | 100 //===================== Global Vars =================== |
| 96 | 101 |
| 102 | |
| 97 pthread_t coreLoopThds[ NUM_WORKERS ]; // std struc, holds thread info | 103 pthread_t coreLoopThds[ NUM_WORKERS ]; // std struc, holds thread info |
| 98 QueueStruc *workQ; | |
| 99 ThdParams thdParams[ NUM_WORKERS ]; | 104 ThdParams thdParams[ NUM_WORKERS ]; |
| 100 | 105 |
| 101 MasterEnv *masterEnv; | 106 volatile MasterEnv *_VMSMasterEnv; |
| 107 | |
| 108 //workQ is global, static, and volatile so that core loop has its location | |
| 109 // hard coded, and reloads every time through the loop -- that way don't | |
| 110 // need to save any regs used by core loop (will see if this really works) | |
| 111 volatile QueueStruc *_VMSWorkQ; | |
| 102 | 112 |
| 103 | 113 |
| 104 #endif /* _VMS_H */ | 114 #endif /* _VMS_H */ |
| 105 | 115 |
