Changeset 872
- Timestamp:
- Nov 23, 2003, 3:41:33 AM (22 years ago)
- Location:
- trunk/src/emx
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/emx/include/sys/fmutex.h
-
Property cvs2svn:cvs-rev
changed from
1.1
to1.2
r871 r872 34 34 typedef struct 35 35 { 36 unsigned long hev; /* HEV */ 37 __volatile__ signed char fs; /* Status */ 36 /** Handle to event semaphore. */ 37 unsigned long hev; 38 /** Semaphore status. */ 39 __volatile__ signed char fs; 40 /** Semaphore create flags. (_FMC_SHARED) */ 41 unsigned char flags; 42 /** padding the struct to 8 bytes. */ 43 unsigned char padding[2]; 38 44 } _fmutex; 39 45 #pragma pack() -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/process/fmutex.c
-
Property cvs2svn:cvs-rev
changed from
1.4
to1.5
r871 r872 20 20 FS_VAR(); 21 21 sem->fs = _FMS_AVAILABLE; 22 sem->flags = flags; 23 sem->padding[0] = 'f'; 24 sem->padding[1] = 'm'; 22 25 FS_SAVE_LOAD(); 23 26 rc = DosCreateEventSem (NULL, (PHEV)&sem->hev, … … 55 58 { 56 59 ULONG rc, count; 60 PTIB pTib; 61 PPIB pPib; 57 62 58 63 if (fs == _FMS_UNINIT) … … 79 84 if (__cxchg (&sem->fs, _FMS_OWNED_HARD) == _FMS_AVAILABLE) 80 85 return 0; 86 FS_SAVE_LOAD(); 87 81 88 do 82 89 { 83 FS_SAVE_LOAD(); 84 rc = DosWaitEventSem (sem->hev, SEM_INDEFINITE_WAIT); 85 FS_RESTORE(); 86 } while (rc == ERROR_INTERRUPT && (flags & _FMR_IGNINT)); 90 rc = DosWaitEventSem (sem->hev, sem->flags & _FMC_SHARED ? SEM_INDEFINITE_WAIT : 3000); 91 if (rc == ERROR_INTERRUPT) 92 { 93 /* 94 * An interrupt occured, this might be a bug in the wait, or 95 * more likely someone is killing us. If we're dying/exiting or 96 * something along those lines, we return to the caller no matter 97 * what flags it specified. 98 */ 99 if (!(flags & _FMR_IGNINT)) 100 break; 101 DosGetInfoBlocks(&pTib, &pPib); 102 if (pPib->pib_flstatus & (0x40/*dying*/ | 0x04/*exiting all*/ | 0x02/*Exiting Thread 1*/ | 0x01/* ExitList */)) 103 break; 104 rc = ERROR_TIMEOUT; 105 } 106 if (rc == ERROR_TIMEOUT && !(sem->flags & _FMC_SHARED)) 107 { 108 /* 109 * Deadlock detection - if this is the only thread of the 110 * process we should just kill our selves. 111 * ASSUME thread ids are reused and upper thread limit or 4k. 112 */ 113 int iThread; 114 DosGetInfoBlocks(&pTib, &pPib); 115 for (iThread = 1; iThread < 4096; iThread++) 116 { 117 if ( iThread != pTib->tib_ptib2->tib2_ultid 118 && !DosVerifyPidTid(pPib->pib_ulpid, iThread)) 119 break; 120 } 121 if (iThread >= 4096) 122 { /* No other threads! */ 123 ULONG ul; 124 DosWrite((HFILE)2/*stderr*/, "\r\n!!!deadlock!!!\r\r", 18, &ul); 125 __asm__ __volatile__ ("movl $0xdead10cc, %%eax; movl $0xdead10cc, %%edx; movl %0, %%ecx; int $3" : : "m" (sem) : "%eax", "%edx", "%ecx"); 126 rc = ERROR_SEM_OWNER_DIED; 127 break; 128 } 129 } 130 } while (rc == ERROR_TIMEOUT); 131 FS_RESTORE(); 87 132 if (rc != 0) 88 133 return rc; -
Property cvs2svn:cvs-rev
changed from
Note:
See TracChangeset
for help on using the changeset viewer.