Changeset 3849
- Timestamp:
- Mar 16, 2014, 10:17:54 PM (11 years ago)
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/libc-0.6/src/emx/src/lib/process/fmutex.c
r3102 r3849 148 148 for (;;) 149 149 { 150 rc = DosWaitEventSem(sem->hev, sem->flags & _FMC_SHARED ? SEM_INDEFINITE_WAIT : 3000); 150 ULONG cMsWait = sem->flags & _FMC_SHARED ? SEM_INDEFINITE_WAIT : 3000; 151 if (fibIsInExit()) 152 cMsWait = 250; 153 rc = DosWaitEventSem(sem->hev, cMsWait); 151 154 if (rc == ERROR_INTERRUPT) 152 155 { … … 165 168 if (rc != ERROR_TIMEOUT) 166 169 break; 170 167 171 /* 168 172 * Deadlock detection - check if owner is around. … … 179 183 } 180 184 } 185 181 186 FS_RESTORE(); 182 187 if (rc != 0) … … 284 289 for (;;) 285 290 { 286 DosExitMustComplete(&ulNesting); 287 rc = DosWaitEventSem(sem->hev, sem->flags & _FMC_SHARED ? SEM_INDEFINITE_WAIT : 3000); 291 ULONG cMsWait = sem->flags & _FMC_SHARED ? SEM_INDEFINITE_WAIT : 3000; 292 if (fibIsInExit()) 293 cMsWait = 250; 294 DosExitMustComplete(&ulNesting); 295 rc = DosWaitEventSem(sem->hev, cMsWait); 288 296 DosEnterMustComplete(&ulNesting); 289 297 if (rc == ERROR_INTERRUPT) … … 303 311 if (rc != ERROR_TIMEOUT) 304 312 break; 313 305 314 /* 306 315 * Deadlock detection - check if owner is around. … … 319 328 } 320 329 } 330 321 331 FS_RESTORE(); 322 332 if (rc != 0) … … 331 341 static void __fmutex_deadlock(_fmutex *pSem, const char *pszMsg) 332 342 { 333 __libc_Back_panic(0, NULL, 334 "fmutex deadlock: %s\n" 335 "%x: Owner=%x Self=%x fs=%x flags=%x hev=%x\n" 336 " Desc=\"%s\"\n", 337 pszMsg, 338 pSem, pSem->Owner, fibGetTidPid(), pSem->fs, pSem->flags, pSem->hev, 339 pSem->pszDesc); 343 if (!fibIsInExit()) 344 __libc_Back_panic(0, NULL, 345 "fmutex deadlock: %s\n" 346 "%x: Owner=%x Self=%x fs=%x flags=%x hev=%x\n" 347 " Desc=\"%s\"\n", 348 pszMsg, 349 pSem, pSem->Owner, fibGetTidPid(), pSem->fs, pSem->flags, pSem->hev, 350 pSem->pszDesc); 340 351 } 341 352 … … 377 388 { 378 389 FS_RESTORE(); 379 LIBCLOG_ RETURN_UINT(rc);390 LIBCLOG_ERROR_RETURN_UINT(rc); 380 391 } 381 392 -
trunk/libc/src/libc/process/os2/fmutex-os2.c
r2726 r3849 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 … … 147 148 for (;;) 148 149 { 149 rc = DosWaitEventSem(sem->hev, sem->flags & _FMC_SHARED ? SEM_INDEFINITE_WAIT : 3000); 150 ULONG cMsWait = sem->flags & _FMC_SHARED ? SEM_INDEFINITE_WAIT : 3000; 151 if (fibIsInExit()) 152 cMsWait = 250; 153 rc = DosWaitEventSem(sem->hev, cMsWait); 150 154 if (rc == ERROR_INTERRUPT) 151 155 { … … 164 168 if (rc != ERROR_TIMEOUT) 165 169 break; 170 166 171 /* 167 172 * Deadlock detection - check if owner is around. … … 178 183 } 179 184 } 185 180 186 FS_RESTORE(); 181 187 if (rc != 0) … … 200 206 FS_SAVE_LOAD(); 201 207 DosEnterMustComplete(&ulNesting); 208 #if 0 /** @todo lost signal / kernel boundrary */ 209 if (ulNesting == 1) /* This is a hack to catch lost poke signals. */ 210 { 211 __LIBC_PTHREAD pThrd = __libc_threadCurrentNoAuto(); 212 if (pThrd && pThrd->fSigBeingPoked) 213 { 214 DosExitMustComplete(&ulNesting); 215 __libc_Back_signalLostPoke(); 216 DosEnterMustComplete(&ulNesting); 217 } 218 } 219 #endif 202 220 fs = __cxchg(&sem->fs, _FMS_OWNED_SIMPLE); 203 221 if (fs == _FMS_AVAILABLE) … … 214 232 if (rc) 215 233 { 234 DosExitMustComplete(&ulNesting); 216 235 LIBC_ASSERTM_FAILED("Failed to create event semaphore for fmutex '%s', rc=%d. flags=%#x\n", sem->pszDesc, rc, sem->flags); 217 236 FS_RESTORE(); … … 272 291 for (;;) 273 292 { 274 DosExitMustComplete(&ulNesting); 275 rc = DosWaitEventSem(sem->hev, sem->flags & _FMC_SHARED ? SEM_INDEFINITE_WAIT : 3000); 293 ULONG cMsWait = sem->flags & _FMC_SHARED ? SEM_INDEFINITE_WAIT : 3000; 294 if (fibIsInExit()) 295 cMsWait = 250; 296 DosExitMustComplete(&ulNesting); 297 rc = DosWaitEventSem(sem->hev, cMsWait); 276 298 DosEnterMustComplete(&ulNesting); 277 299 if (rc == ERROR_INTERRUPT) … … 291 313 if (rc != ERROR_TIMEOUT) 292 314 break; 315 293 316 /* 294 317 * Deadlock detection - check if owner is around. … … 307 330 } 308 331 } 332 309 333 FS_RESTORE(); 310 334 if (rc != 0) … … 319 343 static void __fmutex_deadlock(_fmutex *pSem, const char *pszMsg) 320 344 { 321 __libc_Back_panic(0, NULL, 322 "fmutex deadlock: %s\n" 323 "%x: Owner=%x Self=%x fs=%x flags=%x hev=%x\n" 324 " Desc=\"%s\"\n", 325 pszMsg, 326 pSem, pSem->Owner, fibGetTidPid(), pSem->fs, pSem->flags, pSem->hev, 327 pSem->pszDesc); 345 if (!fibIsInExit()) 346 __libc_Back_panic(0, NULL, 347 "fmutex deadlock: %s\n" 348 "%x: Owner=%x Self=%x fs=%x flags=%x hev=%x\n" 349 " Desc=\"%s\"\n", 350 pszMsg, 351 pSem, pSem->Owner, fibGetTidPid(), pSem->fs, pSem->flags, pSem->hev, 352 pSem->pszDesc); 328 353 } 329 354 … … 332 357 LIBCLOG_ENTER("sem=%p{.pszDesc=%s}\n", (void *)sem, sem->pszDesc); 333 358 ULONG ulNesting; 359 int rc = 0; 334 360 __atomic_xchg(&sem->Owner, 0); 335 361 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 } 362 if (fs == _FMS_OWNED_HARD) 363 rc = __fmutex_release_internal (sem); 364 365 FS_VAR_SAVE_LOAD(); 366 DosExitMustComplete(&ulNesting); 367 FS_RESTORE(); 368 369 /* This is a hack to catch lost poke signals. */ 370 #if 0 /** @todo lost signal / kernel boundrary */ 371 if (!ulNesting) 372 { 373 __LIBC_PTHREAD pThrd = __libc_threadCurrentNoAuto(); 374 if (pThrd && pThrd->fSigBeingPoked) 375 __libc_Back_signalLostPoke(); 376 } 377 #endif 378 379 LIBCLOG_RETURN_UINT(rc); 351 380 } 352 381
Note:
See TracChangeset
for help on using the changeset viewer.