| rev |
line source |
|
Me@0
|
1 /*
|
|
Me@38
|
2 * Copyright 2010 OpenSourceStewardshipFoundation
|
|
Me@0
|
3 *
|
|
Me@0
|
4 * Licensed under BSD
|
|
Me@0
|
5 */
|
|
Me@0
|
6
|
|
Me@0
|
7 #include <stdio.h>
|
|
Me@0
|
8 #include <stdlib.h>
|
|
Me@50
|
9 #include <string.h>
|
|
Me@0
|
10 #include <malloc.h>
|
|
Me@50
|
11 #include <sys/time.h>
|
|
Me@0
|
12
|
|
Me@0
|
13 #include "VMS.h"
|
|
msach@71
|
14 #include "SwitchAnimators.h"
|
|
Me@0
|
15 #include "Queue_impl/BlockingQueue.h"
|
|
Me@38
|
16 #include "Histogram/Histogram.h"
|
|
Me@0
|
17
|
|
Me@0
|
18
|
|
Me@26
|
19 #define thdAttrs NULL
|
|
Me@26
|
20
|
|
Me@22
|
21 //===========================================================================
|
|
Me@22
|
22 void
|
|
Me@22
|
23 shutdownFn( void *dummy, VirtProcr *dummy2 );
|
|
Me@22
|
24
|
|
Me@31
|
25 SchedSlot **
|
|
Me@31
|
26 create_sched_slots();
|
|
Me@22
|
27
|
|
Me@28
|
28 void
|
|
Me@28
|
29 create_masterEnv();
|
|
Me@28
|
30
|
|
Me@28
|
31 void
|
|
Me@28
|
32 create_the_coreLoop_OS_threads();
|
|
Me@28
|
33
|
|
Me@50
|
34 MallocProlog *
|
|
Me@50
|
35 create_free_list();
|
|
Me@50
|
36
|
|
Me@53
|
37 void
|
|
Me@53
|
38 endOSThreadFn( void *initData, VirtProcr *animatingPr );
|
|
Me@50
|
39
|
|
Me@26
|
40 pthread_mutex_t suspendLock = PTHREAD_MUTEX_INITIALIZER;
|
|
Me@26
|
41 pthread_cond_t suspend_cond = PTHREAD_COND_INITIALIZER;
|
|
Me@26
|
42
|
|
Me@22
|
43 //===========================================================================
|
|
Me@22
|
44
|
|
Me@0
|
45 /*Setup has two phases:
|
|
Me@0
|
46 * 1) Semantic layer first calls init_VMS, which creates masterEnv, and puts
|
|
Me@8
|
47 * the master virt procr into the work-queue, ready for first "call"
|
|
Me@8
|
48 * 2) Semantic layer then does its own init, which creates the seed virt
|
|
Me@8
|
49 * procr inside the semantic layer, ready to schedule it when
|
|
Me@0
|
50 * asked by the first run of the masterLoop.
|
|
Me@0
|
51 *
|
|
Me@0
|
52 *This part is bit weird because VMS really wants to be "always there", and
|
|
Me@0
|
53 * have applications attach and detach.. for now, this VMS is part of
|
|
Me@0
|
54 * the app, so the VMS system starts up as part of running the app.
|
|
Me@0
|
55 *
|
|
Me@8
|
56 *The semantic layer is isolated from the VMS internals by making the
|
|
Me@8
|
57 * semantic layer do setup to a state that it's ready with its
|
|
Me@8
|
58 * initial virt procrs, ready to schedule them to slots when the masterLoop
|
|
Me@0
|
59 * asks. Without this pattern, the semantic layer's setup would
|
|
Me@8
|
60 * have to modify slots directly to assign the initial virt-procrs, and put
|
|
Me@31
|
61 * them into the readyToAnimateQ itself, breaking the isolation completely.
|
|
Me@0
|
62 *
|
|
Me@0
|
63 *
|
|
Me@8
|
64 *The semantic layer creates the initial virt procr(s), and adds its
|
|
Me@8
|
65 * own environment to masterEnv, and fills in the pointers to
|
|
Me@0
|
66 * the requestHandler and slaveScheduler plug-in functions
|
|
Me@8
|
67 */
|
|
Me@8
|
68
|
|
Me@8
|
69 /*This allocates VMS data structures, populates the master VMSProc,
|
|
Me@0
|
70 * and master environment, and returns the master environment to the semantic
|
|
Me@0
|
71 * layer.
|
|
Me@0
|
72 */
|
|
Me@8
|
73 void
|
|
Me@8
|
74 VMS__init()
|
|
Me@28
|
75 {
|
|
Me@28
|
76 create_masterEnv();
|
|
Me@28
|
77 create_the_coreLoop_OS_threads();
|
|
Me@28
|
78 }
|
|
Me@28
|
79
|
|
msach@71
|
80 #ifdef SEQUENTIAL
|
|
msach@71
|
81
|
|
Me@28
|
82 /*To initialize the sequential version, just don't create the threads
|
|
Me@28
|
83 */
|
|
Me@28
|
84 void
|
|
Me@28
|
85 VMS__init_Seq()
|
|
Me@28
|
86 {
|
|
Me@28
|
87 create_masterEnv();
|
|
Me@28
|
88 }
|
|
Me@28
|
89
|
|
msach@71
|
90 #endif
|
|
msach@71
|
91
|
|
Me@28
|
92 void
|
|
Me@28
|
93 create_masterEnv()
|
|
Me@31
|
94 { MasterEnv *masterEnv;
|
|
Me@55
|
95 VMSQueueStruc **readyToAnimateQs;
|
|
Me@31
|
96 int coreIdx;
|
|
Me@31
|
97 VirtProcr **masterVPs;
|
|
Me@31
|
98 SchedSlot ***allSchedSlots; //ptr to array of ptrs
|
|
Me@53
|
99
|
|
Me@53
|
100
|
|
Me@31
|
101 //Make the master env, which holds everything else
|
|
Me@1
|
102 _VMSMasterEnv = malloc( sizeof(MasterEnv) );
|
|
Me@53
|
103
|
|
Me@53
|
104 //Very first thing put into the master env is the free-list, seeded
|
|
Me@53
|
105 // with a massive initial chunk of memory.
|
|
Me@53
|
106 //After this, all other mallocs are VMS__malloc.
|
|
Me@53
|
107 _VMSMasterEnv->freeListHead = VMS_ext__create_free_list();
|
|
Me@53
|
108
|
|
Me@65
|
109
|
|
Me@65
|
110 //============================= MEASUREMENT STUFF ========================
|
|
Me@65
|
111 #ifdef MEAS__TIME_MALLOC
|
|
Me@68
|
112 _VMSMasterEnv->mallocTimeHist = makeFixedBinHistExt( 50, 0, 100,
|
|
Me@65
|
113 "malloc time hist");
|
|
Me@68
|
114 _VMSMasterEnv->freeTimeHist = makeFixedBinHistExt( 50, 0, 100,
|
|
Me@65
|
115 "free time hist");
|
|
Me@65
|
116 #endif
|
|
Me@68
|
117 #ifdef MEAS__TIME_PLUGIN
|
|
Me@68
|
118 _VMSMasterEnv->reqHdlrLowTimeHist = makeFixedBinHistExt( 50, 0, 10,
|
|
Me@68
|
119 "plugin low time hist");
|
|
Me@68
|
120 _VMSMasterEnv->reqHdlrHighTimeHist = makeFixedBinHistExt( 50, 0, 100,
|
|
Me@68
|
121 "plugin high time hist");
|
|
Me@68
|
122 #endif
|
|
Me@65
|
123 //========================================================================
|
|
Me@65
|
124
|
|
Me@53
|
125 //===================== Only VMS__malloc after this ====================
|
|
msach@69
|
126 masterEnv = (MasterEnv*)_VMSMasterEnv;
|
|
Me@31
|
127
|
|
Me@31
|
128 //Make a readyToAnimateQ for each core loop
|
|
Me@55
|
129 readyToAnimateQs = VMS__malloc( NUM_CORES * sizeof(VMSQueueStruc *) );
|
|
Me@53
|
130 masterVPs = VMS__malloc( NUM_CORES * sizeof(VirtProcr *) );
|
|
Me@0
|
131
|
|
Me@31
|
132 //One array for each core, 3 in array, core's masterVP scheds all
|
|
Me@53
|
133 allSchedSlots = VMS__malloc( NUM_CORES * sizeof(SchedSlot *) );
|
|
Me@0
|
134
|
|
Me@53
|
135 _VMSMasterEnv->numProcrsCreated = 0; //used by create procr
|
|
Me@31
|
136 for( coreIdx = 0; coreIdx < NUM_CORES; coreIdx++ )
|
|
Me@53
|
137 {
|
|
Me@55
|
138 readyToAnimateQs[ coreIdx ] = makeVMSQ();
|
|
Me@31
|
139
|
|
Me@50
|
140 //Q: should give masterVP core-specific info as its init data?
|
|
Me@53
|
141 masterVPs[ coreIdx ] = VMS__create_procr( &masterLoop, masterEnv );
|
|
Me@31
|
142 masterVPs[ coreIdx ]->coreAnimatedBy = coreIdx;
|
|
Me@31
|
143 allSchedSlots[ coreIdx ] = create_sched_slots(); //makes for one core
|
|
Me@53
|
144 _VMSMasterEnv->numMasterInARow[ coreIdx ] = 0;
|
|
Me@55
|
145 _VMSMasterEnv->workStealingGates[ coreIdx ] = NULL;
|
|
Me@31
|
146 }
|
|
Me@31
|
147 _VMSMasterEnv->readyToAnimateQs = readyToAnimateQs;
|
|
Me@31
|
148 _VMSMasterEnv->masterVPs = masterVPs;
|
|
Me@50
|
149 _VMSMasterEnv->masterLock = UNLOCKED;
|
|
Me@31
|
150 _VMSMasterEnv->allSchedSlots = allSchedSlots;
|
|
Me@55
|
151 _VMSMasterEnv->workStealingLock = UNLOCKED;
|
|
Me@28
|
152
|
|
Me@12
|
153
|
|
Me@31
|
154 //Aug 19, 2010: no longer need to place initial masterVP into queue
|
|
Me@31
|
155 // because coreLoop now controls -- animates its masterVP when no work
|
|
Me@31
|
156
|
|
Me@30
|
157
|
|
Me@50
|
158 //============================= MEASUREMENT STUFF ========================
|
|
Me@50
|
159 #ifdef STATS__TURN_ON_PROBES
|
|
Me@50
|
160 _VMSMasterEnv->dynIntervalProbesInfo =
|
|
msach@69
|
161 makePrivDynArrayOfSize( (void***)&(_VMSMasterEnv->intervalProbes), 200);
|
|
Me@30
|
162
|
|
Me@53
|
163 _VMSMasterEnv->probeNameHashTbl = makeHashTable( 1000, &VMS__free );
|
|
Me@53
|
164
|
|
Me@53
|
165 //put creation time directly into master env, for fast retrieval
|
|
Me@50
|
166 struct timeval timeStamp;
|
|
Me@50
|
167 gettimeofday( &(timeStamp), NULL);
|
|
Me@50
|
168 _VMSMasterEnv->createPtInSecs =
|
|
Me@50
|
169 timeStamp.tv_sec +(timeStamp.tv_usec/1000000.0);
|
|
Me@50
|
170 #endif
|
|
Me@65
|
171 #ifdef MEAS__TIME_MASTER_LOCK
|
|
Me@65
|
172 _VMSMasterEnv->masterLockLowTimeHist = makeFixedBinHist( 50, 0, 2,
|
|
Me@65
|
173 "master lock low time hist");
|
|
Me@68
|
174 _VMSMasterEnv->masterLockHighTimeHist = makeFixedBinHist( 50, 0, 100,
|
|
Me@65
|
175 "master lock high time hist");
|
|
Me@65
|
176 #endif
|
|
Me@68
|
177
|
|
Me@68
|
178 MakeTheMeasHists
|
|
Me@50
|
179 //========================================================================
|
|
Me@38
|
180
|
|
Me@0
|
181 }
|
|
Me@0
|
182
|
|
Me@31
|
183 SchedSlot **
|
|
Me@31
|
184 create_sched_slots()
|
|
Me@31
|
185 { SchedSlot **schedSlots;
|
|
Me@0
|
186 int i;
|
|
Me@0
|
187
|
|
Me@53
|
188 schedSlots = VMS__malloc( NUM_SCHED_SLOTS * sizeof(SchedSlot *) );
|
|
Me@8
|
189
|
|
Me@1
|
190 for( i = 0; i < NUM_SCHED_SLOTS; i++ )
|
|
Me@0
|
191 {
|
|
Me@53
|
192 schedSlots[i] = VMS__malloc( sizeof(SchedSlot) );
|
|
Me@8
|
193
|
|
Me@1
|
194 //Set state to mean "handling requests done, slot needs filling"
|
|
Me@8
|
195 schedSlots[i]->workIsDone = FALSE;
|
|
Me@8
|
196 schedSlots[i]->needsProcrAssigned = TRUE;
|
|
Me@0
|
197 }
|
|
Me@31
|
198 return schedSlots;
|
|
Me@31
|
199 }
|
|
Me@31
|
200
|
|
Me@31
|
201
|
|
Me@31
|
202 void
|
|
Me@31
|
203 freeSchedSlots( SchedSlot **schedSlots )
|
|
Me@31
|
204 { int i;
|
|
Me@31
|
205 for( i = 0; i < NUM_SCHED_SLOTS; i++ )
|
|
Me@31
|
206 {
|
|
Me@53
|
207 VMS__free( schedSlots[i] );
|
|
Me@31
|
208 }
|
|
Me@53
|
209 VMS__free( schedSlots );
|
|
Me@0
|
210 }
|
|
Me@0
|
211
|
|
Me@8
|
212
|
|
Me@28
|
213 void
|
|
Me@28
|
214 create_the_coreLoop_OS_threads()
|
|
Me@28
|
215 {
|
|
Me@28
|
216 //========================================================================
|
|
Me@28
|
217 // Create the Threads
|
|
Me@28
|
218 int coreIdx, retCode;
|
|
Me@28
|
219
|
|
Me@28
|
220 //Need the threads to be created suspended, and wait for a signal
|
|
Me@28
|
221 // before proceeding -- gives time after creating to initialize other
|
|
Me@28
|
222 // stuff before the coreLoops set off.
|
|
Me@28
|
223 _VMSMasterEnv->setupComplete = 0;
|
|
Me@28
|
224
|
|
Me@28
|
225 //Make the threads that animate the core loops
|
|
Me@28
|
226 for( coreIdx=0; coreIdx < NUM_CORES; coreIdx++ )
|
|
Me@53
|
227 { coreLoopThdParams[coreIdx] = VMS__malloc( sizeof(ThdParams) );
|
|
Me@28
|
228 coreLoopThdParams[coreIdx]->coreNum = coreIdx;
|
|
Me@28
|
229
|
|
Me@28
|
230 retCode =
|
|
Me@28
|
231 pthread_create( &(coreLoopThdHandles[coreIdx]),
|
|
Me@28
|
232 thdAttrs,
|
|
Me@28
|
233 &coreLoop,
|
|
Me@28
|
234 (void *)(coreLoopThdParams[coreIdx]) );
|
|
Me@50
|
235 if(retCode){printf("ERROR creating thread: %d\n", retCode); exit(1);}
|
|
Me@28
|
236 }
|
|
Me@28
|
237 }
|
|
Me@28
|
238
|
|
Me@0
|
239 /*Semantic layer calls this when it want the system to start running..
|
|
Me@0
|
240 *
|
|
Me@24
|
241 *This starts the core loops running then waits for them to exit.
|
|
Me@0
|
242 */
|
|
Me@12
|
243 void
|
|
Me@24
|
244 VMS__start_the_work_then_wait_until_done()
|
|
Me@12
|
245 { int coreIdx;
|
|
Me@24
|
246 //Start the core loops running
|
|
Me@25
|
247
|
|
Me@25
|
248 //tell the core loop threads that setup is complete
|
|
Me@25
|
249 //get lock, to lock out any threads still starting up -- they'll see
|
|
Me@25
|
250 // that setupComplete is true before entering while loop, and so never
|
|
Me@25
|
251 // wait on the condition
|
|
Me@26
|
252 pthread_mutex_lock( &suspendLock );
|
|
Me@25
|
253 _VMSMasterEnv->setupComplete = 1;
|
|
Me@26
|
254 pthread_mutex_unlock( &suspendLock );
|
|
Me@26
|
255 pthread_cond_broadcast( &suspend_cond );
|
|
Me@25
|
256
|
|
Me@25
|
257
|
|
Me@24
|
258 //wait for all to complete
|
|
Me@8
|
259 for( coreIdx=0; coreIdx < NUM_CORES; coreIdx++ )
|
|
Me@8
|
260 {
|
|
Me@25
|
261 pthread_join( coreLoopThdHandles[coreIdx], NULL );
|
|
Me@24
|
262 }
|
|
Me@25
|
263
|
|
Me@24
|
264 //NOTE: do not clean up VMS env here -- semantic layer has to have
|
|
Me@24
|
265 // a chance to clean up its environment first, then do a call to free
|
|
Me@24
|
266 // the Master env and rest of VMS locations
|
|
Me@8
|
267 }
|
|
Me@0
|
268
|
|
msach@71
|
269 #ifdef SEQUENTIAL
|
|
Me@28
|
270 /*Only difference between version with an OS thread pinned to each core and
|
|
Me@28
|
271 * the sequential version of VMS is VMS__init_Seq, this, and coreLoop_Seq.
|
|
Me@28
|
272 */
|
|
Me@28
|
273 void
|
|
Me@28
|
274 VMS__start_the_work_then_wait_until_done_Seq()
|
|
Me@28
|
275 {
|
|
Me@28
|
276 //Instead of un-suspending threads, just call the one and only
|
|
Me@28
|
277 // core loop (sequential version), in the main thread.
|
|
Me@28
|
278 coreLoop_Seq( NULL );
|
|
msach@75
|
279 flushRegisters();
|
|
Me@28
|
280
|
|
Me@28
|
281 }
|
|
msach@71
|
282 #endif
|
|
Me@0
|
283
|
|
Me@8
|
284 /*Create stack, then create __cdecl structure on it and put initialData and
|
|
Me@8
|
285 * pointer to the new structure instance into the parameter positions on
|
|
Me@8
|
286 * the stack
|
|
Me@8
|
287 *Then put function pointer into nextInstrPt -- the stack is setup in std
|
|
Me@8
|
288 * call structure, so jumping to function ptr is same as a GCC generated
|
|
Me@8
|
289 * function call
|
|
Me@8
|
290 *No need to save registers on old stack frame, because there's no old
|
|
Me@8
|
291 * animator state to return to --
|
|
Me@8
|
292 *
|
|
Me@8
|
293 */
|
|
Me@50
|
294 inline VirtProcr *
|
|
Me@50
|
295 create_procr_helper( VirtProcr *newPr, VirtProcrFnPtr fnPtr,
|
|
Me@50
|
296 void *initialData, char *stackLocs )
|
|
Me@50
|
297 {
|
|
Me@50
|
298 char *stackPtr;
|
|
Me@8
|
299
|
|
Me@53
|
300 newPr->startOfStack = stackLocs;
|
|
Me@53
|
301 newPr->procrID = _VMSMasterEnv->numProcrsCreated++;
|
|
Me@53
|
302 newPr->nextInstrPt = fnPtr;
|
|
Me@53
|
303 newPr->initialData = initialData;
|
|
Me@53
|
304 newPr->requests = NULL;
|
|
Me@53
|
305 newPr->schedSlot = NULL;
|
|
Me@8
|
306
|
|
Me@14
|
307 //fnPtr takes two params -- void *initData & void *animProcr
|
|
Me@8
|
308 //alloc stack locations, make stackPtr be the highest addr minus room
|
|
Me@14
|
309 // for 2 params + return addr. Return addr (NULL) is in loc pointed to
|
|
Me@14
|
310 // by stackPtr, initData at stackPtr + 4 bytes, animatingPr just above
|
|
Me@22
|
311 stackPtr = ( (char *)stackLocs + VIRT_PROCR_STACK_SIZE - 0x10 );
|
|
Me@50
|
312
|
|
Me@8
|
313 //setup __cdecl on stack -- coreloop will switch to stackPtr before jmp
|
|
Me@22
|
314 *( (int *)stackPtr + 2 ) = (int) newPr; //rightmost param -- 32bit pointer
|
|
Me@14
|
315 *( (int *)stackPtr + 1 ) = (int) initialData; //next param to left
|
|
Me@8
|
316 newPr->stackPtr = stackPtr; //core loop will switch to this, then
|
|
Me@8
|
317 newPr->framePtr = stackPtr; //suspend loop will save new stack & frame ptr
|
|
Me@8
|
318
|
|
Me@50
|
319 //============================= MEASUREMENT STUFF ========================
|
|
Me@50
|
320 #ifdef STATS__TURN_ON_PROBES
|
|
Me@50
|
321 struct timeval timeStamp;
|
|
Me@50
|
322 gettimeofday( &(timeStamp), NULL);
|
|
Me@54
|
323 newPr->createPtInSecs = timeStamp.tv_sec +(timeStamp.tv_usec/1000000.0) -
|
|
Me@54
|
324 _VMSMasterEnv->createPtInSecs;
|
|
Me@50
|
325 #endif
|
|
Me@50
|
326 //========================================================================
|
|
Me@50
|
327
|
|
Me@8
|
328 return newPr;
|
|
Me@8
|
329 }
|
|
Me@8
|
330
|
|
Me@50
|
331 inline VirtProcr *
|
|
Me@50
|
332 VMS__create_procr( VirtProcrFnPtr fnPtr, void *initialData )
|
|
Me@50
|
333 { VirtProcr *newPr;
|
|
Me@50
|
334 char *stackLocs;
|
|
Me@50
|
335
|
|
Me@50
|
336 newPr = VMS__malloc( sizeof(VirtProcr) );
|
|
Me@50
|
337 stackLocs = VMS__malloc( VIRT_PROCR_STACK_SIZE );
|
|
Me@50
|
338 if( stackLocs == 0 )
|
|
Me@50
|
339 { perror("VMS__malloc stack"); exit(1); }
|
|
Me@50
|
340
|
|
Me@50
|
341 return create_procr_helper( newPr, fnPtr, initialData, stackLocs );
|
|
Me@50
|
342 }
|
|
Me@50
|
343
|
|
Me@50
|
344 /* "ext" designates that it's for use outside the VMS system -- should only
|
|
Me@50
|
345 * be called from main thread or other thread -- never from code animated by
|
|
Me@50
|
346 * a VMS virtual processor.
|
|
Me@50
|
347 */
|
|
Me@50
|
348 inline VirtProcr *
|
|
Me@50
|
349 VMS_ext__create_procr( VirtProcrFnPtr fnPtr, void *initialData )
|
|
Me@50
|
350 { VirtProcr *newPr;
|
|
Me@50
|
351 char *stackLocs;
|
|
Me@50
|
352
|
|
Me@50
|
353 newPr = malloc( sizeof(VirtProcr) );
|
|
Me@50
|
354 stackLocs = malloc( VIRT_PROCR_STACK_SIZE );
|
|
Me@50
|
355 if( stackLocs == 0 )
|
|
Me@50
|
356 { perror("malloc stack"); exit(1); }
|
|
Me@50
|
357
|
|
Me@50
|
358 return create_procr_helper( newPr, fnPtr, initialData, stackLocs );
|
|
Me@50
|
359 }
|
|
Me@50
|
360
|
|
Me@8
|
361
|
|
Me@64
|
362 /*Anticipating multi-tasking
|
|
Me@64
|
363 */
|
|
Me@64
|
364 void *
|
|
Me@64
|
365 VMS__give_sem_env_for( VirtProcr *animPr )
|
|
Me@64
|
366 {
|
|
Me@64
|
367 return _VMSMasterEnv->semanticEnv;
|
|
Me@64
|
368 }
|
|
Me@64
|
369 //===========================================================================
|
|
Me@26
|
370 /*there is a label inside this function -- save the addr of this label in
|
|
Me@0
|
371 * the callingPr struc, as the pick-up point from which to start the next
|
|
Me@0
|
372 * work-unit for that procr. If turns out have to save registers, then
|
|
Me@0
|
373 * save them in the procr struc too. Then do assembly jump to the CoreLoop's
|
|
Me@0
|
374 * "done with work-unit" label. The procr struc is in the request in the
|
|
Me@0
|
375 * slave that animated the just-ended work-unit, so all the state is saved
|
|
Me@0
|
376 * there, and will get passed along, inside the request handler, to the
|
|
Me@0
|
377 * next work-unit for that procr.
|
|
Me@0
|
378 */
|
|
Me@8
|
379 void
|
|
Me@38
|
380 VMS__suspend_procr( VirtProcr *animatingPr )
|
|
Me@55
|
381 {
|
|
Me@0
|
382
|
|
Me@14
|
383 //The request to master will cause this suspended virt procr to get
|
|
Me@14
|
384 // scheduled again at some future point -- to resume, core loop jumps
|
|
Me@14
|
385 // to the resume point (below), which causes restore of saved regs and
|
|
Me@14
|
386 // "return" from this call.
|
|
msach@71
|
387 //animatingPr->nextInstrPt = &&ResumePt;
|
|
Me@1
|
388
|
|
Me@1
|
389 //return ownership of the virt procr and sched slot to Master virt pr
|
|
Me@38
|
390 animatingPr->schedSlot->workIsDone = TRUE;
|
|
Me@1
|
391
|
|
Me@41
|
392 //=========================== Measurement stuff ========================
|
|
Me@38
|
393 #ifdef MEAS__TIME_STAMP_SUSP
|
|
Me@41
|
394 //record time stamp: compare to time-stamp recorded below
|
|
Me@38
|
395 saveLowTimeStampCountInto( animatingPr->preSuspTSCLow );
|
|
Me@38
|
396 #endif
|
|
Me@41
|
397 //=======================================================================
|
|
Me@38
|
398
|
|
msach@71
|
399 switchToCoreLoop(animatingPr);
|
|
msach@71
|
400 flushRegisters();
|
|
Me@55
|
401
|
|
Me@55
|
402 //=======================================================================
|
|
msach@71
|
403
|
|
Me@38
|
404 #ifdef MEAS__TIME_STAMP_SUSP
|
|
Me@41
|
405 //NOTE: only take low part of count -- do sanity check when take diff
|
|
Me@38
|
406 saveLowTimeStampCountInto( animatingPr->postSuspTSCLow );
|
|
Me@38
|
407 #endif
|
|
Me@38
|
408
|
|
Me@0
|
409 return;
|
|
Me@0
|
410 }
|
|
Me@0
|
411
|
|
Me@22
|
412
|
|
Me@22
|
413
|
|
Me@50
|
414 /*For this implementation of VMS, it may not make much sense to have the
|
|
Me@50
|
415 * system of requests for creating a new processor done this way.. but over
|
|
Me@50
|
416 * the scope of single-master, multi-master, mult-tasking, OS-implementing,
|
|
Me@50
|
417 * distributed-memory, and so on, this gives VMS implementation a chance to
|
|
Me@50
|
418 * do stuff before suspend, in the AppVP, and in the Master before the plugin
|
|
Me@50
|
419 * is called, as well as in the lang-lib before this is called, and in the
|
|
Me@50
|
420 * plugin. So, this gives both VMS and language implementations a chance to
|
|
Me@50
|
421 * intercept at various points and do order-dependent stuff.
|
|
Me@50
|
422 *Having a standard VMSNewPrReqData struc allows the language to create and
|
|
Me@50
|
423 * free the struc, while VMS knows how to get the newPr if it wants it, and
|
|
Me@50
|
424 * it lets the lang have lang-specific data related to creation transported
|
|
Me@50
|
425 * to the plugin.
|
|
Me@50
|
426 */
|
|
Me@50
|
427 void
|
|
Me@50
|
428 VMS__send_create_procr_req( void *semReqData, VirtProcr *reqstingPr )
|
|
Me@50
|
429 { VMSReqst req;
|
|
Me@50
|
430
|
|
Me@50
|
431 req.reqType = createReq;
|
|
Me@50
|
432 req.semReqData = semReqData;
|
|
Me@50
|
433 req.nextReqst = reqstingPr->requests;
|
|
Me@50
|
434 reqstingPr->requests = &req;
|
|
Me@50
|
435
|
|
Me@50
|
436 VMS__suspend_procr( reqstingPr );
|
|
Me@50
|
437 }
|
|
Me@50
|
438
|
|
Me@22
|
439
|
|
Me@38
|
440 /*
|
|
Me@22
|
441 *This adds a request to dissipate, then suspends the processor so that the
|
|
Me@22
|
442 * request handler will receive the request. The request handler is what
|
|
Me@22
|
443 * does the work of freeing memory and removing the processor from the
|
|
Me@22
|
444 * semantic environment's data structures.
|
|
Me@22
|
445 *The request handler also is what figures out when to shutdown the VMS
|
|
Me@22
|
446 * system -- which causes all the core loop threads to die, and returns from
|
|
Me@22
|
447 * the call that started up VMS to perform the work.
|
|
Me@22
|
448 *
|
|
Me@22
|
449 *This form is a bit misleading to understand if one is trying to figure out
|
|
Me@22
|
450 * how VMS works -- it looks like a normal function call, but inside it
|
|
Me@22
|
451 * sends a request to the request handler and suspends the processor, which
|
|
Me@22
|
452 * jumps out of the VMS__dissipate_procr function, and out of all nestings
|
|
Me@22
|
453 * above it, transferring the work of dissipating to the request handler,
|
|
Me@22
|
454 * which then does the actual work -- causing the processor that animated
|
|
Me@22
|
455 * the call of this function to disappear and the "hanging" state of this
|
|
Me@22
|
456 * function to just poof into thin air -- the virtual processor's trace
|
|
Me@22
|
457 * never returns from this call, but instead the virtual processor's trace
|
|
Me@22
|
458 * gets suspended in this call and all the virt processor's state disap-
|
|
Me@22
|
459 * pears -- making that suspend the last thing in the virt procr's trace.
|
|
Me@8
|
460 */
|
|
Me@8
|
461 void
|
|
Me@53
|
462 VMS__send_dissipate_req( VirtProcr *procrToDissipate )
|
|
Me@50
|
463 { VMSReqst req;
|
|
Me@22
|
464
|
|
Me@50
|
465 req.reqType = dissipate;
|
|
Me@50
|
466 req.nextReqst = procrToDissipate->requests;
|
|
Me@50
|
467 procrToDissipate->requests = &req;
|
|
Me@50
|
468
|
|
Me@22
|
469 VMS__suspend_procr( procrToDissipate );
|
|
Me@50
|
470 }
|
|
Me@50
|
471
|
|
Me@50
|
472
|
|
Me@50
|
473 /* "ext" designates that it's for use outside the VMS system -- should only
|
|
Me@50
|
474 * be called from main thread or other thread -- never from code animated by
|
|
Me@50
|
475 * a VMS virtual processor.
|
|
Me@50
|
476 *
|
|
Me@50
|
477 *Use this version to dissipate VPs created outside the VMS system.
|
|
Me@50
|
478 */
|
|
Me@50
|
479 void
|
|
Me@50
|
480 VMS_ext__dissipate_procr( VirtProcr *procrToDissipate )
|
|
Me@50
|
481 {
|
|
Me@50
|
482 //NOTE: initialData was given to the processor, so should either have
|
|
Me@50
|
483 // been alloc'd with VMS__malloc, or freed by the level above animPr.
|
|
Me@50
|
484 //So, all that's left to free here is the stack and the VirtProcr struc
|
|
Me@50
|
485 // itself
|
|
Me@50
|
486 //Note, should not stack-allocate initial data -- no guarantee, in
|
|
Me@50
|
487 // general that creating processor will outlive ones it creates.
|
|
Me@50
|
488 free( procrToDissipate->startOfStack );
|
|
Me@50
|
489 free( procrToDissipate );
|
|
Me@50
|
490 }
|
|
Me@50
|
491
|
|
Me@22
|
492
|
|
Me@22
|
493
|
|
Me@53
|
494 /*This call's name indicates that request is malloc'd -- so req handler
|
|
Me@53
|
495 * has to free any extra requests tacked on before a send, using this.
|
|
Me@53
|
496 *
|
|
Me@53
|
497 * This inserts the semantic-layer's request data into standard VMS carrier
|
|
Me@53
|
498 * request data-struct that is mallocd. The sem request doesn't need to
|
|
Me@53
|
499 * be malloc'd if this is called inside the same call chain before the
|
|
Me@53
|
500 * send of the last request is called.
|
|
Me@53
|
501 *
|
|
Me@53
|
502 *The request handler has to call VMS__free_VMSReq for any of these
|
|
Me@22
|
503 */
|
|
Me@22
|
504 inline void
|
|
Me@53
|
505 VMS__add_sem_request_in_mallocd_VMSReqst( void *semReqData,
|
|
Me@53
|
506 VirtProcr *callingPr )
|
|
Me@53
|
507 { VMSReqst *req;
|
|
Me@22
|
508
|
|
Me@53
|
509 req = VMS__malloc( sizeof(VMSReqst) );
|
|
Me@53
|
510 req->reqType = semantic;
|
|
Me@53
|
511 req->semReqData = semReqData;
|
|
Me@53
|
512 req->nextReqst = callingPr->requests;
|
|
Me@53
|
513 callingPr->requests = req;
|
|
Me@22
|
514 }
|
|
Me@22
|
515
|
|
Me@50
|
516 /*This inserts the semantic-layer's request data into standard VMS carrier
|
|
Me@50
|
517 * request data-struct is allocated on stack of this call & ptr to it sent
|
|
Me@50
|
518 * to plugin
|
|
Me@50
|
519 *Then it does suspend, to cause request to be sent.
|
|
Me@50
|
520 */
|
|
Me@50
|
521 inline void
|
|
Me@50
|
522 VMS__send_sem_request( void *semReqData, VirtProcr *callingPr )
|
|
Me@50
|
523 { VMSReqst req;
|
|
Me@22
|
524
|
|
Me@50
|
525 req.reqType = semantic;
|
|
Me@50
|
526 req.semReqData = semReqData;
|
|
Me@50
|
527 req.nextReqst = callingPr->requests;
|
|
Me@50
|
528 callingPr->requests = &req;
|
|
Me@50
|
529
|
|
Me@50
|
530 VMS__suspend_procr( callingPr );
|
|
Me@50
|
531 }
|
|
Me@50
|
532
|
|
Me@50
|
533
|
|
Me@50
|
534 inline void
|
|
Me@50
|
535 VMS__send_VMSSem_request( void *semReqData, VirtProcr *callingPr )
|
|
Me@50
|
536 { VMSReqst req;
|
|
Me@50
|
537
|
|
Me@50
|
538 req.reqType = VMSSemantic;
|
|
Me@50
|
539 req.semReqData = semReqData;
|
|
Me@50
|
540 req.nextReqst = callingPr->requests; //gab any other preceeding
|
|
Me@50
|
541 callingPr->requests = &req;
|
|
Me@50
|
542
|
|
Me@50
|
543 VMS__suspend_procr( callingPr );
|
|
Me@50
|
544 }
|
|
Me@50
|
545
|
|
Me@50
|
546
|
|
Me@50
|
547 /*
|
|
Me@38
|
548 */
|
|
Me@24
|
549 VMSReqst *
|
|
Me@50
|
550 VMS__take_next_request_out_of( VirtProcr *procrWithReq )
|
|
Me@31
|
551 { VMSReqst *req;
|
|
Me@31
|
552
|
|
Me@31
|
553 req = procrWithReq->requests;
|
|
Me@38
|
554 if( req == NULL ) return NULL;
|
|
Me@31
|
555
|
|
Me@31
|
556 procrWithReq->requests = procrWithReq->requests->nextReqst;
|
|
Me@50
|
557 return req;
|
|
Me@24
|
558 }
|
|
Me@22
|
559
|
|
Me@24
|
560
|
|
Me@24
|
561 inline void *
|
|
Me@24
|
562 VMS__take_sem_reqst_from( VMSReqst *req )
|
|
Me@24
|
563 {
|
|
Me@24
|
564 return req->semReqData;
|
|
Me@24
|
565 }
|
|
Me@24
|
566
|
|
Me@24
|
567
|
|
Me@24
|
568
|
|
Me@50
|
569 /* This is for OS requests and VMS infrastructure requests, such as to create
|
|
Me@50
|
570 * a probe -- a probe is inside the heart of VMS-core, it's not part of any
|
|
Me@50
|
571 * language -- but it's also a semantic thing that's triggered from and used
|
|
Me@50
|
572 * in the application.. so it crosses abstractions.. so, need some special
|
|
Me@50
|
573 * pattern here for handling such requests.
|
|
Me@52
|
574 * Doing this just like it were a second language sharing VMS-core.
|
|
Me@52
|
575 *
|
|
Me@50
|
576 * This is called from the language's request handler when it sees a request
|
|
Me@50
|
577 * of type VMSSemReq
|
|
Me@52
|
578 *
|
|
Me@52
|
579 * TODO: Later change this, to give probes their own separate plugin & have
|
|
Me@52
|
580 * VMS-core steer the request to appropriate plugin
|
|
Me@52
|
581 * Do the same for OS calls -- look later at it..
|
|
Me@50
|
582 */
|
|
Me@50
|
583 void inline
|
|
Me@50
|
584 VMS__handle_VMSSemReq( VMSReqst *req, VirtProcr *requestingPr, void *semEnv,
|
|
Me@50
|
585 ResumePrFnPtr resumePrFnPtr )
|
|
Me@50
|
586 { VMSSemReq *semReq;
|
|
Me@50
|
587 IntervalProbe *newProbe;
|
|
Me@50
|
588 int32 nameLen;
|
|
Me@24
|
589
|
|
Me@50
|
590 semReq = req->semReqData;
|
|
Me@24
|
591
|
|
Me@50
|
592 newProbe = VMS__malloc( sizeof(IntervalProbe) );
|
|
Me@65
|
593 newProbe->nameStr = VMS__strDup( semReq->nameStr );
|
|
Me@50
|
594 newProbe->hist = NULL;
|
|
Me@50
|
595 newProbe->schedChoiceWasRecorded = FALSE;
|
|
Me@53
|
596
|
|
Me@53
|
597 //This runs in masterVP, so no race-condition worries
|
|
Me@50
|
598 newProbe->probeID =
|
|
Me@50
|
599 addToDynArray( newProbe, _VMSMasterEnv->dynIntervalProbesInfo );
|
|
Me@50
|
600
|
|
Me@53
|
601 requestingPr->dataRetFromReq = newProbe;
|
|
Me@50
|
602
|
|
Me@50
|
603 (*resumePrFnPtr)( requestingPr, semEnv );
|
|
Me@22
|
604 }
|
|
Me@22
|
605
|
|
Me@22
|
606
|
|
Me@22
|
607
|
|
Me@24
|
608 /*This must be called by the request handler plugin -- it cannot be called
|
|
Me@24
|
609 * from the semantic library "dissipate processor" function -- instead, the
|
|
Me@50
|
610 * semantic layer has to generate a request, and the plug-in calls this
|
|
Me@24
|
611 * function.
|
|
Me@24
|
612 *The reason is that this frees the virtual processor's stack -- which is
|
|
Me@24
|
613 * still in use inside semantic library calls!
|
|
Me@24
|
614 *
|
|
Me@24
|
615 *This frees or recycles all the state owned by and comprising the VMS
|
|
Me@24
|
616 * portion of the animating virtual procr. The request handler must first
|
|
Me@24
|
617 * free any semantic data created for the processor that didn't use the
|
|
Me@24
|
618 * VMS_malloc mechanism. Then it calls this, which first asks the malloc
|
|
Me@24
|
619 * system to disown any state that did use VMS_malloc, and then frees the
|
|
Me@24
|
620 * statck and the processor-struct itself.
|
|
Me@24
|
621 *If the dissipated processor is the sole (remaining) owner of VMS__malloc'd
|
|
Me@24
|
622 * state, then that state gets freed (or sent to recycling) as a side-effect
|
|
Me@24
|
623 * of dis-owning it.
|
|
Me@24
|
624 */
|
|
Me@24
|
625 void
|
|
Me@53
|
626 VMS__dissipate_procr( VirtProcr *animatingPr )
|
|
Me@24
|
627 {
|
|
Me@24
|
628 //dis-own all locations owned by this processor, causing to be freed
|
|
Me@24
|
629 // any locations that it is (was) sole owner of
|
|
Me@29
|
630 //TODO: implement VMS__malloc system, including "give up ownership"
|
|
Me@24
|
631
|
|
Me@24
|
632
|
|
Me@24
|
633 //NOTE: initialData was given to the processor, so should either have
|
|
Me@24
|
634 // been alloc'd with VMS__malloc, or freed by the level above animPr.
|
|
Me@24
|
635 //So, all that's left to free here is the stack and the VirtProcr struc
|
|
Me@24
|
636 // itself
|
|
Me@50
|
637 //Note, should not stack-allocate initial data -- no guarantee, in
|
|
Me@50
|
638 // general that creating processor will outlive ones it creates.
|
|
Me@50
|
639 VMS__free( animatingPr->startOfStack );
|
|
Me@50
|
640 VMS__free( animatingPr );
|
|
Me@24
|
641 }
|
|
Me@24
|
642
|
|
Me@24
|
643
|
|
Me@53
|
644 //TODO: look at architecting cleanest separation between request handler
|
|
Me@29
|
645 // and master loop, for dissipate, create, shutdown, and other non-semantic
|
|
Me@29
|
646 // requests. Issue is chain: one removes requests from AppVP, one dispatches
|
|
Me@29
|
647 // on type of request, and one handles each type.. but some types require
|
|
Me@29
|
648 // action from both request handler and master loop -- maybe just give the
|
|
Me@29
|
649 // request handler calls like: VMS__handle_X_request_type
|
|
Me@24
|
650
|
|
Me@29
|
651
|
|
Me@29
|
652 /*This is called by the semantic layer's request handler when it decides its
|
|
Me@29
|
653 * time to shut down the VMS system. Calling this causes the core loop OS
|
|
Me@29
|
654 * threads to exit, which unblocks the entry-point function that started up
|
|
Me@29
|
655 * VMS, and allows it to grab the result and return to the original single-
|
|
Me@29
|
656 * threaded application.
|
|
Me@22
|
657 *
|
|
Me@29
|
658 *The _VMSMasterEnv is needed by this shut down function, so the create-seed-
|
|
Me@29
|
659 * and-wait function has to free a bunch of stuff after it detects the
|
|
Me@29
|
660 * threads have all died: the masterEnv, the thread-related locations,
|
|
Me@29
|
661 * masterVP any AppVPs that might still be allocated and sitting in the
|
|
Me@29
|
662 * semantic environment, or have been orphaned in the _VMSWorkQ.
|
|
Me@29
|
663 *
|
|
Me@53
|
664 *NOTE: the semantic plug-in is expected to use VMS__malloc to get all the
|
|
Me@29
|
665 * locations it needs, and give ownership to masterVP. Then, they will be
|
|
Me@53
|
666 * automatically freed.
|
|
Me@22
|
667 *
|
|
Me@29
|
668 *In here,create one core-loop shut-down processor for each core loop and put
|
|
Me@31
|
669 * them all directly into the readyToAnimateQ.
|
|
Me@29
|
670 *Note, this function can ONLY be called after the semantic environment no
|
|
Me@29
|
671 * longer cares if AppVPs get animated after the point this is called. In
|
|
Me@29
|
672 * other words, this can be used as an abort, or else it should only be
|
|
Me@29
|
673 * called when all AppVPs have finished dissipate requests -- only at that
|
|
Me@29
|
674 * point is it sure that all results have completed.
|
|
Me@22
|
675 */
|
|
Me@22
|
676 void
|
|
Me@53
|
677 VMS__shutdown()
|
|
Me@8
|
678 { int coreIdx;
|
|
Me@14
|
679 VirtProcr *shutDownPr;
|
|
Me@22
|
680
|
|
Me@29
|
681 //create the shutdown processors, one for each core loop -- put them
|
|
Me@31
|
682 // directly into the Q -- each core will die when gets one
|
|
Me@8
|
683 for( coreIdx=0; coreIdx < NUM_CORES; coreIdx++ )
|
|
Me@50
|
684 { //Note, this is running in the master
|
|
Me@29
|
685 shutDownPr = VMS__create_procr( &endOSThreadFn, NULL );
|
|
Me@55
|
686 writeVMSQ( shutDownPr, _VMSMasterEnv->readyToAnimateQs[coreIdx] );
|
|
Me@8
|
687 }
|
|
Me@22
|
688
|
|
Me@12
|
689 }
|
|
Me@12
|
690
|
|
Me@12
|
691
|
|
Me@29
|
692 /*Am trying to be cute, avoiding IF statement in coreLoop that checks for
|
|
Me@29
|
693 * a special shutdown procr. Ended up with extra-complex shutdown sequence.
|
|
Me@29
|
694 *This function has the sole purpose of setting the stack and framePtr
|
|
Me@29
|
695 * to the coreLoop's stack and framePtr.. it does that then jumps to the
|
|
Me@29
|
696 * core loop's shutdown point -- might be able to just call Pthread_exit
|
|
Me@30
|
697 * from here, but am going back to the pthread's stack and setting everything
|
|
Me@29
|
698 * up just as if it never jumped out, before calling pthread_exit.
|
|
Me@29
|
699 *The end-point of core loop will free the stack and so forth of the
|
|
Me@29
|
700 * processor that animates this function, (this fn is transfering the
|
|
Me@29
|
701 * animator of the AppVP that is in turn animating this function over
|
|
Me@29
|
702 * to core loop function -- note that this slices out a level of virtual
|
|
Me@29
|
703 * processors).
|
|
Me@29
|
704 */
|
|
Me@29
|
705 void
|
|
Me@29
|
706 endOSThreadFn( void *initData, VirtProcr *animatingPr )
|
|
msach@71
|
707 {
|
|
msach@75
|
708 #ifdef SEQUENTIAL
|
|
msach@75
|
709 asmTerminateCoreLoopSeq(animatingPr);
|
|
msach@75
|
710 #else
|
|
msach@71
|
711 asmTerminateCoreLoop(animatingPr);
|
|
msach@75
|
712 #endif
|
|
Me@29
|
713 }
|
|
Me@29
|
714
|
|
Me@29
|
715
|
|
Me@53
|
716 /*This is called from the startup & shutdown
|
|
Me@24
|
717 */
|
|
Me@24
|
718 void
|
|
Me@53
|
719 VMS__cleanup_at_end_of_shutdown()
|
|
Me@31
|
720 {
|
|
Me@55
|
721 VMSQueueStruc **readyToAnimateQs;
|
|
Me@31
|
722 int coreIdx;
|
|
Me@31
|
723 VirtProcr **masterVPs;
|
|
Me@31
|
724 SchedSlot ***allSchedSlots; //ptr to array of ptrs
|
|
Me@31
|
725
|
|
Me@65
|
726 //Before getting rid of everything, print out any measurements made
|
|
msach@69
|
727 forAllInDynArrayDo( _VMSMasterEnv->measHistsInfo, (DynArrayFnPtr)&printHist );
|
|
Me@68
|
728 //forAllInDynArrayDo( _VMSMasterEnv->measHistsInfo, &freeHistExt );
|
|
Me@65
|
729 #ifdef MEAS__TIME_PLUGIN
|
|
Me@68
|
730 printHist( _VMSMasterEnv->reqHdlrLowTimeHist );
|
|
Me@68
|
731 printHist( _VMSMasterEnv->reqHdlrHighTimeHist );
|
|
Me@68
|
732 freeHistExt( _VMSMasterEnv->reqHdlrLowTimeHist );
|
|
Me@68
|
733 freeHistExt( _VMSMasterEnv->reqHdlrHighTimeHist );
|
|
Me@65
|
734 #endif
|
|
Me@65
|
735 #ifdef MEAS__TIME_MALLOC
|
|
Me@65
|
736 printHist( _VMSMasterEnv->mallocTimeHist );
|
|
Me@65
|
737 printHist( _VMSMasterEnv->freeTimeHist );
|
|
Me@65
|
738 freeHistExt( _VMSMasterEnv->mallocTimeHist );
|
|
Me@65
|
739 freeHistExt( _VMSMasterEnv->freeTimeHist );
|
|
Me@65
|
740 #endif
|
|
Me@65
|
741 #ifdef MEAS__TIME_MASTER_LOCK
|
|
Me@65
|
742 printHist( _VMSMasterEnv->masterLockLowTimeHist );
|
|
Me@65
|
743 printHist( _VMSMasterEnv->masterLockHighTimeHist );
|
|
Me@65
|
744 #endif
|
|
Me@65
|
745 #ifdef MEAS__TIME_MASTER
|
|
Me@65
|
746 printHist( _VMSMasterEnv->pluginTimeHist );
|
|
Me@65
|
747 for( coreIdx = 0; coreIdx < NUM_CORES; coreIdx++ )
|
|
Me@65
|
748 {
|
|
Me@65
|
749 freeVMSQ( readyToAnimateQs[ coreIdx ] );
|
|
Me@65
|
750 //master VPs were created external to VMS, so use external free
|
|
Me@65
|
751 VMS__dissipate_procr( masterVPs[ coreIdx ] );
|
|
Me@65
|
752
|
|
Me@65
|
753 freeSchedSlots( allSchedSlots[ coreIdx ] );
|
|
Me@65
|
754 }
|
|
Me@65
|
755 #endif
|
|
Me@65
|
756 #ifdef MEAS__TIME_STAMP_SUSP
|
|
Me@65
|
757 printHist( _VMSMasterEnv->pluginTimeHist );
|
|
Me@65
|
758 for( coreIdx = 0; coreIdx < NUM_CORES; coreIdx++ )
|
|
Me@65
|
759 {
|
|
Me@65
|
760 freeVMSQ( readyToAnimateQs[ coreIdx ] );
|
|
Me@65
|
761 //master VPs were created external to VMS, so use external free
|
|
Me@65
|
762 VMS__dissipate_procr( masterVPs[ coreIdx ] );
|
|
Me@65
|
763
|
|
Me@65
|
764 freeSchedSlots( allSchedSlots[ coreIdx ] );
|
|
Me@65
|
765 }
|
|
Me@65
|
766 #endif
|
|
Me@65
|
767
|
|
Me@53
|
768 //All the environment data has been allocated with VMS__malloc, so just
|
|
Me@53
|
769 // free its internal big-chunk and all inside it disappear.
|
|
Me@53
|
770 /*
|
|
Me@31
|
771 readyToAnimateQs = _VMSMasterEnv->readyToAnimateQs;
|
|
Me@31
|
772 masterVPs = _VMSMasterEnv->masterVPs;
|
|
Me@31
|
773 allSchedSlots = _VMSMasterEnv->allSchedSlots;
|
|
Me@31
|
774
|
|
Me@31
|
775 for( coreIdx = 0; coreIdx < NUM_CORES; coreIdx++ )
|
|
Me@24
|
776 {
|
|
Me@55
|
777 freeVMSQ( readyToAnimateQs[ coreIdx ] );
|
|
Me@50
|
778 //master VPs were created external to VMS, so use external free
|
|
Me@53
|
779 VMS__dissipate_procr( masterVPs[ coreIdx ] );
|
|
Me@31
|
780
|
|
Me@31
|
781 freeSchedSlots( allSchedSlots[ coreIdx ] );
|
|
Me@24
|
782 }
|
|
Me@31
|
783
|
|
Me@53
|
784 VMS__free( _VMSMasterEnv->readyToAnimateQs );
|
|
Me@53
|
785 VMS__free( _VMSMasterEnv->masterVPs );
|
|
Me@53
|
786 VMS__free( _VMSMasterEnv->allSchedSlots );
|
|
Me@50
|
787
|
|
Me@50
|
788 //============================= MEASUREMENT STUFF ========================
|
|
Me@50
|
789 #ifdef STATS__TURN_ON_PROBES
|
|
Me@53
|
790 freeDynArrayDeep( _VMSMasterEnv->dynIntervalProbesInfo, &VMS__free_probe);
|
|
Me@50
|
791 #endif
|
|
Me@50
|
792 //========================================================================
|
|
Me@53
|
793 */
|
|
Me@53
|
794 //These are the only two that use system free
|
|
Me@53
|
795 VMS_ext__free_free_list( _VMSMasterEnv->freeListHead );
|
|
Me@53
|
796 free( (void *)_VMSMasterEnv );
|
|
Me@24
|
797 }
|
|
Me@24
|
798
|
|
Me@54
|
799
|
|
Me@54
|
800 //================================
|
|
Me@54
|
801
|
|
Me@54
|
802
|
|
Me@54
|
803 /*Later, improve this -- for now, just exits the application after printing
|
|
Me@54
|
804 * the error message.
|
|
Me@54
|
805 */
|
|
Me@54
|
806 void
|
|
Me@54
|
807 VMS__throw_exception( char *msgStr, VirtProcr *reqstPr, VMSExcp *excpData )
|
|
Me@54
|
808 {
|
|
msach@69
|
809 printf("%s",msgStr);
|
|
Me@54
|
810 fflush(stdin);
|
|
Me@54
|
811 exit(1);
|
|
Me@54
|
812 }
|
|
Me@54
|
813
|