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