rev |
line source |
seanhalle@64
|
1 /*
|
seanhalle@64
|
2 * Copyright 2010 OpenSourceCodeStewardshipFoundation
|
seanhalle@64
|
3 *
|
seanhalle@64
|
4 * Licensed under BSD
|
seanhalle@64
|
5 */
|
seanhalle@64
|
6
|
seanhalle@64
|
7 #include <stdio.h>
|
seanhalle@64
|
8 #include <stdlib.h>
|
seanhalle@64
|
9 #include <malloc.h>
|
seanhalle@64
|
10
|
seanhalle@64
|
11 #include "Queue_impl/PrivateQueue.h"
|
seanhalle@64
|
12 #include "Hash_impl/PrivateHash.h"
|
seanhalle@64
|
13
|
seanhalle@64
|
14 #include "SSR.h"
|
seanhalle@64
|
15 #include "SSR_Counter_Recording.h"
|
seanhalle@64
|
16
|
seanhalle@64
|
17 //==========================================================================
|
seanhalle@64
|
18
|
seanhalle@64
|
19 void
|
seanhalle@64
|
20 SSR__init();
|
seanhalle@64
|
21
|
seanhalle@64
|
22 void
|
seanhalle@64
|
23 SSR__init_Helper();
|
seanhalle@64
|
24 //==========================================================================
|
seanhalle@64
|
25
|
seanhalle@64
|
26
|
seanhalle@64
|
27 /*TODO: Q: dealing with library f()s and DKU vs WT vs FoR
|
seanhalle@64
|
28 * (still want to do FoR, with time-lines as syntax, could be super cool)
|
seanhalle@64
|
29 * A: thinking pin the coreCtlrs for all of BLIS -- let Master arbitrate
|
seanhalle@64
|
30 * among library, DKU, WT, FoR -- all the patterns in terms of virtual
|
seanhalle@64
|
31 * processors (or equivalently work-units), so Master picks which virt procr
|
seanhalle@67
|
32 * from which portions of app (DKU, WT, FoR) onto which anim slots
|
seanhalle@67
|
33 *Might even do hierarchy of masters -- group of anim slots for each core
|
seanhalle@64
|
34 * has its own master, that keeps generated work local
|
seanhalle@64
|
35 * single-reader-single-writer sync everywhere -- no atomic primitives
|
seanhalle@64
|
36 * Might have the different assigners talk to each other, to negotiate
|
seanhalle@64
|
37 * larger-grain sharing of resources, according to predicted critical
|
seanhalle@64
|
38 * path, and expansion of work
|
seanhalle@64
|
39 */
|
seanhalle@64
|
40
|
seanhalle@64
|
41
|
seanhalle@64
|
42
|
seanhalle@64
|
43 //===========================================================================
|
seanhalle@64
|
44
|
seanhalle@64
|
45
|
seanhalle@64
|
46 /*These are the library functions *called in the application*
|
seanhalle@64
|
47 *
|
seanhalle@64
|
48 *There's a pattern for the outside sequential code to interact with the
|
seanhalle@64
|
49 * VMS_HW code.
|
seanhalle@64
|
50 *The VMS_HW system is inside a boundary.. every SSR system is in its
|
seanhalle@64
|
51 * own directory that contains the functions for each of the processor types.
|
seanhalle@64
|
52 * One of the processor types is the "seed" processor that starts the
|
seanhalle@64
|
53 * cascade of creating all the processors that do the work.
|
seanhalle@64
|
54 *So, in the directory is a file called "EntryPoint.c" that contains the
|
seanhalle@64
|
55 * function, named appropriately to the work performed, that the outside
|
seanhalle@64
|
56 * sequential code calls. This function follows a pattern:
|
seanhalle@64
|
57 *1) it calls SSR__init()
|
seanhalle@64
|
58 *2) it creates the initial data for the seed processor, which is passed
|
seanhalle@64
|
59 * in to the function
|
seanhalle@64
|
60 *3) it creates the seed SSR processor, with the data to start it with.
|
seanhalle@64
|
61 *4) it calls startSSRThenWaitUntilWorkDone
|
seanhalle@64
|
62 *5) it gets the returnValue from the transfer struc and returns that
|
seanhalle@64
|
63 * from the function
|
seanhalle@64
|
64 *
|
seanhalle@64
|
65 *For now, a new SSR system has to be created via SSR__init every
|
seanhalle@64
|
66 * time an entry point function is called -- later, might add letting the
|
seanhalle@64
|
67 * SSR system be created once, and let all the entry points just reuse
|
seanhalle@64
|
68 * it -- want to be as simple as possible now, and see by using what makes
|
seanhalle@64
|
69 * sense for later..
|
seanhalle@64
|
70 */
|
seanhalle@64
|
71
|
seanhalle@64
|
72
|
seanhalle@64
|
73
|
seanhalle@64
|
74 //===========================================================================
|
seanhalle@64
|
75
|
seanhalle@64
|
76 /*This is the "border crossing" function -- the thing that crosses from the
|
seanhalle@64
|
77 * outside world, into the VMS_HW world. It initializes and starts up the
|
seanhalle@64
|
78 * VMS system, then creates one processor from the specified function and
|
seanhalle@64
|
79 * puts it into the readyQ. From that point, that one function is resp.
|
seanhalle@64
|
80 * for creating all the other processors, that then create others, and so
|
seanhalle@64
|
81 * forth.
|
seanhalle@64
|
82 *When all the processors, including the seed, have dissipated, then this
|
seanhalle@64
|
83 * function returns. The results will have been written by side-effect via
|
seanhalle@64
|
84 * pointers read from, or written into initData.
|
seanhalle@64
|
85 *
|
seanhalle@64
|
86 *NOTE: no Threads should exist in the outside program that might touch
|
seanhalle@64
|
87 * any of the data reachable from initData passed in to here
|
seanhalle@64
|
88 */
|
seanhalle@64
|
89 void
|
seanhalle@64
|
90 SSR__create_seed_procr_and_do_work( TopLevelFnPtr fnPtr, void *initData )
|
seanhalle@64
|
91 { SSRSemEnv *semEnv;
|
seanhalle@64
|
92 SlaveVP *seedPr;
|
seanhalle@64
|
93
|
seanhalle@64
|
94 SSR__init(); //normal multi-thd
|
seanhalle@64
|
95
|
seanhalle@64
|
96 semEnv = _VMSMasterEnv->semanticEnv;
|
seanhalle@64
|
97
|
seanhalle@64
|
98 //SSR starts with one processor, which is put into initial environ,
|
seanhalle@64
|
99 // and which then calls create() to create more, thereby expanding work
|
seanhalle@64
|
100 seedPr = SSR__create_procr_helper( fnPtr, initData,
|
seanhalle@64
|
101 semEnv, semEnv->nextCoreToGetNewPr++ );
|
seanhalle@64
|
102
|
seanhalle@64
|
103 resume_slaveVP( seedPr, semEnv );
|
seanhalle@64
|
104
|
seanhalle@64
|
105 VMS_SS__start_the_work_then_wait_until_done(); //normal multi-thd
|
seanhalle@64
|
106
|
seanhalle@64
|
107 SSR__cleanup_after_shutdown();
|
seanhalle@64
|
108 }
|
seanhalle@64
|
109
|
seanhalle@64
|
110
|
seanhalle@64
|
111 int32
|
seanhalle@64
|
112 SSR__giveMinWorkUnitCycles( float32 percentOverhead )
|
seanhalle@64
|
113 {
|
seanhalle@64
|
114 return MIN_WORK_UNIT_CYCLES;
|
seanhalle@64
|
115 }
|
seanhalle@64
|
116
|
seanhalle@64
|
117 int32
|
seanhalle@64
|
118 SSR__giveIdealNumWorkUnits()
|
seanhalle@64
|
119 {
|
seanhalle@69
|
120 return NUM_ANIM_SLOTS * NUM_CORES;
|
seanhalle@64
|
121 }
|
seanhalle@64
|
122
|
seanhalle@64
|
123 int32
|
seanhalle@64
|
124 SSR__give_number_of_cores_to_schedule_onto()
|
seanhalle@64
|
125 {
|
seanhalle@64
|
126 return NUM_CORES;
|
seanhalle@64
|
127 }
|
seanhalle@64
|
128
|
seanhalle@64
|
129 /*For now, use TSC -- later, make these two macros with assembly that first
|
seanhalle@64
|
130 * saves jump point, and second jumps back several times to get reliable time
|
seanhalle@64
|
131 */
|
seanhalle@64
|
132 void
|
seanhalle@64
|
133 SSR__start_primitive()
|
seanhalle@64
|
134 { saveLowTimeStampCountInto( ((SSRSemEnv *)(_VMSMasterEnv->semanticEnv))->
|
seanhalle@64
|
135 primitiveStartTime );
|
seanhalle@64
|
136 }
|
seanhalle@64
|
137
|
seanhalle@64
|
138 /*Just quick and dirty for now -- make reliable later
|
seanhalle@64
|
139 * will want this to jump back several times -- to be sure cache is warm
|
seanhalle@64
|
140 * because don't want comm time included in calc-time measurement -- and
|
seanhalle@64
|
141 * also to throw out any "weird" values due to OS interrupt or TSC rollover
|
seanhalle@64
|
142 */
|
seanhalle@64
|
143 int32
|
seanhalle@64
|
144 SSR__end_primitive_and_give_cycles()
|
seanhalle@64
|
145 { int32 endTime, startTime;
|
seanhalle@64
|
146 //TODO: fix by repeating time-measurement
|
seanhalle@64
|
147 saveLowTimeStampCountInto( endTime );
|
seanhalle@64
|
148 startTime =((SSRSemEnv*)(_VMSMasterEnv->semanticEnv))->primitiveStartTime;
|
seanhalle@64
|
149 return (endTime - startTime);
|
seanhalle@64
|
150 }
|
seanhalle@64
|
151
|
seanhalle@64
|
152 //===========================================================================
|
seanhalle@64
|
153
|
seanhalle@64
|
154 /*Initializes all the data-structures for a SSR system -- but doesn't
|
seanhalle@64
|
155 * start it running yet!
|
seanhalle@64
|
156 *
|
seanhalle@64
|
157 *This runs in the main thread -- before VMS starts up
|
seanhalle@64
|
158 *
|
seanhalle@64
|
159 *This sets up the semantic layer over the VMS system
|
seanhalle@64
|
160 *
|
seanhalle@64
|
161 *First, calls VMS_Setup, then creates own environment, making it ready
|
seanhalle@64
|
162 * for creating the seed processor and then starting the work.
|
seanhalle@64
|
163 */
|
seanhalle@64
|
164 void
|
seanhalle@64
|
165 SSR__init()
|
seanhalle@64
|
166 {
|
seanhalle@64
|
167 VMS_SS__init();
|
seanhalle@64
|
168 //masterEnv, a global var, now is partially set up by init_VMS
|
seanhalle@64
|
169 // after this, have VMS_int__malloc and VMS_int__free available
|
seanhalle@64
|
170
|
seanhalle@64
|
171 SSR__init_Helper();
|
seanhalle@64
|
172 }
|
seanhalle@64
|
173
|
seanhalle@64
|
174
|
seanhalle@64
|
175 void idle_fn(void* data, SlaveVP *animatingSlv){
|
seanhalle@64
|
176 while(1){
|
seanhalle@64
|
177 VMS_int__suspend_slaveVP_and_send_req(animatingSlv);
|
seanhalle@64
|
178 }
|
seanhalle@64
|
179 }
|
seanhalle@64
|
180
|
seanhalle@64
|
181 void
|
seanhalle@64
|
182 SSR__init_Helper()
|
seanhalle@64
|
183 { SSRSemEnv *semanticEnv;
|
seanhalle@64
|
184 PrivQueueStruc **readyVPQs;
|
seanhalle@64
|
185 int coreIdx, i, j;
|
seanhalle@64
|
186
|
seanhalle@64
|
187 //Hook up the semantic layer's plug-ins to the Master virt procr
|
seanhalle@64
|
188 _VMSMasterEnv->requestHandler = &SSR__Request_Handler;
|
seanhalle@67
|
189 _VMSMasterEnv->slaveAssigner = &SSR__assign_slaveVP_to_slot;
|
seanhalle@64
|
190 #ifdef HOLISTIC__TURN_ON_PERF_COUNTERS
|
seanhalle@64
|
191 _VMSMasterEnv->counterHandler = &SSR__counter_handler;
|
seanhalle@64
|
192 #endif
|
seanhalle@64
|
193
|
seanhalle@64
|
194 //create the semantic layer's environment (all its data) and add to
|
seanhalle@64
|
195 // the master environment
|
seanhalle@64
|
196 semanticEnv = VMS_int__malloc( sizeof( SSRSemEnv ) );
|
seanhalle@64
|
197 _VMSMasterEnv->semanticEnv = semanticEnv;
|
seanhalle@64
|
198
|
seanhalle@64
|
199 #ifdef HOLISTIC__TURN_ON_PERF_COUNTERS
|
seanhalle@64
|
200 SSR__init_counter_data_structs();
|
seanhalle@64
|
201 #endif
|
nengel@72
|
202 #ifdef IDLE_SLAVES
|
nengel@66
|
203 semanticEnv->shutdownInitiated = FALSE;
|
seanhalle@64
|
204 for(i=0;i<NUM_CORES;++i){
|
seanhalle@69
|
205 for(j=0;j<NUM_ANIM_SLOTS;++j){
|
seanhalle@64
|
206 semanticEnv->idlePr[i][j] = VMS_int__create_slaveVP(&idle_fn,NULL);
|
seanhalle@64
|
207 semanticEnv->idlePr[i][j]->coreAnimatedBy = i;
|
nengel@72
|
208 semanticEnv->idlePr[i][j]->typeOfVP = Idle;
|
seanhalle@64
|
209 }
|
seanhalle@64
|
210 }
|
nengel@72
|
211 #endif
|
seanhalle@64
|
212 #ifdef HOLISTIC__TURN_ON_OBSERVE_UCC
|
seanhalle@64
|
213 semanticEnv->unitList = makeListOfArrays(sizeof(Unit),128);
|
seanhalle@64
|
214 semanticEnv->ctlDependenciesList = makeListOfArrays(sizeof(Dependency),128);
|
seanhalle@64
|
215 semanticEnv->commDependenciesList = makeListOfArrays(sizeof(Dependency),128);
|
seanhalle@64
|
216 semanticEnv->dynDependenciesList = makeListOfArrays(sizeof(Dependency),128);
|
nengel@74
|
217 semanticEnv->singletonDependenciesList = makeListOfArrays(sizeof(Dependency),128);
|
seanhalle@64
|
218 semanticEnv->ntonGroupsInfo = makePrivDynArrayOfSize((void***)&(semanticEnv->ntonGroups),8);
|
seanhalle@64
|
219
|
seanhalle@64
|
220 semanticEnv->hwArcs = makeListOfArrays(sizeof(Dependency),128);
|
seanhalle@69
|
221 memset(semanticEnv->last_in_slot,0,sizeof(NUM_CORES * NUM_ANIM_SLOTS * sizeof(Unit)));
|
seanhalle@64
|
222 #endif
|
seanhalle@64
|
223
|
seanhalle@64
|
224 //create the ready queue, hash tables used for pairing send to receive
|
seanhalle@64
|
225 // and so forth
|
seanhalle@64
|
226 //TODO: add hash tables for pairing sends with receives, and
|
seanhalle@64
|
227 // initialize the data ownership system
|
seanhalle@64
|
228 readyVPQs = VMS_int__malloc( NUM_CORES * sizeof(PrivQueueStruc *) );
|
seanhalle@64
|
229
|
seanhalle@64
|
230 for( coreIdx = 0; coreIdx < NUM_CORES; coreIdx++ )
|
seanhalle@64
|
231 {
|
seanhalle@64
|
232 readyVPQs[ coreIdx ] = makeVMSQ();
|
seanhalle@64
|
233 }
|
seanhalle@64
|
234
|
seanhalle@64
|
235 semanticEnv->readyVPQs = readyVPQs;
|
seanhalle@64
|
236
|
seanhalle@64
|
237 semanticEnv->nextCoreToGetNewPr = 0;
|
seanhalle@64
|
238 semanticEnv->numSlaveVP = 0;
|
seanhalle@64
|
239
|
seanhalle@64
|
240 semanticEnv->commHashTbl = makeHashTable( 1<<16, &VMS_int__free );//start big
|
seanhalle@64
|
241
|
seanhalle@64
|
242 //TODO: bug -- turn these arrays into dyn arrays to eliminate limit
|
seanhalle@64
|
243 //semanticEnv->singletonHasBeenExecutedFlags = makeDynArrayInfo( );
|
seanhalle@64
|
244 //semanticEnv->transactionStrucs = makeDynArrayInfo( );
|
seanhalle@64
|
245 for( i = 0; i < NUM_STRUCS_IN_SEM_ENV; i++ )
|
seanhalle@64
|
246 {
|
seanhalle@64
|
247 semanticEnv->fnSingletons[i].endInstrAddr = NULL;
|
seanhalle@64
|
248 semanticEnv->fnSingletons[i].hasBeenStarted = FALSE;
|
seanhalle@64
|
249 semanticEnv->fnSingletons[i].hasFinished = FALSE;
|
seanhalle@64
|
250 semanticEnv->fnSingletons[i].waitQ = makeVMSQ();
|
seanhalle@64
|
251 semanticEnv->transactionStrucs[i].waitingVPQ = makeVMSQ();
|
seanhalle@64
|
252 }
|
seanhalle@64
|
253 }
|
seanhalle@64
|
254
|
seanhalle@64
|
255
|
seanhalle@64
|
256 /*Frees any memory allocated by SSR__init() then calls VMS_int__shutdown
|
seanhalle@64
|
257 */
|
seanhalle@64
|
258 void
|
seanhalle@64
|
259 SSR__cleanup_after_shutdown()
|
seanhalle@64
|
260 { SSRSemEnv *semanticEnv;
|
seanhalle@64
|
261
|
seanhalle@64
|
262 semanticEnv = _VMSMasterEnv->semanticEnv;
|
seanhalle@64
|
263
|
seanhalle@64
|
264 #ifdef HOLISTIC__TURN_ON_OBSERVE_UCC
|
seanhalle@64
|
265 //UCC
|
seanhalle@64
|
266 FILE* output;
|
seanhalle@64
|
267 int n;
|
seanhalle@64
|
268 char filename[255];
|
seanhalle@64
|
269 for(n=0;n<255;n++)
|
seanhalle@64
|
270 {
|
seanhalle@64
|
271 sprintf(filename, "./counters/UCC.%d",n);
|
seanhalle@64
|
272 output = fopen(filename,"r");
|
seanhalle@64
|
273 if(output)
|
seanhalle@64
|
274 {
|
seanhalle@64
|
275 fclose(output);
|
seanhalle@64
|
276 }else{
|
seanhalle@64
|
277 break;
|
seanhalle@64
|
278 }
|
seanhalle@64
|
279 }
|
seanhalle@64
|
280 if(n<255){
|
seanhalle@64
|
281 printf("Saving UCC to File: %s ...\n", filename);
|
seanhalle@64
|
282 output = fopen(filename,"w+");
|
seanhalle@64
|
283 if(output!=NULL){
|
seanhalle@64
|
284 set_dependency_file(output);
|
seanhalle@64
|
285 //fprintf(output,"digraph Dependencies {\n");
|
seanhalle@64
|
286 //set_dot_file(output);
|
seanhalle@64
|
287 //FIXME: first line still depends on counters being enabled, replace w/ unit struct!
|
seanhalle@64
|
288 //forAllInDynArrayDo(_VMSMasterEnv->counter_history_array_info, &print_dot_node_info );
|
seanhalle@64
|
289 forAllInListOfArraysDo(semanticEnv->unitList, &print_unit_to_file);
|
seanhalle@64
|
290 forAllInListOfArraysDo( semanticEnv->commDependenciesList, &print_comm_dependency_to_file );
|
seanhalle@64
|
291 forAllInListOfArraysDo( semanticEnv->ctlDependenciesList, &print_ctl_dependency_to_file );
|
seanhalle@64
|
292 forAllInDynArrayDo(semanticEnv->ntonGroupsInfo,&print_nton_to_file);
|
seanhalle@64
|
293 //fprintf(output,"}\n");
|
seanhalle@64
|
294 fflush(output);
|
seanhalle@64
|
295
|
seanhalle@64
|
296 } else
|
seanhalle@64
|
297 printf("Opening UCC file failed. Please check that folder \"counters\" exists in run directory and has write permission.\n");
|
seanhalle@64
|
298 } else {
|
seanhalle@64
|
299 printf("Could not open UCC file, please clean \"counters\" folder. (Must contain less than 255 files.)\n");
|
seanhalle@64
|
300 }
|
seanhalle@64
|
301 //Loop Graph
|
seanhalle@64
|
302 for(n=0;n<255;n++)
|
seanhalle@64
|
303 {
|
seanhalle@64
|
304 sprintf(filename, "./counters/LoopGraph.%d",n);
|
seanhalle@64
|
305 output = fopen(filename,"r");
|
seanhalle@64
|
306 if(output)
|
seanhalle@64
|
307 {
|
seanhalle@64
|
308 fclose(output);
|
seanhalle@64
|
309 }else{
|
seanhalle@64
|
310 break;
|
seanhalle@64
|
311 }
|
seanhalle@64
|
312 }
|
seanhalle@64
|
313 if(n<255){
|
seanhalle@64
|
314 printf("Saving LoopGraph to File: %s ...\n", filename);
|
seanhalle@64
|
315 output = fopen(filename,"w+");
|
seanhalle@64
|
316 if(output!=NULL){
|
seanhalle@64
|
317 set_dependency_file(output);
|
seanhalle@64
|
318 //fprintf(output,"digraph Dependencies {\n");
|
seanhalle@64
|
319 //set_dot_file(output);
|
seanhalle@64
|
320 //FIXME: first line still depends on counters being enabled, replace w/ unit struct!
|
seanhalle@64
|
321 //forAllInDynArrayDo(_VMSMasterEnv->counter_history_array_info, &print_dot_node_info );
|
seanhalle@64
|
322 forAllInListOfArraysDo( semanticEnv->unitList, &print_unit_to_file );
|
seanhalle@64
|
323 forAllInListOfArraysDo( semanticEnv->commDependenciesList, &print_comm_dependency_to_file );
|
seanhalle@64
|
324 forAllInListOfArraysDo( semanticEnv->ctlDependenciesList, &print_ctl_dependency_to_file );
|
seanhalle@64
|
325 forAllInListOfArraysDo( semanticEnv->dynDependenciesList, &print_dyn_dependency_to_file );
|
nengel@74
|
326 forAllInListOfArraysDo( semanticEnv->singletonDependenciesList, &print_singleton_dependency_to_file );
|
seanhalle@64
|
327 forAllInListOfArraysDo( semanticEnv->hwArcs, &print_hw_dependency_to_file );
|
seanhalle@64
|
328 //fprintf(output,"}\n");
|
seanhalle@64
|
329 fflush(output);
|
seanhalle@64
|
330
|
seanhalle@64
|
331 } else
|
seanhalle@64
|
332 printf("Opening LoopGraph file failed. Please check that folder \"counters\" exists in run directory and has write permission.\n");
|
seanhalle@64
|
333 } else {
|
seanhalle@64
|
334 printf("Could not open LoopGraph file, please clean \"counters\" folder. (Must contain less than 255 files.)\n");
|
seanhalle@64
|
335 }
|
seanhalle@64
|
336
|
seanhalle@64
|
337
|
seanhalle@64
|
338 freeListOfArrays(semanticEnv->unitList);
|
seanhalle@64
|
339 freeListOfArrays(semanticEnv->commDependenciesList);
|
seanhalle@64
|
340 freeListOfArrays(semanticEnv->ctlDependenciesList);
|
seanhalle@64
|
341 freeListOfArrays(semanticEnv->dynDependenciesList);
|
nengel@74
|
342 freeListOfArrays(semanticEnv->singletonDependenciesList);
|
seanhalle@64
|
343 #endif
|
seanhalle@64
|
344 #ifdef HOLISTIC__TURN_ON_PERF_COUNTERS
|
seanhalle@64
|
345 for(n=0;n<255;n++)
|
seanhalle@64
|
346 {
|
seanhalle@64
|
347 sprintf(filename, "./counters/Counters.%d.csv",n);
|
seanhalle@64
|
348 output = fopen(filename,"r");
|
seanhalle@64
|
349 if(output)
|
seanhalle@64
|
350 {
|
seanhalle@64
|
351 fclose(output);
|
seanhalle@64
|
352 }else{
|
seanhalle@64
|
353 break;
|
seanhalle@64
|
354 }
|
seanhalle@64
|
355 }
|
seanhalle@64
|
356 if(n<255){
|
seanhalle@64
|
357 printf("Saving Counter measurements to File: %s ...\n", filename);
|
seanhalle@64
|
358 output = fopen(filename,"w+");
|
seanhalle@64
|
359 if(output!=NULL){
|
seanhalle@64
|
360 set_counter_file(output);
|
seanhalle@64
|
361 int i;
|
seanhalle@64
|
362 for(i=0;i<NUM_CORES;i++){
|
seanhalle@64
|
363 forAllInListOfArraysDo( semanticEnv->counterList[i], &print_counter_events_to_file );
|
seanhalle@64
|
364 fflush(output);
|
seanhalle@64
|
365 }
|
seanhalle@64
|
366
|
seanhalle@64
|
367 } else
|
seanhalle@64
|
368 printf("Opening UCC file failed. Please check that folder \"counters\" exists in run directory and has write permission.\n");
|
seanhalle@64
|
369 } else {
|
seanhalle@64
|
370 printf("Could not open UCC file, please clean \"counters\" folder. (Must contain less than 255 files.)\n");
|
seanhalle@64
|
371 }
|
seanhalle@64
|
372
|
seanhalle@64
|
373 #endif
|
seanhalle@64
|
374 /* It's all allocated inside VMS's big chunk -- that's about to be freed, so
|
seanhalle@64
|
375 * nothing to do here
|
seanhalle@64
|
376
|
seanhalle@64
|
377
|
seanhalle@64
|
378 for( coreIdx = 0; coreIdx < NUM_CORES; coreIdx++ )
|
seanhalle@64
|
379 {
|
seanhalle@64
|
380 VMS_int__free( semanticEnv->readyVPQs[coreIdx]->startOfData );
|
seanhalle@64
|
381 VMS_int__free( semanticEnv->readyVPQs[coreIdx] );
|
seanhalle@64
|
382 }
|
seanhalle@64
|
383 VMS_int__free( semanticEnv->readyVPQs );
|
seanhalle@64
|
384
|
seanhalle@64
|
385 freeHashTable( semanticEnv->commHashTbl );
|
seanhalle@64
|
386 VMS_int__free( _VMSMasterEnv->semanticEnv );
|
seanhalle@64
|
387 */
|
seanhalle@64
|
388 VMS_SS__cleanup_at_end_of_shutdown();
|
seanhalle@64
|
389 }
|
seanhalle@64
|
390
|
seanhalle@64
|
391
|
seanhalle@64
|
392 //===========================================================================
|
seanhalle@64
|
393
|
seanhalle@64
|
394 /*
|
seanhalle@64
|
395 */
|
seanhalle@64
|
396 SlaveVP *
|
seanhalle@64
|
397 SSR__create_procr_with( TopLevelFnPtr fnPtr, void *initData,
|
seanhalle@64
|
398 SlaveVP *creatingPr )
|
seanhalle@64
|
399 { SSRSemReq reqData;
|
seanhalle@64
|
400
|
seanhalle@64
|
401 //the semantic request data is on the stack and disappears when this
|
seanhalle@64
|
402 // call returns -- it's guaranteed to remain in the VP's stack for as
|
seanhalle@64
|
403 // long as the VP is suspended.
|
seanhalle@64
|
404 reqData.reqType = 0; //know type because in a VMS create req
|
seanhalle@64
|
405 reqData.coreToAssignOnto = -1; //means round-robin assign
|
seanhalle@64
|
406 reqData.fnPtr = fnPtr;
|
seanhalle@64
|
407 reqData.initData = initData;
|
seanhalle@64
|
408 reqData.sendPr = creatingPr;
|
seanhalle@64
|
409
|
seanhalle@64
|
410 VMS_WL__send_create_slaveVP_req( &reqData, creatingPr );
|
seanhalle@64
|
411
|
seanhalle@64
|
412 return creatingPr->dataRetFromReq;
|
seanhalle@64
|
413 }
|
seanhalle@64
|
414
|
seanhalle@64
|
415 SlaveVP *
|
seanhalle@64
|
416 SSR__create_procr_with_affinity( TopLevelFnPtr fnPtr, void *initData,
|
seanhalle@64
|
417 SlaveVP *creatingPr, int32 coreToAssignOnto )
|
seanhalle@64
|
418 { SSRSemReq reqData;
|
seanhalle@64
|
419
|
seanhalle@64
|
420 //the semantic request data is on the stack and disappears when this
|
seanhalle@64
|
421 // call returns -- it's guaranteed to remain in the VP's stack for as
|
seanhalle@64
|
422 // long as the VP is suspended.
|
seanhalle@64
|
423 reqData.reqType = 0; //know type because in a VMS create req
|
seanhalle@64
|
424 reqData.coreToAssignOnto = coreToAssignOnto;
|
seanhalle@64
|
425 reqData.fnPtr = fnPtr;
|
seanhalle@64
|
426 reqData.initData = initData;
|
seanhalle@64
|
427 reqData.sendPr = creatingPr;
|
seanhalle@64
|
428
|
seanhalle@64
|
429 VMS_WL__send_create_slaveVP_req( &reqData, creatingPr );
|
seanhalle@64
|
430
|
seanhalle@64
|
431 return creatingPr->dataRetFromReq;
|
seanhalle@64
|
432 }
|
seanhalle@64
|
433
|
seanhalle@64
|
434
|
seanhalle@64
|
435 void
|
seanhalle@64
|
436 SSR__dissipate_procr( SlaveVP *procrToDissipate )
|
seanhalle@64
|
437 {
|
seanhalle@64
|
438 VMS_WL__send_dissipate_req( procrToDissipate );
|
seanhalle@64
|
439 }
|
seanhalle@64
|
440
|
seanhalle@64
|
441
|
seanhalle@64
|
442 //===========================================================================
|
seanhalle@64
|
443
|
seanhalle@64
|
444 void *
|
seanhalle@64
|
445 SSR__malloc_to( int32 sizeToMalloc, SlaveVP *owningPr )
|
seanhalle@64
|
446 { SSRSemReq reqData;
|
seanhalle@64
|
447
|
seanhalle@64
|
448 reqData.reqType = malloc_req;
|
seanhalle@64
|
449 reqData.sendPr = owningPr;
|
seanhalle@64
|
450 reqData.sizeToMalloc = sizeToMalloc;
|
seanhalle@64
|
451
|
seanhalle@64
|
452 VMS_WL__send_sem_request( &reqData, owningPr );
|
seanhalle@64
|
453
|
seanhalle@64
|
454 return owningPr->dataRetFromReq;
|
seanhalle@64
|
455 }
|
seanhalle@64
|
456
|
seanhalle@64
|
457
|
seanhalle@64
|
458 /*Sends request to Master, which does the work of freeing
|
seanhalle@64
|
459 */
|
seanhalle@64
|
460 void
|
seanhalle@64
|
461 SSR__free( void *ptrToFree, SlaveVP *owningPr )
|
seanhalle@64
|
462 { SSRSemReq reqData;
|
seanhalle@64
|
463
|
seanhalle@64
|
464 reqData.reqType = free_req;
|
seanhalle@64
|
465 reqData.sendPr = owningPr;
|
seanhalle@64
|
466 reqData.ptrToFree = ptrToFree;
|
seanhalle@64
|
467
|
seanhalle@64
|
468 VMS_WL__send_sem_request( &reqData, owningPr );
|
seanhalle@64
|
469 }
|
seanhalle@64
|
470
|
seanhalle@64
|
471
|
seanhalle@64
|
472 void
|
seanhalle@64
|
473 SSR__transfer_ownership_of_from_to( void *data, SlaveVP *oldOwnerSlv,
|
seanhalle@64
|
474 SlaveVP *newOwnerPr )
|
seanhalle@64
|
475 {
|
seanhalle@64
|
476 //TODO: put in the ownership system that automatically frees when no
|
seanhalle@64
|
477 // owners of data left -- will need keeper for keeping data around when
|
seanhalle@64
|
478 // future created processors might need it but don't exist yet
|
seanhalle@64
|
479 }
|
seanhalle@64
|
480
|
seanhalle@64
|
481
|
seanhalle@64
|
482 void
|
seanhalle@64
|
483 SSR__add_ownership_by_to( SlaveVP *newOwnerSlv, void *data )
|
seanhalle@64
|
484 {
|
seanhalle@64
|
485
|
seanhalle@64
|
486 }
|
seanhalle@64
|
487
|
seanhalle@64
|
488
|
seanhalle@64
|
489 void
|
seanhalle@64
|
490 SSR__remove_ownership_by_from( SlaveVP *loserSlv, void *dataLosing )
|
seanhalle@64
|
491 {
|
seanhalle@64
|
492
|
seanhalle@64
|
493 }
|
seanhalle@64
|
494
|
seanhalle@64
|
495
|
seanhalle@64
|
496 /*Causes the SSR system to remove internal ownership, so data won't be
|
seanhalle@64
|
497 * freed when SSR shuts down, and will persist in the external program.
|
seanhalle@64
|
498 *
|
seanhalle@64
|
499 *Must be called from the processor that currently owns the data.
|
seanhalle@64
|
500 *
|
seanhalle@64
|
501 *IMPL: Transferring ownership touches two different virtual processor's
|
seanhalle@64
|
502 * state -- which means it has to be done carefully -- the VMS rules for
|
seanhalle@64
|
503 * semantic layers say that a work-unit is only allowed to touch the
|
seanhalle@64
|
504 * virtual processor it is part of, and that only a single work-unit per
|
seanhalle@64
|
505 * virtual processor be assigned to a slave at a time. So, this has to
|
seanhalle@64
|
506 * modify the virtual processor that owns the work-unit that called this
|
seanhalle@64
|
507 * function, then create a request to have the other processor modified.
|
seanhalle@64
|
508 *However, in this case, the TO processor is the outside, and transfers
|
seanhalle@64
|
509 * are only allowed to be called by the giver-upper, so can mark caller of
|
seanhalle@64
|
510 * this function as no longer owner, and return -- done.
|
seanhalle@64
|
511 */
|
seanhalle@64
|
512 void
|
seanhalle@64
|
513 SSR__transfer_ownership_to_outside( void *data )
|
seanhalle@64
|
514 {
|
seanhalle@64
|
515 //TODO: removeAllOwnersFrom( data );
|
seanhalle@64
|
516 }
|
seanhalle@64
|
517
|
seanhalle@64
|
518
|
seanhalle@64
|
519 //===========================================================================
|
seanhalle@64
|
520
|
seanhalle@64
|
521 void
|
seanhalle@64
|
522 SSR__send_of_type_to( SlaveVP *sendPr, void *msg, const int type,
|
seanhalle@64
|
523 SlaveVP *receivePr)
|
seanhalle@64
|
524 { SSRSemReq reqData;
|
seanhalle@64
|
525
|
seanhalle@64
|
526 reqData.receivePr = receivePr;
|
seanhalle@64
|
527 reqData.sendPr = sendPr;
|
seanhalle@64
|
528 reqData.reqType = send_type;
|
seanhalle@64
|
529 reqData.msgType = type;
|
seanhalle@64
|
530 reqData.msg = msg;
|
seanhalle@64
|
531 reqData.nextReqInHashEntry = NULL;
|
seanhalle@64
|
532
|
seanhalle@64
|
533 //On ownership -- remove inside the send and let ownership sit in limbo
|
seanhalle@64
|
534 // as a potential in an entry in the hash table, when this receive msg
|
seanhalle@64
|
535 // gets paired to a send, the ownership gets added to the receivePr --
|
seanhalle@64
|
536 // the next work-unit in the receivePr's trace will have ownership.
|
seanhalle@64
|
537 VMS_WL__send_sem_request( &reqData, sendPr );
|
seanhalle@64
|
538
|
seanhalle@64
|
539 //When come back from suspend, no longer own data reachable from msg
|
seanhalle@64
|
540 //TODO: release ownership here
|
seanhalle@64
|
541 }
|
seanhalle@64
|
542
|
seanhalle@64
|
543 void
|
seanhalle@64
|
544 SSR__send_from_to( void *msg, SlaveVP *sendPr, SlaveVP *receivePr )
|
seanhalle@64
|
545 { SSRSemReq reqData;
|
seanhalle@64
|
546
|
seanhalle@64
|
547 //hash on the receiver, 'cause always know it, but sometimes want to
|
seanhalle@64
|
548 // receive from anonymous sender
|
seanhalle@64
|
549
|
seanhalle@64
|
550 reqData.receivePr = receivePr;
|
seanhalle@64
|
551 reqData.sendPr = sendPr;
|
seanhalle@64
|
552 reqData.reqType = send_from_to;
|
seanhalle@64
|
553 reqData.msg = msg;
|
seanhalle@64
|
554 reqData.nextReqInHashEntry = NULL;
|
seanhalle@64
|
555
|
seanhalle@64
|
556 VMS_WL__send_sem_request( &reqData, sendPr );
|
seanhalle@64
|
557 }
|
seanhalle@64
|
558
|
seanhalle@64
|
559
|
seanhalle@64
|
560 //===========================================================================
|
seanhalle@64
|
561
|
seanhalle@64
|
562 void *
|
seanhalle@64
|
563 SSR__receive_any_to( SlaveVP *receivePr )
|
seanhalle@64
|
564 {
|
seanhalle@64
|
565
|
seanhalle@64
|
566 }
|
seanhalle@64
|
567
|
seanhalle@64
|
568 void *
|
seanhalle@64
|
569 SSR__receive_type_to( const int type, SlaveVP *receivePr )
|
seanhalle@67
|
570 { DEBUG__printf1(dbgRqstHdlr,"WL: receive type to: %d", receivePr->slaveID);
|
seanhalle@64
|
571 SSRSemReq reqData;
|
seanhalle@64
|
572
|
seanhalle@64
|
573 reqData.receivePr = receivePr;
|
seanhalle@64
|
574 reqData.reqType = receive_type;
|
seanhalle@64
|
575 reqData.msgType = type;
|
seanhalle@64
|
576 reqData.nextReqInHashEntry = NULL;
|
seanhalle@64
|
577
|
seanhalle@64
|
578 VMS_WL__send_sem_request( &reqData, receivePr );
|
seanhalle@64
|
579
|
seanhalle@64
|
580 return receivePr->dataRetFromReq;
|
seanhalle@64
|
581 }
|
seanhalle@64
|
582
|
seanhalle@64
|
583
|
seanhalle@64
|
584
|
seanhalle@64
|
585 /*Call this at point receiving virt pr wants in-coming data.
|
seanhalle@64
|
586 *
|
seanhalle@64
|
587 *The reason receivePr must call this is that it modifies the receivPr
|
seanhalle@64
|
588 * loc structure directly -- and the VMS rules state a virtual processor
|
seanhalle@64
|
589 * loc structure can only be modified by itself.
|
seanhalle@64
|
590 */
|
seanhalle@64
|
591 void *
|
seanhalle@64
|
592 SSR__receive_from_to( SlaveVP *sendPr, SlaveVP *receivePr )
|
seanhalle@67
|
593 { DEBUG__printf2(dbgRqstHdlr,"WL: receive from %d to: %d", sendPr->slaveID, receivePr->slaveID);
|
seanhalle@67
|
594 SSRSemReq reqData;
|
seanhalle@64
|
595
|
seanhalle@64
|
596 //hash on the receiver, 'cause always know it, but sometimes want to
|
seanhalle@64
|
597 // receive from anonymous sender
|
seanhalle@64
|
598
|
seanhalle@64
|
599 reqData.receivePr = receivePr;
|
seanhalle@64
|
600 reqData.sendPr = sendPr;
|
seanhalle@64
|
601 reqData.reqType = receive_from_to;
|
seanhalle@64
|
602 reqData.nextReqInHashEntry = NULL;
|
seanhalle@64
|
603
|
seanhalle@64
|
604 VMS_WL__send_sem_request( &reqData, receivePr );
|
seanhalle@64
|
605
|
seanhalle@64
|
606 return receivePr->dataRetFromReq;
|
seanhalle@64
|
607 }
|
seanhalle@64
|
608
|
seanhalle@64
|
609
|
seanhalle@64
|
610 //===========================================================================
|
seanhalle@64
|
611 //
|
seanhalle@64
|
612 /*A function singleton is a function whose body executes exactly once, on a
|
seanhalle@64
|
613 * single core, no matter how many times the fuction is called and no
|
seanhalle@64
|
614 * matter how many cores or the timing of cores calling it.
|
seanhalle@64
|
615 *
|
seanhalle@64
|
616 *A data singleton is a ticket attached to data. That ticket can be used
|
seanhalle@64
|
617 * to get the data through the function exactly once, no matter how many
|
seanhalle@64
|
618 * times the data is given to the function, and no matter the timing of
|
seanhalle@64
|
619 * trying to get the data through from different cores.
|
seanhalle@64
|
620 */
|
seanhalle@64
|
621
|
seanhalle@64
|
622 /*asm function declarations*/
|
seanhalle@64
|
623 void asm_save_ret_to_singleton(SSRSingleton *singletonPtrAddr);
|
seanhalle@64
|
624 void asm_write_ret_from_singleton(SSRSingleton *singletonPtrAddr);
|
seanhalle@64
|
625
|
seanhalle@64
|
626 /*Fn singleton uses ID as index into array of singleton structs held in the
|
seanhalle@64
|
627 * semantic environment.
|
seanhalle@64
|
628 */
|
seanhalle@64
|
629 void
|
seanhalle@64
|
630 SSR__start_fn_singleton( int32 singletonID, SlaveVP *animPr )
|
seanhalle@64
|
631 {
|
seanhalle@64
|
632 SSRSemReq reqData;
|
seanhalle@64
|
633
|
seanhalle@64
|
634 //
|
seanhalle@64
|
635 reqData.reqType = singleton_fn_start;
|
seanhalle@64
|
636 reqData.singletonID = singletonID;
|
seanhalle@64
|
637
|
seanhalle@64
|
638 VMS_WL__send_sem_request( &reqData, animPr );
|
seanhalle@64
|
639 if( animPr->dataRetFromReq ) //will be 0 or addr of label in end singleton
|
seanhalle@64
|
640 {
|
seanhalle@64
|
641 SSRSemEnv *semEnv = VMS_int__give_sem_env_for( animPr );
|
seanhalle@64
|
642 asm_write_ret_from_singleton(&(semEnv->fnSingletons[ singletonID]));
|
seanhalle@64
|
643 }
|
seanhalle@64
|
644 }
|
seanhalle@64
|
645
|
seanhalle@64
|
646 /*Data singleton hands addr of loc holding a pointer to a singleton struct.
|
seanhalle@64
|
647 * The start_data_singleton makes the structure and puts its addr into the
|
seanhalle@64
|
648 * location.
|
seanhalle@64
|
649 */
|
seanhalle@64
|
650 void
|
seanhalle@64
|
651 SSR__start_data_singleton( SSRSingleton **singletonAddr, SlaveVP *animPr )
|
seanhalle@64
|
652 {
|
seanhalle@64
|
653 SSRSemReq reqData;
|
seanhalle@64
|
654
|
seanhalle@64
|
655 if( *singletonAddr && (*singletonAddr)->hasFinished )
|
seanhalle@64
|
656 goto JmpToEndSingleton;
|
seanhalle@64
|
657
|
seanhalle@64
|
658 reqData.reqType = singleton_data_start;
|
seanhalle@64
|
659 reqData.singletonPtrAddr = singletonAddr;
|
seanhalle@64
|
660
|
seanhalle@64
|
661 VMS_WL__send_sem_request( &reqData, animPr );
|
seanhalle@64
|
662 if( animPr->dataRetFromReq ) //either 0 or end singleton's return addr
|
seanhalle@64
|
663 { //Assembly code changes the return addr on the stack to the one
|
seanhalle@64
|
664 // saved into the singleton by the end-singleton-fn
|
seanhalle@64
|
665 //The return addr is at 0x4(%%ebp)
|
seanhalle@64
|
666 JmpToEndSingleton:
|
seanhalle@64
|
667 asm_write_ret_from_singleton(*singletonAddr);
|
seanhalle@64
|
668 }
|
seanhalle@64
|
669 //now, simply return
|
seanhalle@64
|
670 //will exit either from the start singleton call or the end-singleton call
|
seanhalle@64
|
671 }
|
seanhalle@64
|
672
|
seanhalle@64
|
673 /*Uses ID as index into array of flags. If flag already set, resumes from
|
seanhalle@64
|
674 * end-label. Else, sets flag and resumes normally.
|
seanhalle@64
|
675 *
|
seanhalle@64
|
676 *Note, this call cannot be inlined because the instr addr at the label
|
seanhalle@64
|
677 * inside is shared by all invocations of a given singleton ID.
|
seanhalle@64
|
678 */
|
seanhalle@64
|
679 void
|
seanhalle@64
|
680 SSR__end_fn_singleton( int32 singletonID, SlaveVP *animPr )
|
seanhalle@64
|
681 {
|
seanhalle@64
|
682 SSRSemReq reqData;
|
seanhalle@64
|
683
|
seanhalle@64
|
684 //don't need this addr until after at least one singleton has reached
|
seanhalle@64
|
685 // this function
|
seanhalle@64
|
686 SSRSemEnv *semEnv = VMS_int__give_sem_env_for( animPr );
|
seanhalle@64
|
687 asm_write_ret_from_singleton(&(semEnv->fnSingletons[ singletonID]));
|
seanhalle@64
|
688
|
seanhalle@64
|
689 reqData.reqType = singleton_fn_end;
|
seanhalle@64
|
690 reqData.singletonID = singletonID;
|
seanhalle@64
|
691
|
seanhalle@64
|
692 VMS_WL__send_sem_request( &reqData, animPr );
|
seanhalle@64
|
693
|
seanhalle@64
|
694 EndSingletonInstrAddr:
|
seanhalle@64
|
695 return;
|
seanhalle@64
|
696 }
|
seanhalle@64
|
697
|
seanhalle@64
|
698 void
|
seanhalle@64
|
699 SSR__end_data_singleton( SSRSingleton **singletonPtrAddr, SlaveVP *animPr )
|
seanhalle@64
|
700 {
|
seanhalle@64
|
701 SSRSemReq reqData;
|
seanhalle@64
|
702
|
seanhalle@64
|
703 //don't need this addr until after singleton struct has reached
|
seanhalle@64
|
704 // this function for first time
|
seanhalle@64
|
705 //do assembly that saves the return addr of this fn call into the
|
seanhalle@64
|
706 // data singleton -- that data-singleton can only be given to exactly
|
seanhalle@64
|
707 // one instance in the code of this function. However, can use this
|
seanhalle@64
|
708 // function in different places for different data-singletons.
|
seanhalle@64
|
709 // (*(singletonAddr))->endInstrAddr = &&EndDataSingletonInstrAddr;
|
seanhalle@64
|
710
|
seanhalle@64
|
711
|
seanhalle@64
|
712 asm_save_ret_to_singleton(*singletonPtrAddr);
|
seanhalle@64
|
713
|
seanhalle@64
|
714 reqData.reqType = singleton_data_end;
|
seanhalle@64
|
715 reqData.singletonPtrAddr = singletonPtrAddr;
|
seanhalle@64
|
716
|
seanhalle@64
|
717 VMS_WL__send_sem_request( &reqData, animPr );
|
seanhalle@64
|
718 }
|
seanhalle@64
|
719
|
seanhalle@64
|
720 /*This executes the function in the masterVP, so it executes in isolation
|
seanhalle@64
|
721 * from any other copies -- only one copy of the function can ever execute
|
seanhalle@64
|
722 * at a time.
|
seanhalle@64
|
723 *
|
seanhalle@64
|
724 *It suspends to the master, and the request handler takes the function
|
seanhalle@64
|
725 * pointer out of the request and calls it, then resumes the VP.
|
seanhalle@64
|
726 *Only very short functions should be called this way -- for longer-running
|
seanhalle@64
|
727 * isolation, use transaction-start and transaction-end, which run the code
|
seanhalle@64
|
728 * between as work-code.
|
seanhalle@64
|
729 */
|
seanhalle@64
|
730 void
|
seanhalle@64
|
731 SSR__animate_short_fn_in_isolation( PtrToAtomicFn ptrToFnToExecInMaster,
|
seanhalle@64
|
732 void *data, SlaveVP *animPr )
|
seanhalle@64
|
733 {
|
seanhalle@64
|
734 SSRSemReq reqData;
|
seanhalle@64
|
735
|
seanhalle@64
|
736 //
|
seanhalle@64
|
737 reqData.reqType = atomic;
|
seanhalle@64
|
738 reqData.fnToExecInMaster = ptrToFnToExecInMaster;
|
seanhalle@64
|
739 reqData.dataForFn = data;
|
seanhalle@64
|
740
|
seanhalle@64
|
741 VMS_WL__send_sem_request( &reqData, animPr );
|
seanhalle@64
|
742 }
|
seanhalle@64
|
743
|
seanhalle@64
|
744
|
seanhalle@64
|
745 /*This suspends to the master.
|
seanhalle@64
|
746 *First, it looks at the VP's data, to see the highest transactionID that VP
|
seanhalle@64
|
747 * already has entered. If the current ID is not larger, it throws an
|
seanhalle@64
|
748 * exception stating a bug in the code. Otherwise it puts the current ID
|
seanhalle@64
|
749 * there, and adds the ID to a linked list of IDs entered -- the list is
|
seanhalle@64
|
750 * used to check that exits are properly ordered.
|
seanhalle@64
|
751 *Next it is uses transactionID as index into an array of transaction
|
seanhalle@64
|
752 * structures.
|
seanhalle@64
|
753 *If the "VP_currently_executing" field is non-null, then put requesting VP
|
seanhalle@64
|
754 * into queue in the struct. (At some point a holder will request
|
seanhalle@64
|
755 * end-transaction, which will take this VP from the queue and resume it.)
|
seanhalle@64
|
756 *If NULL, then write requesting into the field and resume.
|
seanhalle@64
|
757 */
|
seanhalle@64
|
758 void
|
seanhalle@64
|
759 SSR__start_transaction( int32 transactionID, SlaveVP *animPr )
|
seanhalle@64
|
760 {
|
seanhalle@64
|
761 SSRSemReq reqData;
|
seanhalle@64
|
762
|
seanhalle@64
|
763 //
|
seanhalle@64
|
764 reqData.sendPr = animPr;
|
seanhalle@64
|
765 reqData.reqType = trans_start;
|
seanhalle@64
|
766 reqData.transID = transactionID;
|
seanhalle@64
|
767
|
seanhalle@64
|
768 VMS_WL__send_sem_request( &reqData, animPr );
|
seanhalle@64
|
769 }
|
seanhalle@64
|
770
|
seanhalle@64
|
771 /*This suspends to the master, then uses transactionID as index into an
|
seanhalle@64
|
772 * array of transaction structures.
|
seanhalle@64
|
773 *It looks at VP_currently_executing to be sure it's same as requesting VP.
|
seanhalle@64
|
774 * If different, throws an exception, stating there's a bug in the code.
|
seanhalle@64
|
775 *Next it looks at the queue in the structure.
|
seanhalle@64
|
776 *If it's empty, it sets VP_currently_executing field to NULL and resumes.
|
seanhalle@64
|
777 *If something in, gets it, sets VP_currently_executing to that VP, then
|
seanhalle@64
|
778 * resumes both.
|
seanhalle@64
|
779 */
|
seanhalle@64
|
780 void
|
seanhalle@64
|
781 SSR__end_transaction( int32 transactionID, SlaveVP *animPr )
|
seanhalle@64
|
782 {
|
seanhalle@64
|
783 SSRSemReq reqData;
|
seanhalle@64
|
784
|
seanhalle@64
|
785 //
|
seanhalle@64
|
786 reqData.sendPr = animPr;
|
seanhalle@64
|
787 reqData.reqType = trans_end;
|
seanhalle@64
|
788 reqData.transID = transactionID;
|
seanhalle@64
|
789
|
seanhalle@64
|
790 VMS_WL__send_sem_request( &reqData, animPr );
|
seanhalle@64
|
791 }
|