comparison VSs.c @ 8:eb3d77ca9f59

Code complete -- not debuggedd yet
author Sean Halle <seanhalle@yahoo.com>
date Thu, 02 Aug 2012 01:03:14 -0700
parents 3999b8429ddd
children 832bc715fbf2
comparison
equal deleted inserted replaced
6:fb263b95cd61 7:ae096282b759
74 void 74 void
75 VSs__create_seed_slave_and_do_work( TopLevelFnPtr fnPtr, void *initData ) 75 VSs__create_seed_slave_and_do_work( TopLevelFnPtr fnPtr, void *initData )
76 { VSsSemEnv *semEnv; 76 { VSsSemEnv *semEnv;
77 SlaveVP *seedSlv; 77 SlaveVP *seedSlv;
78 VSsSemData *semData; 78 VSsSemData *semData;
79 VSsTaskStub *explPrTaskStub; 79 VSsTaskStub *threadTaskStub, *parentTaskStub;
80 80
81 VSs__init(); //normal multi-thd 81 VSs__init(); //normal multi-thd
82 82
83 semEnv = _VMSMasterEnv->semanticEnv; 83 semEnv = _VMSMasterEnv->semanticEnv;
84 84
85 //VSs starts with one processor, which is put into initial environ, 85 //VSs starts with one processor, which is put into initial environ,
86 // and which then calls create() to create more, thereby expanding work 86 // and which then calls create() to create more, thereby expanding work
87 seedSlv = VSs__create_slave_helper( fnPtr, initData, 87 seedSlv = VSs__create_slave_helper( fnPtr, initData,
88 semEnv, semEnv->nextCoreToGetNewSlv++ ); 88 semEnv, semEnv->nextCoreToGetNewSlv++ );
89 89
90 //seed slave is an explicit processor, so make one of the special 90 //seed slave is a thread slave, so make a thread's task stub for it
91 // task stubs for explicit processors, and attach it to the slave 91 // and then make another to stand for the seed's parent task. Make
92 explPrTaskStub = create_expl_proc_task_stub( initData ); 92 // the parent be already ended, and have one child (the seed). This
93 // will make the dissipate handler do the right thing when the seed
94 // is dissipated.
95 threadTaskStub = create_thread_task_stub( initData );
96 parentTaskStub = create_thread_task_stub( NULL );
97 parentTaskStub->isEnded = TRUE;
98 parentTaskStub->numLiveChildThreads = 1; //so dissipate works for seed
99 threadTaskStub->parentTasksStub = parentTaskStub;
93 100
94 semData = (VSsSemData *)seedSlv->semanticData; 101 semData = (VSsSemData *)seedSlv->semanticData;
95 //seedVP already has a permanent task 102 //seedVP is a thread, so has a permanent task
96 semData->needsTaskAssigned = FALSE; 103 semData->needsTaskAssigned = FALSE;
97 semData->taskStub = explPrTaskStub; 104 semData->taskStub = threadTaskStub;
98 105
99 resume_slaveVP( seedSlv, semEnv ); //returns right away, just queues Slv 106 resume_slaveVP( seedSlv, semEnv ); //returns right away, just queues Slv
100 107
101 VMS_SS__start_the_work_then_wait_until_done(); //normal multi-thd 108 VMS_SS__start_the_work_then_wait_until_done(); //normal multi-thd
102 109
237 semanticEnv->fnSingletons[i].hasFinished = FALSE; 244 semanticEnv->fnSingletons[i].hasFinished = FALSE;
238 semanticEnv->fnSingletons[i].waitQ = makeVMSQ(); 245 semanticEnv->fnSingletons[i].waitQ = makeVMSQ();
239 semanticEnv->transactionStrucs[i].waitingVPQ = makeVMSQ(); 246 semanticEnv->transactionStrucs[i].waitingVPQ = makeVMSQ();
240 } 247 }
241 248
242 semanticEnv->numAdditionalSlvs = 0; //must be last 249 semanticEnv->numLiveExtraTaskSlvs = 0; //must be last
250 semanticEnv->numLiveThreadSlvs = 1; //must be last, count the seed
243 251
244 #ifdef HOLISTIC__TURN_ON_OBSERVE_UCC 252 #ifdef HOLISTIC__TURN_ON_OBSERVE_UCC
245 semanticEnv->unitList = makeListOfArrays(sizeof(Unit),128); 253 semanticEnv->unitList = makeListOfArrays(sizeof(Unit),128);
246 semanticEnv->ctlDependenciesList = makeListOfArrays(sizeof(Dependency),128); 254 semanticEnv->ctlDependenciesList = makeListOfArrays(sizeof(Dependency),128);
247 semanticEnv->commDependenciesList = makeListOfArrays(sizeof(Dependency),128); 255 semanticEnv->commDependenciesList = makeListOfArrays(sizeof(Dependency),128);
413 * Normally, this would be the last line of the thread's top level function. 421 * Normally, this would be the last line of the thread's top level function.
414 * But, if the thread exits from any point, it has to do so by calling 422 * But, if the thread exits from any point, it has to do so by calling
415 * this. 423 * this.
416 * 424 *
417 *This must update the count of active sub-tasks (sub-threads) of parents, 425 *This must update the count of active sub-tasks (sub-threads) of parents,
418 * and the semantic data and task stub must stay 426 * and the semantic data and task stub must stay.
419 */ 427 */
420 void 428 void
421 VSs__end_thread( SlaveVP *thdToEnd ) 429 VSs__end_thread( SlaveVP *thdToEnd )
422 { 430 { VSsSemData *semData;
431
423 //check whether all sub-tasks have ended.. if not, don't free the 432 //check whether all sub-tasks have ended.. if not, don't free the
424 // semantic data nor task stub of this thread. 433 // semantic data nor task stub of this thread.
425 check_sub_tasks(); 434 semData = (VSsSemData *)thdToEnd->semanticData;
435 if( semData->taskStub->numLiveChildTasks != 0 )
436 {
437 fix_me();
438 }
426 439
427 //Update the count of live sub-tasks in parent. If parent was a 440 //Update the count of live sub-tasks in parent. If parent was a
428 // thread and has already ended, then if this was the last sub-task, 441 // thread and has already ended, then if this was the last sub-task,
429 // free the semantic data and task stub of the parent. 442 // free the semantic data and task stub of the parent.
443
430 VMS_WL__send_dissipate_req( thdToEnd ); 444 VMS_WL__send_dissipate_req( thdToEnd );
431 } 445 }
432 446
433 447
434 //=========================================================================== 448 //===========================================================================