Mercurial > cgi-bin > hgwebdir.cgi > VMS > VMS_Implementations > VSs_impls > VSs__MC_shared_impl
comparison VSs.c @ 40:df464a215387
add implementations of (some) nanos api functions
| author | Nina Engelhardt <nengel@mailbox.tu-berlin.de> |
|---|---|
| date | Mon, 03 Jun 2013 18:49:19 +0200 |
| parents | a951b38d2cfc |
| children | 8733d1299c3a |
comparison
equal
deleted
inserted
replaced
| 30:010f2f004282 | 31:2d08410d3a2f |
|---|---|
| 92 //seed slave is a thread slave, so make a thread's task stub for it | 92 //seed slave is a thread slave, so make a thread's task stub for it |
| 93 // and then make another to stand for the seed's parent task. Make | 93 // and then make another to stand for the seed's parent task. Make |
| 94 // the parent be already ended, and have one child (the seed). This | 94 // the parent be already ended, and have one child (the seed). This |
| 95 // will make the dissipate handler do the right thing when the seed | 95 // will make the dissipate handler do the right thing when the seed |
| 96 // is dissipated. | 96 // is dissipated. |
| 97 threadTaskStub = create_thread_task_stub( initData ); | 97 threadTaskStub = create_thread_task_stub( initData); |
| 98 parentTaskStub = create_thread_task_stub( NULL ); | 98 parentTaskStub = create_thread_task_stub( NULL ); |
| 99 parentTaskStub->isEnded = TRUE; | 99 parentTaskStub->isEnded = TRUE; |
| 100 parentTaskStub->numLiveChildThreads = 1; //so dissipate works for seed | 100 parentTaskStub->numLiveChildThreads = 1; //so dissipate works for seed |
| 101 threadTaskStub->parentTaskStub = parentTaskStub; | 101 threadTaskStub->parentTaskStub = parentTaskStub; |
| 102 threadTaskStub->slaveAssignedTo = seedSlv; | 102 threadTaskStub->slaveAssignedTo = seedSlv; |
| 246 semanticEnv->freeExtraTaskSlvQ = makeVMSQ(); | 246 semanticEnv->freeExtraTaskSlvQ = makeVMSQ(); |
| 247 semanticEnv->taskReadyQ = makeVMSQ(); | 247 semanticEnv->taskReadyQ = makeVMSQ(); |
| 248 | 248 |
| 249 semanticEnv->argPtrHashTbl = makeHashTable32( 20, &free_pointer_entry ); | 249 semanticEnv->argPtrHashTbl = makeHashTable32( 20, &free_pointer_entry ); |
| 250 semanticEnv->commHashTbl = makeHashTable32( 16, &VMS_int__free ); | 250 semanticEnv->commHashTbl = makeHashTable32( 16, &VMS_int__free ); |
| 251 semanticEnv->criticalHashTbl = makeHashTable32( 16, &VMS_int__free ); | |
| 251 | 252 |
| 252 semanticEnv->nextCoreToGetNewSlv = 0; | 253 semanticEnv->nextCoreToGetNewSlv = 0; |
| 253 | 254 |
| 254 semanticEnv->numInFlightTasks = 0; | 255 semanticEnv->numInFlightTasks = 0; |
| 255 semanticEnv->deferredSubmitsQ = makeVMSQ(); | 256 semanticEnv->deferredSubmitsQ = makeVMSQ(); |
| 264 semanticEnv->fnSingletons[i].endInstrAddr = NULL; | 265 semanticEnv->fnSingletons[i].endInstrAddr = NULL; |
| 265 semanticEnv->fnSingletons[i].hasBeenStarted = FALSE; | 266 semanticEnv->fnSingletons[i].hasBeenStarted = FALSE; |
| 266 semanticEnv->fnSingletons[i].hasFinished = FALSE; | 267 semanticEnv->fnSingletons[i].hasFinished = FALSE; |
| 267 semanticEnv->fnSingletons[i].waitQ = makeVMSQ(); | 268 semanticEnv->fnSingletons[i].waitQ = makeVMSQ(); |
| 268 semanticEnv->transactionStrucs[i].waitingVPQ = makeVMSQ(); | 269 semanticEnv->transactionStrucs[i].waitingVPQ = makeVMSQ(); |
| 269 semanticEnv->criticalSection[i].isOccupied = FALSE; | |
| 270 semanticEnv->criticalSection[i].waitQ = makeVMSQ(); | |
| 271 #ifdef HOLISTIC__TURN_ON_PERF_COUNTERS | |
| 272 semanticEnv->criticalSection[i].previous.vp = 0; | |
| 273 semanticEnv->criticalSection[i].previous.task = 0; | |
| 274 #endif | |
| 275 } | 270 } |
| 276 | 271 |
| 277 semanticEnv->numLiveExtraTaskSlvs = 0; //must be last | 272 semanticEnv->numLiveExtraTaskSlvs = 0; //must be last |
| 278 semanticEnv->numLiveThreadSlvs = 1; //must be last, counts the seed | 273 semanticEnv->numLiveThreadSlvs = 1; //must be last, counts the seed |
| 279 | 274 |
| 442 } | 437 } |
| 443 int i; | 438 int i; |
| 444 for (i = 0; i < NUM_STRUCS_IN_SEM_ENV; i++) { | 439 for (i = 0; i < NUM_STRUCS_IN_SEM_ENV; i++) { |
| 445 freePrivQ(semanticEnv->fnSingletons[i].waitQ); | 440 freePrivQ(semanticEnv->fnSingletons[i].waitQ); |
| 446 freePrivQ(semanticEnv->transactionStrucs[i].waitingVPQ); | 441 freePrivQ(semanticEnv->transactionStrucs[i].waitingVPQ); |
| 447 freePrivQ(semanticEnv->criticalSection[i].waitQ); | |
| 448 } | 442 } |
| 449 | 443 |
| 450 freePrivQ(semanticEnv->freeExtraTaskSlvQ); | 444 freePrivQ(semanticEnv->freeExtraTaskSlvQ); |
| 451 freePrivQ(semanticEnv->slavesReadyToResumeQ); | 445 freePrivQ(semanticEnv->slavesReadyToResumeQ); |
| 452 freePrivQ(semanticEnv->taskReadyQ); | 446 freePrivQ(semanticEnv->taskReadyQ); |
| 453 freePrivQ(semanticEnv->deferredSubmitsQ); | 447 freePrivQ(semanticEnv->deferredSubmitsQ); |
| 454 freeHashTable(semanticEnv->argPtrHashTbl); | 448 freeHashTable(semanticEnv->argPtrHashTbl); |
| 455 freeHashTable(semanticEnv->commHashTbl); | 449 freeHashTable(semanticEnv->commHashTbl); |
| 450 freeHashTable(semanticEnv->criticalHashTbl); | |
| 456 VMS_int__free(semanticEnv->coreIsDone); | 451 VMS_int__free(semanticEnv->coreIsDone); |
| 457 VMS_int__free(_VMSMasterEnv->semanticEnv); | 452 VMS_int__free(_VMSMasterEnv->semanticEnv); |
| 458 | 453 |
| 459 VMS_SS__cleanup_at_end_of_shutdown(); | 454 VMS_SS__cleanup_at_end_of_shutdown(); |
| 460 } | 455 } |
| 501 | 496 |
| 502 //=========================================================================== | 497 //=========================================================================== |
| 503 | 498 |
| 504 | 499 |
| 505 //======================= task submit and end ============================== | 500 //======================= task submit and end ============================== |
| 501 | |
| 506 /* | 502 /* |
| 507 */ | 503 */ |
| 508 void | 504 void VSs__submit_task(VSsTaskType *taskType, void *args, void* deps) { |
| 509 VSs__submit_task( VSsTaskType *taskType, void *args) | 505 VSsSemReq reqData; |
| 510 { VSsSemReq reqData; | 506 |
| 511 | 507 reqData.reqType = submit_task; |
| 512 reqData.reqType = submit_task; | 508 |
| 513 | 509 reqData.taskType = taskType; |
| 514 reqData.taskType = taskType; | 510 reqData.args = args; |
| 515 reqData.args = args; | 511 reqData.deps = deps; |
| 516 reqData.callingSlv = currVP; | 512 reqData.callingSlv = currVP; |
| 517 | 513 |
| 518 reqData.taskID = NULL; | 514 reqData.taskID = NULL; |
| 519 | 515 |
| 520 VMS_WL__send_sem_request( &reqData, currVP ); | 516 VMS_WL__send_sem_request(&reqData, currVP); |
| 521 } | 517 } |
| 522 | 518 |
| 523 int32 * | 519 int32 * |
| 524 VSs__create_taskID_of_size( int32 numInts) | 520 VSs__create_taskID_of_size( int32 numInts) |
| 525 { int32 *taskID; | 521 { int32 *taskID; |
| 526 | 522 |
| 527 taskID = VMS_WL__malloc( sizeof(int32) + numInts * sizeof(int32) ); | 523 taskID = VMS_WL__malloc( sizeof(int32) + numInts * sizeof(int32) ); |
| 528 taskID[0] = numInts; | 524 taskID[0] = numInts; |
| 529 return taskID; | 525 return taskID; |
| 530 } | 526 } |
| 531 | 527 |
| 532 void | 528 void VSs__submit_task_with_ID(VSsTaskType *taskType, void *args, void* deps, int32 *taskID) { |
| 533 VSs__submit_task_with_ID( VSsTaskType *taskType, void *args, int32 *taskID) | 529 VSsSemReq reqData; |
| 534 { VSsSemReq reqData; | 530 |
| 535 | 531 reqData.reqType = submit_task; |
| 536 reqData.reqType = submit_task; | 532 |
| 537 | 533 reqData.taskType = taskType; |
| 538 reqData.taskType = taskType; | 534 reqData.args = args; |
| 539 reqData.args = args; | 535 reqData.deps = deps; |
| 540 reqData.taskID = taskID; | 536 reqData.taskID = taskID; |
| 541 reqData.callingSlv = currVP; | 537 reqData.callingSlv = currVP; |
| 542 | 538 |
| 543 VMS_WL__send_sem_request( &reqData, currVP ); | 539 VMS_WL__send_sem_request(&reqData, currVP); |
| 544 } | 540 } |
| 545 | 541 |
| 546 | 542 |
| 547 /*This call is the last to happen in every task. It causes the slave to | 543 /*This call is the last to happen in every task. It causes the slave to |
| 548 * suspend and get the next task out of the task-queue. Notice there is no | 544 * suspend and get the next task out of the task-queue. Notice there is no |
| 549 * assigner here.. only one slave, no slave ReadyQ, and so on.. | 545 * assigner here.. only one slave, no slave ReadyQ, and so on.. |
| 598 | 594 |
| 599 VMS_WL__send_sem_request( &reqData, currVP ); | 595 VMS_WL__send_sem_request( &reqData, currVP ); |
| 600 } | 596 } |
| 601 | 597 |
| 602 void | 598 void |
| 603 VSs__start_critical(int32 name){ | 599 VSs__start_critical(void* lock){ |
| 604 VSsSemReq reqData; | 600 VSsSemReq reqData; |
| 605 | 601 |
| 606 reqData.reqType = critical_start; | 602 reqData.reqType = critical_start; |
| 607 reqData.callingSlv = currVP; | 603 reqData.callingSlv = currVP; |
| 608 | 604 |
| 609 reqData.criticalID = name; | 605 reqData.criticalID = lock; |
| 610 | 606 |
| 611 VMS_WL__send_sem_request( &reqData, currVP ); | 607 VMS_WL__send_sem_request( &reqData, currVP ); |
| 612 } | 608 } |
| 613 | 609 |
| 614 void | 610 void |
| 615 VSs__end_critical(int32 name){ | 611 VSs__end_critical(void* lock){ |
| 616 VSsSemReq reqData; | 612 VSsSemReq reqData; |
| 617 | 613 |
| 618 reqData.reqType = critical_end; | 614 reqData.reqType = critical_end; |
| 619 reqData.callingSlv = currVP; | 615 reqData.callingSlv = currVP; |
| 620 | 616 |
| 621 reqData.criticalID = name; | 617 reqData.criticalID = lock; |
| 622 | 618 |
| 623 VMS_WL__send_sem_request( &reqData, currVP ); | 619 VMS_WL__send_sem_request( &reqData, currVP ); |
| 624 } | 620 } |
| 625 | 621 |
| 626 //========================== send and receive ============================ | 622 //========================== send and receive ============================ |
