Changeset 243 for trunk/src/helpers/sem.c
- Timestamp:
- Jan 29, 2003, 7:41:39 PM (23 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/helpers/sem.c
r196 r243 2 2 /* 3 3 *@@sourcefile sem.c: 4 * implements fast mutex semaphores a la Win32 5 * critical sections. 6 * 7 * This is an OS/2 implementation of what Win32 calls as 8 * "critical sections" 9 * It is an implementation that is highly optimized for 4 * implements fast mutex semaphores. 5 * 6 * This is an OS/2 implementation of what Win32 calls 7 * "critical sections". This is highly optimized for 10 8 * the case where there is only one thread trying to 11 9 * access the critical section, i.e. it is available most … … 194 192 // do an atomic increase of the lockcounter and see if it is > 0 195 193 // (i.e. it is already posessed) 196 if ( DosInterlockedIncrement(&pmtx->LockCount))194 if (lockIncrement(&pmtx->LockCount)) 197 195 { 198 196 // semaphore was already requested: … … 206 204 } 207 205 208 // current owner is different thread thread:206 // current owner is different thread: 209 207 210 208 // do an atomic operation where we compare the owning thread id with 0 211 209 // and if this is true, exchange it with the id of the current thread 212 if ( DosInterlockedCompareExchange((PLONG)&pmtx->OwningThread, threadid, 0))210 if (lockCompareExchange((PLONG)&pmtx->OwningThread, threadid, 0)) 213 211 { 214 212 // the compare did not return equal, i.e. the pmtx sect is in use … … 257 255 BOOL semTry(PFASTMTX pmtx) 258 256 { 259 if ( DosInterlockedIncrement(&pmtx->LockCount))257 if (lockIncrement(&pmtx->LockCount)) 260 258 { 261 259 if (pmtx->OwningThread == GetTID()) … … 265 263 } 266 264 267 DosInterlockedDecrement(&pmtx->LockCount);265 lockDecrement(&pmtx->LockCount); 268 266 269 267 return FALSE; … … 291 289 if (--pmtx->RecursionCount) 292 290 { 293 DosInterlockedDecrement(&pmtx->LockCount );291 lockDecrement(&pmtx->LockCount ); 294 292 return NO_ERROR; 295 293 } … … 297 295 pmtx->OwningThread = 0; 298 296 299 if ( DosInterlockedDecrement(&pmtx->LockCount) >= 0)297 if (lockDecrement(&pmtx->LockCount) >= 0) 300 298 // someone is waiting 301 299 DosPostEventSem(pmtx->hmtxLock);
Note:
See TracChangeset
for help on using the changeset viewer.