Changeset 1631
- Timestamp:
- Nov 14, 2004, 8:03:24 PM (21 years ago)
- Location:
- trunk/src/emx
- Files:
-
- 12 edited
-
include/InnoTekLIBC/sharedpm.h (modified) (1 diff, 1 prop)
-
src/lib/process/beginthr.c (modified) (1 diff, 1 prop)
-
src/lib/process/waitpid.c (modified) (2 diffs, 1 prop)
-
src/lib/sys/__select.c (modified) (6 diffs, 1 prop)
-
src/lib/sys/__spawnve.c (modified) (2 diffs, 1 prop)
-
src/lib/sys/b_process.h (modified) (1 diff, 1 prop)
-
src/lib/sys/b_processWait.c (modified) (22 diffs, 1 prop)
-
src/lib/sys/b_signalStack.c (modified) (1 diff, 1 prop)
-
src/lib/sys/backend.h (modified) (1 diff, 1 prop)
-
src/lib/sys/libcfork.c (modified) (3 diffs, 1 prop)
-
src/lib/sys/sharedpm.c (modified) (5 diffs, 1 prop)
-
src/lib/sys/signals.c (modified) (11 diffs, 1 prop)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/emx/include/InnoTekLIBC/sharedpm.h
-
Property cvs2svn:cvs-rev
changed from
1.17to1.18
r1630 r1631 675 675 676 676 /** 677 678 679 680 681 682 683 684 685 686 687 688 677 689 * Identificators which can be obtained using __libc_spmGetId(). 678 690 */ -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/process/beginthr.c
-
Property cvs2svn:cvs-rev
changed from
1.12to1.13
r1630 r1631 101 101 int rc = __libc_back_threadCreate(pfnStart, cbStack, pvArg, 0); 102 102 if (rc >= 0) 103 LIBCLOG_RETURN_INT( -1);103 LIBCLOG_RETURN_INT(); 104 104 errno = -rc; 105 105 LIBCLOG_RETURN_INT(-1); -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/process/waitpid.c
-
Property cvs2svn:cvs-rev
changed from
1.5to1.6
r1630 r1631 84 84 /* do the call */ 85 85 siginfo_t SigInfo = {0}; 86 int rc = waitid(P_ALL, 0, &SigInfo, WEXITED);86 int rc = waitid(P_ALL, 0, &SigInfo, WEXITED); 87 87 if (!rc) 88 88 { … … 108 108 SigInfo.si_pid, SigInfo.si_pid, iStatus); 109 109 } 110 errno = -rc; 111 LIBCLOG_RETURN_INT(-1); 110 LIBCLOG_RETURN_INT(rc); 112 111 } 113 112 -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/sys/__select.c
-
Property cvs2svn:cvs-rev
changed from
1.6to1.7
r1630 r1631 27 27 #include "libc-alias.h" 28 28 #define INCL_FSMACROS 29 #define INCL_DOSPROCESS 29 #define INCL_DOSSEMAPHORES 30 #define INCL_ERRORS 30 31 #include <os2emx.h> 31 32 #include <stdlib.h> … … 37 38 #include <emx/syscalls.h> 38 39 #include "syscalls.h" 40 39 41 40 42 … … 48 50 int rc; 49 51 if (!tv) 50 rc = Dos Sleep(~0);52 rc = Dos); 51 53 else 52 54 { … … 54 56 if (!cMillies && tv->tv_usec) 55 57 cMillies = 1; 56 rc = Dos Sleep(cMillies);58 rc = DoscMillies); 57 59 } 58 60 FS_RESTORE(); … … 61 63 * Return. 62 64 */ 63 if (!rc )65 if (!rc) 64 66 return 0; 65 67 errno = __libc_native2errno(rc); … … 174 176 rc = pfnSelect(nfds, readfds, writefds, exceptfds, tv, &rc2); 175 177 } 176 else if (tv)177 {178 FS_VAR();179 /* wait for the given amount of time. */180 rc2 = rc = 0;181 FS_SAVE_LOAD();182 DosSleep(tv->tv_sec * 1000 + tv->tv_usec / 1000);183 FS_RESTORE();184 }185 178 else 186 179 { -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/sys/__spawnve.c
-
Property cvs2svn:cvs-rev
changed from
1.12to1.13
r1630 r1631 275 275 276 276 /* 277 * Notify the process waiter system.278 */279 __libc_back_processWaitNotifyExec();280 281 /*282 277 * Create the process. 283 278 */ … … 290 285 __atomic_cmpxchg32((volatile uint32_t *)(void *)&pEmbryo->pid, (uint32_t)resc.codeTerminate, 0); 291 286 LIBCLOG_MSG("Spawned pid=%04lx (%ld)\n", resc.codeTerminate, resc.codeTerminate); 287 292 288 293 289 /* cleanup embryo and other stuff. */ -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/sys/b_process.h
-
Property cvs2svn:cvs-rev
changed from
1.1to1.2
r1630 r1631 37 37 38 38 void __libc_back_processWaitNotifyTerm(void); 39 void __libc_back_processWaitNotifyExec( void);39 void __libc_back_processWaitNotifyExec(id); 40 40 void __libc_back_processWaitNotifyChild(siginfo_t *pSigInfo); 41 41 void __libc_back_processWaitNotifyNoWait(int fNoWaitStatus); -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/sys/b_processWait.c
-
Property cvs2svn:cvs-rev
changed from
1.3to1.4
r1630 r1631 84 84 85 85 86 87 88 89 90 91 92 93 94 95 96 97 98 86 99 87 100 /******************************************************************************* … … 102 115 /** Index into the preallocated nodes. */ 103 116 static volatile unsigned giWaitPreAlloced; 117 118 119 120 121 122 123 124 104 125 105 126 /** If this flag is set we don't care for wait status info. … … 110 131 /** The event semaphore the callers are sleeping on. */ 111 132 static volatile HEV ghevWait; 133 134 112 135 113 136 /** Thread ID of the wait thread. */ 114 137 static volatile TID gtidThread; 115 138 /** Termination indicator. Used to help the wait thread terminate fast. */ 116 static volatile intgfTerminate;139 static volatile gfTerminate; 117 140 118 141 … … 146 169 if (rc) 147 170 abort(); 171 172 173 174 148 175 149 176 /* done */ … … 164 191 { 165 192 /* kill the thread */ 166 gfTerminate = TRUE; 193 __atomic_xchg(&gfTerminate, 1); 194 DosKillThread(gtidThread); 167 195 gtidThread = 0; 168 DosKillThread(gtidThread); 169 170 /* destroy the event semaphore. */ 171 HEV hev = ghevWait; 172 ghevWait = NULLHANDLE; 173 if (hev) 174 DosPostEventSem(hev); 196 } 197 198 /* destroy the birth event semaphore. */ 199 HEV hev = ghevBirth; 200 ghevBirth = NULLHANDLE; 201 if (hev) 202 { 203 DosPostEventSem(hev); 204 DosCloseEventSem(hev); 205 } 206 207 /* destroy the wait event semaphore. */ 208 hev = ghevWait; 209 ghevWait = NULLHANDLE; 210 if (hev) 211 { 212 DosPostEventSem(hev); 213 DosCloseEventSem(hev); 175 214 } 176 215 } … … 218 257 pWait->pNext = NULL; 219 258 pWait->pPrev = gpWaitTail; 220 if (!pWait->pPrev) 259 if (pWait->pPrev) 260 pWait->pPrev->pNext = pWait; 261 else 221 262 gpWaitHead = pWait; 222 263 gpWaitTail = pWait; … … 233 274 PTIB pTib; 234 275 DosGetInfoBlocks(&pTib, &pPib); 276 235 277 236 278 /* … … 240 282 for (;!gfTerminate;) 241 283 { 242 for (;!gfTerminate;) 243 { 284 /* 285 * Check for exit condition. 286 */ 287 fInternalTerm = gfTerminate; 288 if (pPib->pib_flstatus & (0x40/*dying*/ | 0x04/*exiting all*/ | 0x02/*Exiting Thread 1*/ | 0x01/*ExitList */)) 289 { 290 LIBCLOG_MSG("Terminating thread, exit conditions detected. pib_flstatus=%#lx\n", pPib->pib_flstatus); 291 fInternalTerm = 1; 292 } 293 294 /* 295 * Wait for children. 296 */ 297 WAITINFO Wait; 298 int rc = waitChild(&Wait, fInternalTerm, 0 /* any child */); 299 if (!rc) 300 { 301 /* enter semaphore protection. */ 302 rc = waitSemRequest(1); 303 244 304 /* 245 * Check for exit condition.305 * 246 306 */ 247 fInternalTerm = gfTerminate; 248 if (pPib->pib_flstatus & (0x40/*dying*/ | 0x04/*exiting all*/ | 0x02/*Exiting Thread 1*/ | 0x01/*ExitList */)) 307 if (!gfNoWaitStatus) 308 waitAllocInsert(&Wait); 309 310 /* 311 * Increment death number and decrement number of (known) children. 312 */ 313 __atomic_increment(&gcDeaths); 314 315 /* 316 * Remove the child from the list. 317 */ 318 PWAITCHILD pPrev = NULL; 319 PWAITCHILD pChild = gpChildrenHead; 320 while (pChild) 249 321 { 250 LIBCLOG_MSG("Terminating thread, exit conditions detected. pib_flstatus=%#lx\n", pPib->pib_flstatus); 251 fInternalTerm = TRUE; 322 if (pChild->pid == Wait.pid) 323 { 324 if (pPrev) 325 pPrev->pNext = pChild->pNext; 326 else 327 gpChildrenHead = pChild->pNext; 328 __atomic_decrement_min(&gcChildren, 0); 329 break; 330 } 331 332 /* next */ 333 pPrev = pChild; 334 pChild = pChild->pNext; 252 335 } 253 336 254 337 /* 255 * Wa it for children.338 * Wa. 256 339 */ 257 WAITINFO Wait; 258 int rc = waitChild(&Wait, fInternalTerm, 0 /* any child */); 340 if (DosPostEventSem(ghevWait) == ERROR_INVALID_HANDLE) 341 fInternalTerm = 1; 342 343 /* 344 * Leave semaphore protection and wait again unless someone's hinting it's time to quit... 345 */ 259 346 if (!rc) 260 { 261 /* 262 * Need we bother inserting it? 263 */ 264 rc = waitSemRequest(1); 265 if (!rc && !gfNoWaitStatus) 266 rc = waitAllocInsert(&Wait); 267 268 /* 269 * Wake up any waiters. 270 */ 271 int rcOS2 = DosPostEventSem(ghevWait); 272 if (!rc) 273 waitSemRelease(); 274 if (rc || (rcOS2 && rcOS2 != ERROR_TOO_MANY_POSTS && rcOS2 != ERROR_ALREADY_POSTED)) 275 fInternalTerm = 1; 276 rc = 0; 277 } 278 if (rc || fInternalTerm) 347 waitSemRelease(); 348 if (fInternalTerm) 279 349 break; 280 } 281 282 /* 283 * Check if we're encouraged to quit. 284 */ 285 if (fInternalTerm || gfTerminate) 286 break; 350 continue; 351 } 287 352 288 353 /* … … 293 358 * using the nowait option on the API call. 294 359 */ 360 361 295 362 if (pPib->pib_flstatus & (0x40/*dying*/ | 0x04/*exiting all*/ | 0x02/*Exiting Thread 1*/ | 0x01/*ExitList */)) 296 363 { 297 364 LIBCLOG_MSG("Terminating thread, exit conditions detected. pib_flstatus=%#lx\n", pPib->pib_flstatus); 298 fInternalTerm = TRUE;365 fInternalTerm = ; 299 366 continue; 300 367 } 301 368 302 DosWaitEventSem(ghevWait, 30*1000); 369 if (rc == ERROR_WAIT_NO_CHILDREN) 370 { 371 DosWaitEventSem(ghevBirth, 5*1000); 372 ULONG cIgnore; 373 if (DosResetEventSem(ghevBirth, &cIgnore) == ERROR_INVALID_HANDLE) 374 fInternalTerm = 1; 375 } 376 else 377 LIBC_ASSERTM_FAILED("waitChild -> rc=%d expected ERROR_WAIT_NO_CHILDREN!\n", rc); 303 378 } 304 379 … … 485 560 * it's time to start collect child status codes. 486 561 */ 487 void __libc_back_processWaitNotifyExec(void) 488 { 489 if (gtidThread) 490 return; 491 562 void __libc_back_processWaitNotifyExec(pid_t pid) 563 { 564 PWAITCHILD pChild = _hmalloc(sizeof(*pChild)); 492 565 waitSemRequest(0); 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 493 585 if (!gtidThread) 494 586 { … … 500 592 { 501 593 gtidThread = tid; 502 LIBCLOG_MSG2("Create waitThread! tid=%#x (%d)\n", tid, tid);594 LIBCLOG_MSG2("Create waitThread! tid=%#x (%d)\n", tid, tid); 503 595 } 504 596 else … … 509 601 } 510 602 } 603 511 604 waitSemRelease(); 512 605 } … … 530 623 __atomic_xchg(&gfNoWaitStatus, fNoWaitStatus); 531 624 } 625 532 626 533 627 /** … … 571 665 /* insert it */ 572 666 waitInsertFIFO(pWait); 667 573 668 } 574 669 else … … 619 714 620 715 /* 621 * Make sure there is a worker around.622 */623 if (!gtidThread)624 __libc_back_processWaitNotifyExec();625 626 /*627 716 * Validate options. 628 717 */ … … 676 765 LIBCLOG_RETURN_MSG(rc, "%d mutex\n", rc); 677 766 unsigned cIterations = 0; 767 678 768 for (;; cIterations++) 679 769 { … … 682 772 */ 683 773 WAITINFO Wait; 774 775 776 684 777 PWAITINFO pInfo = gpWaitHead; 685 778 while (pInfo) … -
Property cvs2svn:cvs-rev
changed from
