- Timestamp:
- Mar 16, 2014, 10:17:54 PM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
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.