- Timestamp:
- Jul 19, 2002, 1:06:45 PM (23 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/odincrt/critsect.cpp
r8890 r8895 1 /* $Id: critsect.cpp,v 1. 3 2002-07-18 20:26:28sandervl Exp $ */1 /* $Id: critsect.cpp,v 1.4 2002-07-19 11:06:45 sandervl Exp $ */ 2 2 /* 3 3 * Critical sections … … 74 74 crit->OwningThread = 0; 75 75 76 rc = DosCreate MutexSem(pszSemName, &crit->hmtxLock, (pszSemName) ? DC_SEM_SHARED : 0, TRUE);76 rc = DosCreateEventSem(pszSemName, &crit->hmtxLock, (pszSemName) ? DC_SEM_SHARED : 0, 0); 77 77 if(rc != NO_ERROR) { 78 78 DebugInt3(); … … 96 96 } 97 97 98 rc = DosOpen MutexSem(pszSemName, &hmtxLock);98 rc = DosOpenEventSem(pszSemName, &hmtxLock); 99 99 if(rc != NO_ERROR) { 100 100 DebugInt3(); … … 115 115 crit->RecursionCount = 0; 116 116 crit->OwningThread = 0; 117 DosClose MutexSem(crit->hmtxLock);117 DosCloseEventSem(crit->hmtxLock); 118 118 crit->hmtxLock = 0; 119 119 crit->Reserved = (DWORD)-1; … … 128 128 { 129 129 DWORD res; 130 DWORD threadid = GetCurrentThreadId(); 130 131 131 132 if (!crit->hmtxLock) … … 135 136 if (DosInterlockedIncrement( &crit->LockCount )) 136 137 { 137 if (crit->OwningThread == GetCurrentThreadId()) 138 testenter: 139 if (crit->OwningThread == threadid) 138 140 { 139 141 crit->RecursionCount++; … … 141 143 } 142 144 143 /* Now wait for it */ 144 APIRET rc = DosRequestMutexSem(crit->hmtxLock, SEM_INDEFINITE_WAIT); 145 if(DosInterlockedCompareExchange((PLONG)&crit->OwningThread, threadid, 0)) 146 { 147 ULONG ulnrposts; 148 149 /* Now wait for it */ 150 APIRET rc = DosWaitEventSem(crit->hmtxLock, SEM_INDEFINITE_WAIT); 151 if(rc != NO_ERROR) { 152 DebugInt3(); 153 return; 154 } 155 DosResetEventSem(crit->hmtxLock, &ulnrposts); 156 goto testenter; 157 } 145 158 } 146 159 crit->OwningThread = GetCurrentThreadId(); … … 161 174 return TRUE; 162 175 } 163 /* FIXME: this doesn't work */164 176 DosInterlockedDecrement( &crit->LockCount ); 165 177 return FALSE; … … 187 199 { 188 200 /* Someone is waiting */ 189 Dos ReleaseMutexSem(crit->hmtxLock);190 } 191 } 192 201 DosPostEventSem(crit->hmtxLock); 202 } 203 } 204
Note:
See TracChangeset
for help on using the changeset viewer.