- Timestamp:
- Apr 15, 2007, 5:27:12 AM (18 years ago)
- Location:
- branches/libc-0.6/src/emx
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/libc-0.6/src/emx/include/InnoTekLIBC/backend.h
r2439 r3102 816 816 int __libc_Back_signalTimer(int iWhich, const struct itimerval *pValue, struct itimerval *pOldValue); 817 817 818 /** 819 * This is a hack to deal with potentially lost thread pokes. 820 * 821 * For some reason or another we loose the async signal in some situations. It's 822 * been observed happening after/when opening files (fopen), but it's not known 823 * whether this is really related or not. 824 */ 825 void __libc_Back_signalLostPoke(void); 818 826 819 827 -
branches/libc-0.6/src/emx/src/lib/libc.def
r2896 r3102 1958 1958 "__std_nanf" @1956 1959 1959 "__std_nanl" @1957 1960 "___libc_Back_signalLostPoke" @1958 1960 1961 1962 -
branches/libc-0.6/src/emx/src/lib/process/fmutex.c
r2282 r3102 17 17 #define __LIBC_LOG_GROUP __LIBC_LOG_GRP_MUTEX 18 18 #include <InnoTekLIBC/logstrict.h> 19 #include <InnoTekLIBC/thread.h> 19 20 #include <InnoTekLIBC/backend.h> 20 21 … … 200 201 FS_SAVE_LOAD(); 201 202 DosEnterMustComplete(&ulNesting); 203 if (ulNesting == 1) /* This is a hack to catch lost poke signals. */ 204 { 205 __LIBC_PTHREAD pThrd = __libc_threadCurrentNoAuto(); 206 if (pThrd && pThrd->fSigBeingPoked) 207 { 208 DosExitMustComplete(&ulNesting); 209 __libc_Back_signalLostPoke(); 210 DosEnterMustComplete(&ulNesting); 211 } 212 } 202 213 fs = __cxchg(&sem->fs, _FMS_OWNED_SIMPLE); 203 214 if (fs == _FMS_AVAILABLE) … … 214 225 if (rc) 215 226 { 227 DosExitMustComplete(&ulNesting); 216 228 LIBC_ASSERTM_FAILED("Failed to create event semaphore for fmutex '%s', rc=%d. flags=%#x\n", sem->pszDesc, rc, sem->flags); 217 229 FS_RESTORE(); … … 332 344 LIBCLOG_ENTER("sem=%p{.pszDesc=%s}\n", (void *)sem, sem->pszDesc); 333 345 ULONG ulNesting; 346 347 int rc = 0; 334 348 __atomic_xchg(&sem->Owner, 0); 335 349 signed char fs = __cxchg(&sem->fs, _FMS_AVAILABLE); 336 if (fs != _FMS_OWNED_HARD) 337 { 338 FS_VAR_SAVE_LOAD(); 339 DosExitMustComplete(&ulNesting); 340 FS_RESTORE(); 341 LIBCLOG_RETURN_UINT(0); 342 } 343 else 344 { 345 int rc = __fmutex_release_internal (sem); 346 FS_VAR_SAVE_LOAD(); 347 DosExitMustComplete(&ulNesting); 348 FS_RESTORE(); 349 LIBCLOG_RETURN_UINT(rc); 350 } 350 if (fs == _FMS_OWNED_HARD) 351 rc = __fmutex_release_internal (sem); 352 353 FS_VAR_SAVE_LOAD(); 354 DosExitMustComplete(&ulNesting); 355 FS_RESTORE(); 356 357 /* This is a hack to catch lost poke signals. */ 358 if (!ulNesting) 359 { 360 __LIBC_PTHREAD pThrd = __libc_threadCurrentNoAuto(); 361 if (pThrd && pThrd->fSigBeingPoked) 362 __libc_Back_signalLostPoke(); 363 } 364 365 LIBCLOG_RETURN_UINT(rc); 351 366 } 352 367 -
branches/libc-0.6/src/emx/src/lib/sys/signals.c
r2518 r3102 2478 2478 if (!pThrdPoke->fSigBeingPoked) 2479 2479 { 2480 DosSuspendThread(pThrdPoke->tid); 2480 2481 __atomic_xchg(&pThrdPoke->fSigBeingPoked, 1); 2481 2482 int rc = DosKillThread(pThrdPoke->tid); 2483 DosResumeThread(pThrdPoke->tid); 2482 2484 if (rc) 2485 { 2486 __atomic_xchg(&pThrdPoke->fSigBeingPoked, 0); 2483 2487 LIBC_ASSERTM_FAILED("DosKillThread(%d) -> rc=%d\n", pThrdPoke->tid, rc); 2488 } 2484 2489 } 2485 2490 … … 2532 2537 2533 2538 return -EINVAL; 2539 } 2540 2541 2542 /** 2543 * This is a hack to deal with potentially lost thread pokes. 2544 * 2545 * For some reason or another we loose the async signal in some situations. It's 2546 * been observed happening after/when opening files (fopen), but it's not known 2547 * whether this is really related or not. 2548 */ 2549 void __libc_Back_signalLostPoke(void) 2550 { 2551 LIBCLOG_ENTER("\n"); 2552 __LIBC_PTHREAD pThrd = __libc_threadCurrentNoAuto(); 2553 if (pThrd && pThrd->fSigBeingPoked) 2554 { 2555 ULONG ulSigLastTS = pThrd->ulSigLastTS; 2556 DosSleep(0); 2557 if ( pThrd->fSigBeingPoked 2558 && pThrd->ulSigLastTS == ulSigLastTS) 2559 { 2560 DosSleep(0); 2561 if ( pThrd->fSigBeingPoked 2562 && pThrd->ulSigLastTS == ulSigLastTS) 2563 { 2564 2565 int rc = __libc_back_signalSemRequest(); 2566 if (!rc) 2567 { 2568 if ( pThrd->fSigBeingPoked 2569 && pThrd->ulSigLastTS == ulSigLastTS) 2570 { 2571 /* 2572 * Clear the indicator and deliver signals (releaseing the semaphore). 2573 */ 2574 __atomic_xchg(&pThrd->fSigBeingPoked, 0); 2575 signalDeliver(pThrd, 0, NULL); 2576 LIBCLOG_RETURN_VOID(); 2577 return; 2578 } 2579 __libc_back_signalSemRelease(); 2580 } 2581 } 2582 } 2583 } 2584 LIBCLOG_RETURN_VOID(); 2534 2585 } 2535 2586
Note:
See TracChangeset
for help on using the changeset viewer.