Changeset 25409 in vbox for trunk/src/VBox/Runtime/common
- Timestamp:
- Dec 15, 2009 3:04:41 PM (15 years ago)
- Location:
- trunk/src/VBox/Runtime/common
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Runtime/common/log/log.cpp
r24987 r25409 46 46 # include <iprt/env.h> 47 47 # include <iprt/file.h> 48 # include <iprt/lockvalidator.h> 48 49 # include <iprt/path.h> 49 50 #endif … … 412 413 if (Thread != NIL_RTTHREAD) 413 414 { 414 int32_t c = RT ThreadGetWriteLockCount(Thread);415 int32_t c = RTLockValidatorWriteLockGetCount(Thread); 415 416 RTSemSpinMutexRequest(pLogger->hSpinMtx); 416 c = RT ThreadGetWriteLockCount(Thread) - c;417 c = RTLockValidatorWriteLockGetCount(Thread) - c; 417 418 RTSemSpinMutexRelease(pLogger->hSpinMtx); 418 419 ASMAtomicWriteU32(&g_cLoggerLockCount, c); … … 2525 2526 if (Thread != NIL_RTTHREAD) 2526 2527 { 2527 uint32_t cReadLocks = RT ThreadGetReadLockCount(Thread);2528 uint32_t cWriteLocks = RT ThreadGetWriteLockCount(Thread) - g_cLoggerLockCount;2528 uint32_t cReadLocks = RTLockValidatorReadLockGetCount(Thread); 2529 uint32_t cWriteLocks = RTLockValidatorWriteLockGetCount(Thread) - g_cLoggerLockCount; 2529 2530 cReadLocks = RT_MIN(0xfff, cReadLocks); 2530 2531 cWriteLocks = RT_MIN(0xfff, cWriteLocks); -
trunk/src/VBox/Runtime/common/misc/lockvalidator.cpp
r25406 r25409 185 185 return hThread; 186 186 } 187 188 189 RTDECL(int32_t) RTLockValidatorWriteLockGetCount(RTTHREAD Thread) 190 { 191 if (Thread == NIL_RTTHREAD) 192 return 0; 193 194 PRTTHREADINT pThread = rtThreadGet(Thread); 195 if (!pThread) 196 return VERR_INVALID_HANDLE; 197 int32_t cWriteLocks = ASMAtomicReadS32(&pThread->LockValidator.cWriteLocks); 198 rtThreadRelease(pThread); 199 return cWriteLocks; 200 } 201 RT_EXPORT_SYMBOL(RTLockValidatorWriteLockGetCount); 202 203 204 RTDECL(void) RTLockValidatorWriteLockInc(RTTHREAD Thread) 205 { 206 PRTTHREADINT pThread = rtThreadGet(Thread); 207 AssertReturnVoid(pThread); 208 ASMAtomicIncS32(&pThread->LockValidator.cWriteLocks); 209 rtThreadRelease(pThread); 210 } 211 RT_EXPORT_SYMBOL(RTLockValidatorWriteLockInc); 212 213 214 RTDECL(void) RTLockValidatorWriteLockDec(RTTHREAD Thread) 215 { 216 PRTTHREADINT pThread = rtThreadGet(Thread); 217 AssertReturnVoid(pThread); 218 ASMAtomicDecS32(&pThread->LockValidator.cWriteLocks); 219 rtThreadRelease(pThread); 220 } 221 RT_EXPORT_SYMBOL(RTLockValidatorWriteLockDec); 222 223 224 RTDECL(int32_t) RTLockValidatorReadLockGetCount(RTTHREAD Thread) 225 { 226 if (Thread == NIL_RTTHREAD) 227 return 0; 228 229 PRTTHREADINT pThread = rtThreadGet(Thread); 230 if (!pThread) 231 return VERR_INVALID_HANDLE; 232 int32_t cReadLocks = ASMAtomicReadS32(&pThread->LockValidator.cReadLocks); 233 rtThreadRelease(pThread); 234 return cReadLocks; 235 } 236 RT_EXPORT_SYMBOL(RTLockValidatorReadLockGetCount); 237 238 239 RTDECL(void) RTLockValidatorReadLockInc(RTTHREAD Thread) 240 { 241 PRTTHREADINT pThread = rtThreadGet(Thread); 242 Assert(pThread); 243 ASMAtomicIncS32(&pThread->LockValidator.cReadLocks); 244 rtThreadRelease(pThread); 245 } 246 RT_EXPORT_SYMBOL(RTLockValidatorReadLockInc); 247 248 249 RTDECL(void) RTLockValidatorReadLockDec(RTTHREAD Thread) 250 { 251 PRTTHREADINT pThread = rtThreadGet(Thread); 252 Assert(pThread); 253 ASMAtomicDecS32(&pThread->LockValidator.cReadLocks); 254 rtThreadRelease(pThread); 255 } 256 RT_EXPORT_SYMBOL(RTLockValidatorReadLockDec); 257 187 258 188 259 … … 308 379 AssertPtrReturnVoid(pThread); 309 380 AssertReturnVoid(pThread->u32Magic == RTTHREADINT_MAGIC); 310 AssertReturnVoid(rtThreadGetState(pThread) == RTTHREADSTATE_RUNNING); 381 RTTHREADSTATE enmThreadState = rtThreadGetState(pThread); 382 AssertReturnVoid( enmThreadState == RTTHREADSTATE_RUNNING 383 || enmThreadState == RTTHREADSTATE_TERMINATED /* rtThreadRemove uses locks too */); 311 384 312 385 /* -
trunk/src/VBox/Runtime/common/misc/thread.cpp
r25406 r25409 1203 1203 RT_EXPORT_SYMBOL(RTThreadGetType); 1204 1204 1205 1206 1205 #ifdef IN_RING3 1207 1208 /**1209 * Gets the number of write locks and critical sections the specified1210 * thread owns.1211 *1212 * This number does not include any nested lock/critect entries.1213 *1214 * Note that it probably will return 0 for non-strict builds since1215 * release builds doesn't do unnecessary diagnostic counting like this.1216 *1217 * @returns Number of locks on success (0+) and VERR_INVALID_HANDLER on failure1218 * @param Thread The thread we're inquiring about.1219 *1220 * @todo Move this.1221 */1222 RTDECL(int32_t) RTThreadGetWriteLockCount(RTTHREAD Thread)1223 {1224 if (Thread == NIL_RTTHREAD)1225 return 0;1226 1227 PRTTHREADINT pThread = rtThreadGet(Thread);1228 if (!pThread)1229 return VERR_INVALID_HANDLE;1230 int32_t cWriteLocks = ASMAtomicReadS32(&pThread->LockValidator.cWriteLocks);1231 rtThreadRelease(pThread);1232 return cWriteLocks;1233 }1234 RT_EXPORT_SYMBOL(RTThreadGetWriteLockCount);1235 1236 1237 /**1238 * Works the THREADINT::cWriteLocks member, mostly internal.1239 *1240 * @param Thread The current thread.1241 *1242 * @todo Move this.1243 */1244 RTDECL(void) RTThreadWriteLockInc(RTTHREAD Thread)1245 {1246 PRTTHREADINT pThread = rtThreadGet(Thread);1247 AssertReturnVoid(pThread);1248 ASMAtomicIncS32(&pThread->LockValidator.cWriteLocks);1249 rtThreadRelease(pThread);1250 }1251 RT_EXPORT_SYMBOL(RTThreadWriteLockInc);1252 1253 1254 /**1255 * Works the THREADINT::cWriteLocks member, mostly internal.1256 *1257 * @param Thread The current thread.1258 *1259 * @todo Move this.1260 */1261 RTDECL(void) RTThreadWriteLockDec(RTTHREAD Thread)1262 {1263 PRTTHREADINT pThread = rtThreadGet(Thread);1264 AssertReturnVoid(pThread);1265 ASMAtomicDecS32(&pThread->LockValidator.cWriteLocks);1266 rtThreadRelease(pThread);1267 }1268 RT_EXPORT_SYMBOL(RTThreadWriteLockDec);1269 1270 1271 /**1272 * Gets the number of read locks the specified thread owns.1273 *1274 * Note that nesting read lock entry will be included in the1275 * total sum. And that it probably will return 0 for non-strict1276 * builds since release builds doesn't do unnecessary diagnostic1277 * counting like this.1278 *1279 * @returns Number of read locks on success (0+) and VERR_INVALID_HANDLER on failure1280 * @param Thread The thread we're inquiring about.1281 *1282 * @todo Move this.1283 */1284 RTDECL(int32_t) RTThreadGetReadLockCount(RTTHREAD Thread)1285 {1286 if (Thread == NIL_RTTHREAD)1287 return 0;1288 1289 PRTTHREADINT pThread = rtThreadGet(Thread);1290 if (!pThread)1291 return VERR_INVALID_HANDLE;1292 int32_t cReadLocks = ASMAtomicReadS32(&pThread->LockValidator.cReadLocks);1293 rtThreadRelease(pThread);1294 return cReadLocks;1295 }1296 RT_EXPORT_SYMBOL(RTThreadGetReadLockCount);1297 1298 1299 /**1300 * Works the THREADINT::cReadLocks member.1301 *1302 * @param Thread The current thread.1303 *1304 * @todo Move this.1305 */1306 RTDECL(void) RTThreadReadLockInc(RTTHREAD Thread)1307 {1308 PRTTHREADINT pThread = rtThreadGet(Thread);1309 Assert(pThread);1310 ASMAtomicIncS32(&pThread->LockValidator.cReadLocks);1311 rtThreadRelease(pThread);1312 }1313 RT_EXPORT_SYMBOL(RTThreadReadLockInc);1314 1315 1316 /**1317 * Works the THREADINT::cReadLocks member.1318 *1319 * @param Thread The current thread.1320 *1321 * @todo Move this.1322 */1323 RTDECL(void) RTThreadReadLockDec(RTTHREAD Thread)1324 {1325 PRTTHREADINT pThread = rtThreadGet(Thread);1326 Assert(pThread);1327 ASMAtomicDecS32(&pThread->LockValidator.cReadLocks);1328 rtThreadRelease(pThread);1329 }1330 RT_EXPORT_SYMBOL(RTThreadReadLockDec);1331 1332 1333 1334 1335 1206 1336 1207 /**
Note:
See TracChangeset
for help on using the changeset viewer.