- Timestamp:
- May 27, 2007, 1:03:27 PM (18 years ago)
- Location:
- branches/libc-0.6/src/emx/src/lib/sys
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/libc-0.6/src/emx/src/lib/sys/__spawnve.c
r2540 r3373 504 504 __atomic_cmpxchg32((volatile uint32_t *)(void *)&pEmbryo->pid, (uint32_t)resc.codeTerminate, ~0); 505 505 LIBCLOG_MSG("Spawned pid=%04lx (%ld)\n", resc.codeTerminate, resc.codeTerminate); 506 __libc_back_processWaitNotifyExec(resc.codeTerminate); 507 508 /* cleanup embryo and other stuff. */ 509 __libc_spmRelease(pEmbryo); 510 doInheritDone(); 506 507 /* 508 * If the service is running, notify it now. Otherwise wait until 509 * we're done waiting for the child finish inheriting us. 510 */ 511 int fDoneNotifyExec = __libc_back_processWaitNotifyAlreadyStarted(); 512 if (fDoneNotifyExec) 513 __libc_back_processWaitNotifyExec(resc.codeTerminate); 514 515 /* 516 * Delay a tiny bit while the child is starting up and doing the inheriting. 517 * If we figure that it's a libc child, we can wait a good deal longer. 518 */ 519 /** @todo add a SPM notification for when inherit is completed. */ 520 __LIBC_SPMLOADAVG LoadAvg; 521 unsigned uLoadAvgTS; 522 int fDoneInherit; 523 ULONG ulStart = fibGetMsCount(); 524 rc = 0; 525 while ( (fDoneInherit = pEmbryo->enmState > __LIBC_PROCSTATE_ALIVE 526 || (pEmbryo->pInherit == NULL && pEmbryo->pInheritLocked == NULL) 527 ) == 0 528 && fibGetMsCount() - ulStart <= 8) 529 { 530 DosSleep(!(rc++ % 7)); 531 __libc_spmGetLoadAvg(&LoadAvg, &uLoadAvgTS); /* SMP HACK */ 532 } 533 if ( !fDoneInherit 534 && pEmbryo->enmState == __LIBC_PROCSTATE_ALIVE) 535 { 536 LIBCLOG_MSG("libc child - wait some more (rc=%d)\n", rc); 537 rc = 0; 538 __libc_spmGetLoadAvg(&LoadAvg, &uLoadAvgTS); /* SMP HACK */ 539 while ( (fDoneInherit = pEmbryo->enmState > __LIBC_PROCSTATE_ALIVE 540 || (pEmbryo->pInherit == NULL && pEmbryo->pInheritLocked == NULL) 541 ) == 0 542 && fibGetMsCount() - ulStart <= 100) 543 { 544 DosSleep(!(rc++ % 7)); 545 __libc_spmGetLoadAvg(&LoadAvg, &uLoadAvgTS); /* SMP HACK */ 546 } 547 } 548 LIBCLOG_MSG("fDoneInherit=%d rc=%d enmState=%d inh=%p,%p - waited %d ms\n", 549 fDoneInherit, rc, pEmbryo->enmState, pEmbryo->pInherit, pEmbryo->pInheritLocked, fibGetMsCount() - ulStart); 550 551 /* 552 * Do cleanups unless we're in an exec in which case we wish to 553 * get some more stuff done before we do the clean ups. 554 */ 555 if ((ulMode & 0xff) != P_OVERLAY) 556 { 557 doInheritDone(); 558 if (!fDoneNotifyExec) 559 __libc_back_processWaitNotifyExec(resc.codeTerminate); 560 __libc_spmRelease(pEmbryo); 561 _fmutex_release(&__libc_gmtxExec); 562 } 511 563 if (pszArgsBuf != NULL) 512 564 _tfree(pszArgsBuf); 513 _fmutex_release(&__libc_gmtxExec);514 565 515 566 /* … … 562 613 563 614 /* 564 * Wait 615 * Wait a bit more for the child to catch on since we're going to 616 * close all file handles next and that we certainly screw up tcpip 617 * handles in the child if they aren't already passed along. 618 */ 619 if (!fDoneInherit) 620 { 621 LIBCLOG_MSG("waiting some more...\n"); 622 do 623 { 624 DosSleep(!(rc++ % 3)); 625 __libc_spmGetLoadAvg(&LoadAvg, &uLoadAvgTS); /* SMP HACK */ 626 fDoneInherit = pEmbryo->enmState > __LIBC_PROCSTATE_ALIVE 627 || (pEmbryo->pInherit == NULL && pEmbryo->pInheritLocked == NULL); 628 } while (!fDoneInherit 629 && fibGetMsCount() - ulStart <= 200); 630 LIBCLOG_MSG("fDoneInherit=%d rc=%d enmState=%d inh=%p,%p - waited %d ms\n", 631 fDoneInherit, rc, pEmbryo->enmState, pEmbryo->pInherit, pEmbryo->pInheritLocked, fibGetMsCount() - ulStart); 632 } 633 634 if (!fDoneNotifyExec) 635 __libc_back_processWaitNotifyExec(resc.codeTerminate); 636 __libc_spmRelease(pEmbryo); 637 doInheritDone(); 638 _fmutex_release(&__libc_gmtxExec); 639 640 /* 641 * Shut down the process... 642 */ 643 _rmtmp(); 644 __libc_fhExecDone(); 645 646 /* 647 * Wait for the child to complete and forward stuff while doing so... 565 648 */ 566 649 pid_t pid = resc.codeTerminate; -
branches/libc-0.6/src/emx/src/lib/sys/b_process.h
r1631 r3373 4 4 * LIBC Backend - Process Internals. 5 5 * 6 * Copyright (c) 2004 knut st. osmundsen <bird-srcspam@anduin.net>6 * Copyright (c) 2004-2007 knut st. osmundsen <bird-srcspam@anduin.net> 7 7 * 8 8 * … … 37 37 38 38 void __libc_back_processWaitNotifyTerm(void); 39 int __libc_back_processWaitNotifyAlreadyStarted(void); 39 40 void __libc_back_processWaitNotifyExec(pid_t pid); 40 41 void __libc_back_processWaitNotifyChild(siginfo_t *pSigInfo); -
branches/libc-0.6/src/emx/src/lib/sys/b_processWait.c
r2786 r3373 603 603 } 604 604 return -ENOMEM; 605 } 606 607 608 /** 609 * Checks whether the service has already been started. 610 * 611 * @return 1 if started, 0 if not. 612 */ 613 int __libc_back_processWaitNotifyAlreadyStarted(void) 614 { 615 return gtidThread != 0; 605 616 } 606 617 -
branches/libc-0.6/src/emx/src/lib/sys/filehandles.c
r3098 r3373 552 552 553 553 554 /** 555 * Called as a response to a successful exec so we can close 556 * all open files. 557 */ 558 void __libc_fhExecDone(void) 559 { 560 LIBCLOG_ENTER(""); 561 562 /* 563 * This isn't thread safe, but there shouldn't be any threads 564 * around so it'll have to do for now. 565 */ 566 unsigned iFH; 567 for (iFH = 0; iFH < gcFHs; iFH++) 568 { 569 __LIBC_PFH pFH = gpapFHs[iFH]; 570 if (pFH) 571 __libc_FHClose(iFH); 572 } 573 574 LIBCLOG_RETURN_VOID(); 575 } 576 577 554 578 555 579 #undef __LIBC_LOG_GROUP -
branches/libc-0.6/src/emx/src/lib/sys/sharedpm.c
r2425 r3373 2791 2791 2792 2792 /* update state and insert at head of that state list. */ 2793 pProcess->enmState = __LIBC_PROCSTATE_ALIVE; 2793 LIBC_ASSERT(sizeof(pProcess->enmState) == sizeof(int)); 2794 __lxchg((int volatile *)&pProcess->enmState, __LIBC_PROCSTATE_ALIVE); 2794 2795 pProcess->pNext = gpSPMHdr->apHeads[__LIBC_PROCSTATE_ALIVE]; 2795 2796 if (pProcess->pNext) -
branches/libc-0.6/src/emx/src/lib/sys/syscalls.h
r2323 r3373 146 146 EXTERN _fmutex __libc_gmtxExec INIT({0}); 147 147 #endif 148 void __libc_fhExecDone(void); 148 149 /** @} */ 149 150
Note:
See TracChangeset
for help on using the changeset viewer.