Changeset 8421 in vbox for trunk/src/VBox/Main
- Timestamp:
- Apr 28, 2008 1:32:35 PM (17 years ago)
- Location:
- trunk/src/VBox/Main
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/AutoLock.cpp
r8321 r8421 46 46 47 47 mReadLockCount = 0; 48 mSelfReadLockCount = 0; 49 48 50 mWriteLockLevel = 0; 49 51 mWriteLockPending = 0; … … 94 96 RTCritSectEnter (&mCritSect); 95 97 96 if (mWriteLockThread != RTThreadNativeSelf()) 98 RTNATIVETHREAD threadSelf = RTThreadNativeSelf(); 99 100 if (mWriteLockThread != threadSelf) 97 101 { 98 102 if (mReadLockCount != 0 || mWriteLockThread != NIL_RTNATIVETHREAD || … … 110 114 Assert (mWriteLockLevel == 0); 111 115 Assert (mWriteLockThread == NIL_RTNATIVETHREAD); 112 113 mWriteLockThread = RTThreadNativeSelf(); 116 Assert (mSelfReadLockCount == 0 /* missing unlockRead()? */); 117 118 mWriteLockThread = threadSelf; 114 119 } 115 120 … … 139 144 if (mWriteLockLevel == 0) 140 145 { 146 Assert (mSelfReadLockCount == 0 147 /* mixed unlockWrite()/unlockRead() order? */); 148 141 149 mWriteLockThread = NIL_RTNATIVETHREAD; 142 150 … … 166 174 RTCritSectEnter (&mCritSect); 167 175 168 ++ mReadLockCount; 169 Assert (mReadLockCount != 0 /* read lock overflow? */); 176 RTNATIVETHREAD threadSelf = RTThreadNativeSelf(); 170 177 171 178 bool isWriteLock = mWriteLockLevel != 0; 172 179 bool isFirstReadLock = mReadLockCount == 1; 173 180 174 if (isWriteLock && mWriteLockThread == RTThreadNativeSelf()) 175 { 176 /* read lock nested into the write lock, cause return immediately */ 181 if (isWriteLock && mWriteLockThread == threadSelf) 182 { 183 /* read lock nested into the write lock */ 184 ++ mSelfReadLockCount; 185 Assert (mSelfReadLockCount != 0 /* self read lock overflow? */); 186 187 /* cause to return immediately */ 177 188 isWriteLock = false; 178 189 } 179 190 else 180 191 { 192 ++ mReadLockCount; 193 Assert (mReadLockCount != 0 /* read lock overflow? */); 194 181 195 if (!isWriteLock) 182 196 { 197 Assert (mSelfReadLockCount == 0 /* missing unlockRead()? */); 198 183 199 /* write locks are top priority, so let them go if they are 184 200 * pending */ … … 218 234 RTCritSectEnter (&mCritSect); 219 235 220 Assert (mReadLockCount != 0 /* unlockRead() w/o preceding lockRead()? */); 221 if (mReadLockCount != 0) 222 { 223 if (mWriteLockLevel != 0) 224 { 225 /* read unlock nested into the write lock, just decrease the 226 * counter */ 227 Assert (mWriteLockThread == RTThreadNativeSelf() 228 /* unlockRead() after lockWrite()? */); 229 if (mWriteLockThread == RTThreadNativeSelf()) 230 -- mReadLockCount; 231 } 232 else 236 RTNATIVETHREAD threadSelf = RTThreadNativeSelf(); 237 238 if (mWriteLockLevel != 0) 239 { 240 /* read unlock nested into the write lock */ 241 Assert (mWriteLockThread == threadSelf 242 /* unlockRead() after lockWrite()? */); 243 if (mWriteLockThread == threadSelf) 244 { 245 Assert (mSelfReadLockCount != 0 246 /* unlockRead() w/o preceding lockRead()? */); 247 if (mSelfReadLockCount != 0) 248 { 249 -- mSelfReadLockCount; 250 } 251 } 252 } 253 else 254 { 255 Assert (mReadLockCount != 0 256 /* unlockRead() w/o preceding lockRead()? */); 257 if (mReadLockCount != 0) 233 258 { 234 259 -- mReadLockCount; -
trunk/src/VBox/Main/include/AutoLock.h
r8321 r8421 193 193 RTNATIVETHREAD mWriteLockThread; 194 194 195 uint32_t mReadLockCount; 195 uint32_t mReadLockCount; /*< Number of read locks */ 196 uint32_t mSelfReadLockCount; /*< Number of read locks nested in write lock */ 197 196 198 uint32_t mWriteLockLevel; 197 199 uint32_t mWriteLockPending;
Note:
See TracChangeset
for help on using the changeset viewer.