comparison VMS.h @ 23:aa634ef7cc35

Full VMS test -- works
author Me
date Wed, 30 Jun 2010 13:11:06 -0700
parents c3e6c3fda84e
children 2b161e1a50ee
comparison
equal deleted inserted replaced
4:e7bf3c53c3a4 5:8ab601559d7d
12 #include "VMS_primitive_data_types.h" 12 #include "VMS_primitive_data_types.h"
13 #include "Queue_impl/BlockingQueue.h" 13 #include "Queue_impl/BlockingQueue.h"
14 #include <windows.h> 14 #include <windows.h>
15 #include <winbase.h> 15 #include <winbase.h>
16 16
17 //This value is the number of hardware threads in the shared memory 17 //This value is the number of hardware threads in the shared memory
18 // machine -- make double that number scheduling slots, plus extra for master 18 // machine
19 #define NUM_CORES 4 19 #define NUM_CORES 4
20 #define NUM_SCHED_SLOTS 9 20
21 // make double-num-cores scheduling slots, plus extra for master
22 #define NUM_SCHED_SLOTS (2 * NUM_CORES + 1)
23
24 //128K stack.. compromise, want 10K virtPr
25 #define VIRT_PROCR_STACK_SIZE 0x100000
21 26
22 #define SUCCESS 0 27 #define SUCCESS 0
23 28
24 //#define thdAttrs NULL //For PThreads 29 //#define thdAttrs NULL //For PThreads
25 30
26 typedef struct _SchedSlot SchedSlot; 31 typedef struct _SchedSlot SchedSlot;
27 typedef struct _SlaveReqst SlaveReqst; 32 typedef struct _SlaveReqst VMSReqst;
28 typedef struct _VirtProcr VirtProcr; 33 typedef struct _VirtProcr VirtProcr;
29 34
30 typedef bool8 (*SlaveScheduler) ( SchedSlot *, void * ); 35 typedef VirtProcr * (*SlaveScheduler) ( void * ); //semEnv
31 typedef void (*RequestHandler) ( SlaveReqst * ); 36 typedef void (*RequestHandler) ( VirtProcr *, void * ); //prWReqst, semEnv
32 typedef void (*VirtProcrFnPtr) ( void *, VirtProcr * ); 37 typedef void (*VirtProcrFnPtr) ( void *, VirtProcr * ); //initData, animPr
33 typedef void VirtProcrFn( void *, VirtProcr * ); 38 typedef void VirtProcrFn ( void *, VirtProcr * ); //initData, animPr
34
35 39
36 typedef struct 40 typedef struct
37 { 41 {
38 void *endThdPt; 42 void *endThdPt;
39 unsigned int coreNum; 43 unsigned int coreNum;
49 int needsProcrAssigned; 53 int needsProcrAssigned;
50 VirtProcr *procrAssignedToSlot; 54 VirtProcr *procrAssignedToSlot;
51 }; 55 };
52 //SchedSlot 56 //SchedSlot
53 57
58 enum ReqstType
59 {
60 semantic = 1,
61 dissipate,
62 IO
63 };
54 64
55 struct _SlaveReqst 65 struct _SlaveReqst
56 { 66 {
57 VirtProcr *slaveFrom; 67 // VirtProcr *virtProcrFrom;
58 int reqType; //for future when have I/O and OS services 68 enum ReqstType reqType; //used for dissipate and in future for IO requests
59 void *semReqData; 69 void *semReqData;
60 70
61 SlaveReqst *nextRequest; 71 VMSReqst *nextReqst;
62 }; 72 };
63 //SlaveReqst 73 //SlaveReqst
64 74
65 struct _VirtProcr 75 struct _VirtProcr
66 { int procrID; //for debugging -- count up each time create 76 { int procrID; //for debugging -- count up each time create
67 int coreAnimatedBy; 77 int coreAnimatedBy;
78 void *startOfStack;
68 void *stackPtr; 79 void *stackPtr;
69 void *framePtr; 80 void *framePtr;
70 void *nextInstrPt; 81 void *nextInstrPt;
71 82
72 void *coreLoopStartPt; //allows proto-runtime to be linked later 83 void *coreLoopStartPt; //allows proto-runtime to be linked later
74 void *coreLoopStackPtr; //restore before jmp back to core loop 85 void *coreLoopStackPtr; //restore before jmp back to core loop
75 86
76 void *initialData; 87 void *initialData;
77 88
78 SchedSlot *schedSlot; 89 SchedSlot *schedSlot;
79 SlaveReqst *requests; 90 VMSReqst *requests;
80 91
81 void *semanticData; 92 void *semanticData;
82 }; 93 };
83 //VirtProcr 94 //VirtProcr
84 95
134 VMS__start(); 145 VMS__start();
135 146
136 VirtProcr * 147 VirtProcr *
137 VMS__create_procr( VirtProcrFnPtr fnPtr, void *initialData ); 148 VMS__create_procr( VirtProcrFnPtr fnPtr, void *initialData );
138 149
150 VirtProcr *
151 VMS__create_the_shutdown_procr();
152
139 inline void 153 inline void
140 VMS__send_sem_request( void *semReqData, VirtProcr *callingPr ); 154 VMS__send_sem_request( void *semReqData, VirtProcr *callingPr );
141 155
142 void 156 void
143 VMS__suspend_processor( VirtProcr *callingPr ); 157 VMS__send_dissipate_request( VirtProcr *procrToDissipate );
158
159 void
160 VMS__remove_and_free_top_request( VirtProcr *reqstingPr );
161
162 void
163 VMS__suspend_procr( VirtProcr *callingPr );
164
165 void
166 VMS__dissipate_procr( VirtProcr *prToDissipate );
167
168 void
169 VMS__shutdown();
144 170
145 //============================= Statistics ================================== 171 //============================= Statistics ==================================
146 172
147 typedef unsigned long long TSCount; 173 typedef unsigned long long TSCount;
148 174
155 /* clobber */ : "%eax", "%edx" \ 181 /* clobber */ : "%eax", "%edx" \
156 ); 182 );
157 183
158 inline TSCount getTSCount(); 184 inline TSCount getTSCount();
159 185
186 //===================== Debug ==========================
160 int numProcrsCreated; 187 int numProcrsCreated;
188
161 189
162 #endif /* _VMS_H */ 190 #endif /* _VMS_H */
163 191