VirtualBox

source: vbox/trunk/include/iprt/lockvalidator.h@ 25571

Last change on this file since 25571 was 25571, checked in by vboxsync, 15 years ago

grumble.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 23.8 KB
Line 
1/** @file
2 * IPRT - Lock Validator.
3 */
4
5/*
6 * Copyright (C) 2009 Sun Microsystems, Inc.
7 *
8 * This file is part of VirtualBox Open Source Edition (OSE), as
9 * available from http://www.virtualbox.org. This file is free software;
10 * you can redistribute it and/or modify it under the terms of the GNU
11 * General Public License (GPL) as published by the Free Software
12 * Foundation, in version 2 as it comes in the "COPYING" file of the
13 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
14 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
15 *
16 * The contents of this file may alternatively be used under the terms
17 * of the Common Development and Distribution License Version 1.0
18 * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
19 * VirtualBox OSE distribution, in which case the provisions of the
20 * CDDL are applicable instead of those of the GPL.
21 *
22 * You may elect to license modified versions of this file under the
23 * terms and conditions of either the GPL or the CDDL or both.
24 *
25 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
26 * Clara, CA 95054 USA or visit http://www.sun.com if you need
27 * additional information or have any questions.
28 */
29
30#ifndef ___iprt_lockvalidator_h
31#define ___iprt_lockvalidator_h
32
33#include <iprt/cdefs.h>
34#include <iprt/types.h>
35#include <iprt/assert.h>
36#include <iprt/thread.h>
37
38
39/** @defgroup grp_ldr RTLockValidator - Lock Validator
40 * @ingroup grp_rt
41 * @{
42 */
43
44RT_C_DECLS_BEGIN
45
46typedef struct RTLOCKVALIDATORSRCPOS
47{
48 /** The file where the lock was taken. */
49 R3R0PTRTYPE(const char * volatile) pszFile;
50 /** The function where the lock was taken. */
51 R3R0PTRTYPE(const char * volatile) pszFunction;
52 /** Some ID indicating where the lock was taken, typically an address. */
53 RTHCUINTPTR volatile uId;
54 /** The line number in the file. */
55 uint32_t volatile uLine;
56#if HC_ARCH_BITS == 64
57 uint32_t u32Padding; /**< Alignment padding. */
58#endif
59} RTLOCKVALIDATORSRCPOS;
60AssertCompileSize(RTLOCKVALIDATORSRCPOS, HC_ARCH_BITS == 32 ? 16 : 32);
61/* The pointer types are defined in iprt/types.h. */
62
63/** @def RTLOCKVALIDATORSRCPOS_INIT
64 * Initializer for a RTLOCKVALIDATORSRCPOS variable.
65 *
66 * @param pszFile The file name. Optional (NULL).
67 * @param uLine The line number in that file. Optional (0).
68 * @param pszFunction The function. Optional (NULL).
69 * @param uId Some location ID, normally the return address.
70 * Optional (NULL).
71 */
72#if HC_ARCH_BITS == 64
73# define RTLOCKVALIDATORSRCPOS_INIT(pszFile, uLine, pszFunction, uId) \
74 { (pszFile), (pszFunction), (uId), (uLine), 0 }
75#else
76# define RTLOCKVALIDATORSRCPOS_INIT(pszFile, uLine, pszFunction, uId) \
77 { (pszFile), (pszFunction), (uId), (uLine) }
78#endif
79
80/** @def RTLOCKVALIDATORSRCPOS_INIT_DEBUG_API
81 * Initializer for a RTLOCKVALIDATORSRCPOS variable in a typicial debug API
82 * variant. Assumes RT_SRC_POS_DECL and RTHCUINTPTR uId as arguments.
83 */
84#define RTLOCKVALIDATORSRCPOS_INIT_DEBUG_API() \
85 RTLOCKVALIDATORSRCPOS_INIT(pszFile, iLine, pszFunction, uId)
86
87/** @def RTLOCKVALIDATORSRCPOS_INIT_NORMAL_API
88 * Initializer for a RTLOCKVALIDATORSRCPOS variable in a normal API
89 * variant. Assumes iprt/asm.h is included.
90 */
91#define RTLOCKVALIDATORSRCPOS_INIT_NORMAL_API() \
92 RTLOCKVALIDATORSRCPOS_INIT(__FILE__, __LINE__, __PRETTY_FUNCTION__, (uintptr_t)ASMReturnAddress())
93
94/** Pointer to a record of one ownership share. */
95typedef struct RTLOCKVALIDATORSHARED *PRTLOCKVALIDATORSHARED;
96
97
98/**
99 * Record recording the ownership of a lock.
100 *
101 * This is typically part of the per-lock data structure when compiling with
102 * the lock validator.
103 */
104typedef struct RTLOCKVALIDATORREC
105{
106 /** Magic value (RTLOCKVALIDATORREC_MAGIC). */
107 uint32_t u32Magic;
108 /** Whether it's enabled or not. */
109 bool fEnabled;
110 /** Reserved. */
111 bool afReserved[3];
112 /** Source position where the lock was taken. */
113 RTLOCKVALIDATORSRCPOS SrcPos;
114 /** The current owner thread. */
115 RTTHREAD volatile hThread;
116 /** Pointer to the lock record below us. Only accessed by the owner. */
117 R3R0PTRTYPE(PRTLOCKVALIDATORREC) pDown;
118 /** Recursion count */
119 uint32_t cRecursion;
120 /** The lock sub-class. */
121 uint32_t volatile uSubClass;
122 /** The lock class. */
123 RTLOCKVALIDATORCLASS hClass;
124 /** Pointer to the lock. */
125 RTHCPTR hLock;
126 /** The lock name. */
127 R3R0PTRTYPE(const char *) pszName;
128 /** Pointer to the sibling record.
129 * This is used to find the read side of a read-write lock. */
130 R3R0PTRTYPE(PRTLOCKVALIDATORSHARED) pSibling;
131} RTLOCKVALIDATORREC;
132AssertCompileSize(RTLOCKVALIDATORREC, HC_ARCH_BITS == 32 ? 8 + 16 + 32 : 8 + 32 + 56);
133/* The pointer type is defined in iprt/types.h. */
134
135/**
136 * For recording the one ownership share.
137 */
138typedef struct RTLOCKVALIDATORSHAREDONE
139{
140 /** Magic value (RTLOCKVALIDATORSHAREDONE_MAGIC). */
141 uint32_t u32Magic;
142 /** Recursion count */
143 uint32_t cRecursion;
144 /** The current owner thread. */
145 RTTHREAD volatile hThread;
146 /** Pointer to the lock record below us. Only accessed by the owner. */
147 R3R0PTRTYPE(PRTLOCKVALIDATORREC) pDown;
148 /** Pointer back to the shared record. */
149 R3R0PTRTYPE(PRTLOCKVALIDATORSHARED) pSharedRec;
150#if HC_ARCH_BITS == 32
151 /** Reserved. */
152 RTHCPTR pvReserved;
153#endif
154 /** Source position where the lock was taken. */
155 RTLOCKVALIDATORSRCPOS SrcPos;
156} RTLOCKVALIDATORSHAREDONE;
157AssertCompileSize(RTLOCKVALIDATORSHAREDONE, HC_ARCH_BITS == 32 ? 24 + 16 : 32 + 32);
158/** Pointer to a RTLOCKVALIDATORSHAREDONE. */
159typedef RTLOCKVALIDATORSHAREDONE *PRTLOCKVALIDATORSHAREDONE;
160
161/**
162 * Record recording the shared ownership of a lock.
163 *
164 * This is typically part of the per-lock data structure when compiling with
165 * the lock validator.
166 */
167typedef struct RTLOCKVALIDATORSHARED
168{
169 /** Magic value (RTLOCKVALIDATORSHARED_MAGIC). */
170 uint32_t u32Magic;
171 /** The lock sub-class. */
172 uint32_t volatile uSubClass;
173 /** The lock class. */
174 RTLOCKVALIDATORCLASS hClass;
175 /** Pointer to the lock. */
176 RTHCPTR hLock;
177 /** The lock name. */
178 R3R0PTRTYPE(const char *) pszName;
179 /** Pointer to the sibling record.
180 * This is used to find the write side of a read-write lock. */
181 R3R0PTRTYPE(PRTLOCKVALIDATORREC) pSibling;
182
183 /** The number of entries in the table.
184 * Updated before inserting and after removal. */
185 uint32_t volatile cEntries;
186 /** The index of the last entry (approximately). */
187 uint32_t volatile iLastEntry;
188 /** The max table size. */
189 uint32_t volatile cAllocated;
190 /** Set if the table is being reallocated, clear if not.
191 * This is used together with rtLockValidatorSerializeDetectionEnter to make
192 * sure there is exactly one thread doing the reallocation and that nobody is
193 * using the table at that point. */
194 bool volatile fReallocating;
195 /** Whether it's enabled or not. */
196 bool fEnabled;
197 /** Alignment padding. */
198 bool afPadding[2];
199 /** Pointer to a table containing pointers to records of all the owners. */
200 R3R0PTRTYPE(PRTLOCKVALIDATORSHAREDONE volatile *) papOwners;
201#if RT_ARCH_BITS == 32
202 /** Alignment padding. */
203 uint32_T u32Reserved;
204#endif
205} RTLOCKVALIDATORSHARED;
206/*AssertCompileSize(RTLOCKVALIDATORSHARED, HC_ARCH_BITS == 32 ? 24 + 20 + 4 : 40 + 24);*/
207
208
209/** @name Special sub-class values.
210 * The range 16..UINT32_MAX is available to the user, the range 0..15 is
211 * reserved for the lock validator.
212 * @{ */
213/** Not allowed to be taken with any other locks in the same class.
214 * This is the recommended value. */
215#define RTLOCKVALIDATOR_SUB_CLASS_NONE UINT32_C(0)
216/** Any order is allowed within the class. */
217#define RTLOCKVALIDATOR_SUB_CLASS_ANY UINT32_C(1)
218/** The first user value. */
219#define RTLOCKVALIDATOR_SUB_CLASS_USER UINT32_C(16)
220/** @} */
221
222/**
223 * Initialize a lock validator record.
224 *
225 * Use RTLockValidatorRecDelete to deinitialize it.
226 *
227 * @param pRec The record.
228 * @param hClass The class. If NIL, the no lock order
229 * validation will be performed on this lock.
230 * @param uSubClass The sub-class. This is used to define lock
231 * order inside the same class. If you don't know,
232 * then pass RTLOCKVALIDATOR_SUB_CLASS_NONE.
233 * @param pszName The lock name (optional).
234 * @param hLock The lock handle.
235 */
236RTDECL(void) RTLockValidatorRecInit(PRTLOCKVALIDATORREC pRec, RTLOCKVALIDATORCLASS hClass,
237 uint32_t uSubClass, const char *pszName, void *hLock);
238/**
239 * Uninitialize a lock validator record previously initialized by
240 * RTLockRecValidatorInit.
241 *
242 * @param pRec The record. Must be valid.
243 */
244RTDECL(void) RTLockValidatorRecDelete(PRTLOCKVALIDATORREC pRec);
245
246/**
247 * Create and initialize a lock validator record.
248 *
249 * Use RTLockValidatorRecDestroy to deinitialize and destroy the returned
250 * record.
251 *
252 * @return VINF_SUCCESS or VERR_NO_MEMORY.
253 * @param ppRec Where to return the record pointer.
254 * @param hClass The class. If NIL, the no lock order
255 * validation will be performed on this lock.
256 * @param uSubClass The sub-class. This is used to define lock
257 * order inside the same class. If you don't know,
258 * then pass RTLOCKVALIDATOR_SUB_CLASS_NONE.
259 * @param pszName The lock name (optional).
260 * @param hLock The lock handle.
261 */
262RTDECL(int) RTLockValidatorRecCreate(PRTLOCKVALIDATORREC *ppRec, RTLOCKVALIDATORCLASS hClass,
263 uint32_t uSubClass, const char *pszName, void *hLock);
264
265/**
266 * Deinitialize and destroy a record created by RTLockValidatorRecCreate.
267 *
268 * @param ppRec Pointer to the record pointer. Will be set to
269 * NULL.
270 */
271RTDECL(void) RTLockValidatorRecDestroy(PRTLOCKVALIDATORREC *ppRec);
272
273/**
274 * Initialize a lock validator record for a shared lock.
275 *
276 * Use RTLockValidatorSharedRecDelete to deinitialize it.
277 *
278 * @param pRec The shared lock record.
279 * @param hClass The class. If NIL, the no lock order
280 * validation will be performed on this lock.
281 * @param uSubClass The sub-class. This is used to define lock
282 * order inside the same class. If you don't know,
283 * then pass RTLOCKVALIDATOR_SUB_CLASS_NONE.
284 * @param pszName The lock name (optional).
285 * @param hLock The lock handle.
286 */
287RTDECL(void) RTLockValidatorSharedRecInit(PRTLOCKVALIDATORSHARED pRec, RTLOCKVALIDATORCLASS hClass,
288 uint32_t uSubClass, const char *pszName, void *hLock);
289/**
290 * Uninitialize a lock validator record previously initialized by
291 * RTLockValidatorSharedRecInit.
292 *
293 * @param pRec The shared lock record. Must be valid.
294 */
295RTDECL(void) RTLockValidatorSharedRecDelete(PRTLOCKVALIDATORSHARED pRec);
296
297/**
298 * Makes the two records siblings.
299 *
300 * @returns VINF_SUCCESS on success, VERR_SEM_LV_INVALID_PARAMETER if either of
301 * the records are invalid.
302 * @param pvRec1 Record 1.
303 * @param pvRec2 Record 2.
304 */
305RTDECL(int) RTLockValidatorMakeSiblings(void *pvRec1, void *pvRec2);
306
307/**
308 * Check the locking order.
309 *
310 * This is called by routines implementing lock acquisition.
311 *
312 * @retval VINF_SUCCESS on success.
313 * @retval VERR_SEM_LV_WRONG_ORDER if the order is wrong. Will have done all
314 * necessary whining and breakpointing before returning.
315 * @retval VERR_SEM_LV_INVALID_PARAMETER if the input is invalid.
316 *
317 * @param pRec The validator record.
318 * @param hThread The handle of the calling thread. If not known,
319 * pass NIL_RTTHREAD and this method will figure it
320 * out.
321 * @param pSrcPos The source position of the lock operation.
322 */
323RTDECL(int) RTLockValidatorCheckOrder(PRTLOCKVALIDATORREC pRec, RTTHREAD hThread, PCRTLOCKVALIDATORSRCPOS pSrcPos);
324
325/**
326 * Do deadlock detection before blocking on a lock.
327 *
328 * @retval VINF_SUCCESS
329 * @retval VERR_SEM_LV_DEADLOCK if blocking would deadlock. Gone thru the
330 * motions.
331 * @retval VERR_SEM_LV_NESTED if the semaphore isn't recursive and hThread is
332 * already the owner. Gone thru the motions.
333 * @retval VERR_SEM_LV_INVALID_PARAMETER if the input is invalid.
334 *
335 * @param pRec The validator record we're blocing on.
336 * @param hThread The current thread. Shall not be NIL_RTTHREAD!
337 * @param enmState The sleep state.
338 * @param pvBlock Pointer to a RTLOCKVALIDATORREC structure.
339 * @param fRecursiveOk Whether it's ok to recurse.
340 * @param pSrcPos The source position of the lock operation.
341 */
342RTDECL(int) RTLockValidatorCheckBlocking(PRTLOCKVALIDATORREC pRec, RTTHREAD hThread,
343 RTTHREADSTATE enmState, bool fRecursiveOk,
344 PCRTLOCKVALIDATORSRCPOS pSrcPos);
345
346/**
347 * Do order checking and deadlock detection before blocking on a read/write lock
348 * for exclusive (write) access.
349 *
350 * @retval VINF_SUCCESS
351 * @retval VERR_SEM_LV_DEADLOCK if blocking would deadlock. Gone thru the
352 * motions.
353 * @retval VERR_SEM_LV_NESTED if the semaphore isn't recursive and hThread is
354 * already the owner. Gone thru the motions.
355 * @retval VERR_SEM_LV_INVALID_PARAMETER if the input is invalid.
356 *
357 * @param pWrite The validator record for the writer.
358 * @param pRead The validator record for the readers.
359 * @param hThread The current thread. Shall not be NIL_RTTHREAD!
360 * @param enmState The sleep state.
361 * @param pvBlock Pointer to a RTLOCKVALIDATORREC structure.
362 * @param fRecursiveOk Whether it's ok to recurse.
363 * @param pSrcPos The source position of the lock operation.
364 */
365RTDECL(int) RTLockValidatorCheckWriteOrderBlocking(PRTLOCKVALIDATORREC pWrite, PRTLOCKVALIDATORSHARED pRead,
366 RTTHREAD hThread, RTTHREADSTATE enmState, bool fRecursiveOk,
367 PCRTLOCKVALIDATORSRCPOS pSrcPos);
368
369/**
370 * Do order checking and deadlock detection before blocking on a read/write lock
371 * for shared (read) access.
372 *
373 * @retval VINF_SUCCESS
374 * @retval VERR_SEM_LV_DEADLOCK if blocking would deadlock. Gone thru the
375 * motions.
376 * @retval VERR_SEM_LV_NESTED if the semaphore isn't recursive and hThread is
377 * already the owner. Gone thru the motions.
378 * @retval VERR_SEM_LV_INVALID_PARAMETER if the input is invalid.
379 *
380 * @param pRead The validator record for the readers.
381 * @param pWrite The validator record for the writer.
382 * @param hThread The current thread. Shall not be NIL_RTTHREAD!
383 * @param enmState The sleep state.
384 * @param pvBlock Pointer to a RTLOCKVALIDATORREC structure.
385 * @param fRecursiveOk Whether it's ok to recurse.
386 * @param pSrcPos The source position of the lock operation.
387 */
388RTDECL(int) RTLockValidatorCheckReadOrderBlocking(PRTLOCKVALIDATORSHARED pRead, PRTLOCKVALIDATORREC pWrite,
389 RTTHREAD hThread, RTTHREADSTATE enmState, bool fRecursiveOk,
390 PCRTLOCKVALIDATORSRCPOS pSrcPos);
391
392/**
393 * Check the exit order and release (unset) the ownership.
394 *
395 * This is called by routines implementing releasing the lock.
396 *
397 * @retval VINF_SUCCESS on success.
398 * @retval VERR_SEM_LV_WRONG_RELEASE_ORDER if the order is wrong. Will have
399 * done all necessary whining and breakpointing before returning.
400 * @retval VERR_SEM_LV_INVALID_PARAMETER if the input is invalid.
401 *
402 * @param pRec The validator record.
403 */
404RTDECL(int) RTLockValidatorCheckAndRelease(PRTLOCKVALIDATORREC pRec);
405
406/**
407 * Check the exit order and release (unset) the shared ownership.
408 *
409 * This is called by routines implementing releasing the read/write lock.
410 *
411 * @retval VINF_SUCCESS on success.
412 * @retval VERR_SEM_LV_WRONG_RELEASE_ORDER if the order is wrong. Will have
413 * done all necessary whining and breakpointing before returning.
414 * @retval VERR_SEM_LV_INVALID_PARAMETER if the input is invalid.
415 *
416 * @param pRead The validator record.
417 * @param hThread The handle of the calling thread.
418 */
419RTDECL(int) RTLockValidatorCheckAndReleaseReadOwner(PRTLOCKVALIDATORSHARED pRead, RTTHREAD hThread);
420
421/**
422 * Checks and records a lock recursion.
423 *
424 * @retval VINF_SUCCESS on success.
425 * @retval VERR_SEM_LV_NESTED if the semaphore class forbids recursion. Gone
426 * thru the motions.
427 * @retval VERR_SEM_LV_WRONG_ORDER if the locking order is wrong. Gone thru
428 * the motions.
429 * @retval VERR_SEM_LV_INVALID_PARAMETER if the input is invalid.
430 *
431 * @param pRec The validator record.
432 * @param pSrcPos The source position of the lock operation.
433 */
434RTDECL(int) RTLockValidatorRecordRecursion(PRTLOCKVALIDATORREC pRec, PCRTLOCKVALIDATORSRCPOS pSrcPos);
435
436/**
437 * Checks and records a lock unwind (releasing one recursion).
438 *
439 * This should be coupled with called to RTLockValidatorRecordRecursion.
440 *
441 * @retval VINF_SUCCESS on success.
442 * @retval VERR_SEM_LV_WRONG_RELEASE_ORDER if the release order is wrong. Gone
443 * thru the motions.
444 * @retval VERR_SEM_LV_INVALID_PARAMETER if the input is invalid.
445 *
446 * @param pRec The validator record.
447 */
448RTDECL(int) RTLockValidatorUnwindRecursion(PRTLOCKVALIDATORREC pRec);
449
450/**
451 * Checks and records a read/write lock read recursion done by the writer.
452 *
453 * This should be coupled with called to
454 * RTLockValidatorUnwindReadWriteRecursion.
455 *
456 * @retval VINF_SUCCESS on success.
457 * @retval VERR_SEM_LV_NESTED if the semaphore class forbids recursion. Gone
458 * thru the motions.
459 * @retval VERR_SEM_LV_WRONG_ORDER if the locking order is wrong. Gone thru
460 * the motions.
461 * @retval VERR_SEM_LV_INVALID_PARAMETER if the input is invalid.
462 *
463 * @param pRead The validator record for the readers.
464 * @param pWrite The validator record for the writer.
465 */
466RTDECL(int) RTLockValidatorRecordReadWriteRecursion(PRTLOCKVALIDATORREC pWrite, PRTLOCKVALIDATORSHARED pRead, PCRTLOCKVALIDATORSRCPOS pSrcPos);
467
468/**
469 * Checks and records a read/write lock read unwind done by the writer.
470 *
471 * This should be coupled with called to
472 * RTLockValidatorRecordReadWriteRecursion.
473 *
474 * @retval VINF_SUCCESS on success.
475 * @retval VERR_SEM_LV_WRONG_RELEASE_ORDER if the release order is wrong. Gone
476 * thru the motions.
477 * @retval VERR_SEM_LV_INVALID_PARAMETER if the input is invalid.
478 *
479 * @param pRead The validator record for the readers.
480 * @param pWrite The validator record for the writer.
481 */
482RTDECL(int) RTLockValidatorUnwindReadWriteRecursion(PRTLOCKVALIDATORREC pWrite, PRTLOCKVALIDATORSHARED pRead);
483
484/**
485 * Record the specified thread as lock owner and increment the write lock count.
486 *
487 * This function is typically called after acquiring the lock.
488 *
489 * @returns hThread resolved. Can return NIL_RTHREAD iff we fail to adopt the
490 * alien thread or if pRec is invalid.
491 *
492 * @param pRec The validator record.
493 * @param hThread The handle of the calling thread. If not known,
494 * pass NIL_RTTHREAD and this method will figure it
495 * out.
496 * @param pSrcPos The source position of the lock operation.
497 */
498RTDECL(RTTHREAD) RTLockValidatorSetOwner(PRTLOCKVALIDATORREC pRec, RTTHREAD hThread, PCRTLOCKVALIDATORSRCPOS pSrcPos);
499
500/**
501 * Clear the lock ownership and decrement the write lock count.
502 *
503 * This is typically called before release the lock.
504 *
505 * @returns The thread handle of the previous owner. NIL_RTTHREAD if the record
506 * is invalid or didn't have any owner.
507 * @param pRec The validator record.
508 */
509RTDECL(RTTHREAD) RTLockValidatorUnsetOwner(PRTLOCKVALIDATORREC pRec);
510
511/**
512 * Adds an owner to a shared locking record.
513 *
514 * Takes recursion into account. This function is typically called after
515 * acquiring the lock.
516 *
517 * @param pRead The validator record.
518 * @param hThread The thread to add.
519 * @param pSrcPos The source position of the lock operation.
520 */
521RTDECL(void) RTLockValidatorAddReadOwner(PRTLOCKVALIDATORSHARED pRead, RTTHREAD hThread, PCRTLOCKVALIDATORSRCPOS pSrcPos);
522
523/**
524 * Removes an owner from a shared locking record.
525 *
526 * Takes recursion into account. This function is typically called before
527 * releaseing the lock.
528 *
529 * @param pRead The validator record.
530 * @param hThread The thread to to remove.
531 */
532RTDECL(void) RTLockValidatorRemoveReadOwner(PRTLOCKVALIDATORSHARED pRead, RTTHREAD hThread);
533
534/**
535 * Gets the number of write locks and critical sections the specified
536 * thread owns.
537 *
538 * This number does not include any nested lock/critect entries.
539 *
540 * Note that it probably will return 0 for non-strict builds since
541 * release builds doesn't do unnecessary diagnostic counting like this.
542 *
543 * @returns Number of locks on success (0+) and VERR_INVALID_HANDLER on failure
544 * @param Thread The thread we're inquiring about.
545 * @remarks Will only work for strict builds.
546 */
547RTDECL(int32_t) RTLockValidatorWriteLockGetCount(RTTHREAD Thread);
548
549/**
550 * Works the THREADINT::cWriteLocks member, mostly internal.
551 *
552 * @param Thread The current thread.
553 */
554RTDECL(void) RTLockValidatorWriteLockInc(RTTHREAD Thread);
555
556/**
557 * Works the THREADINT::cWriteLocks member, mostly internal.
558 *
559 * @param Thread The current thread.
560 */
561RTDECL(void) RTLockValidatorWriteLockDec(RTTHREAD Thread);
562
563/**
564 * Gets the number of read locks the specified thread owns.
565 *
566 * Note that nesting read lock entry will be included in the
567 * total sum. And that it probably will return 0 for non-strict
568 * builds since release builds doesn't do unnecessary diagnostic
569 * counting like this.
570 *
571 * @returns Number of read locks on success (0+) and VERR_INVALID_HANDLER on failure
572 * @param Thread The thread we're inquiring about.
573 */
574RTDECL(int32_t) RTLockValidatorReadLockGetCount(RTTHREAD Thread);
575
576/**
577 * Works the THREADINT::cReadLocks member.
578 *
579 * @param Thread The current thread.
580 */
581RTDECL(void) RTLockValidatorReadLockInc(RTTHREAD Thread);
582
583/**
584 * Works the THREADINT::cReadLocks member.
585 *
586 * @param Thread The current thread.
587 */
588RTDECL(void) RTLockValidatorReadLockDec(RTTHREAD Thread);
589
590
591
592/*RTDECL(int) RTLockValidatorClassCreate();*/
593
594
595
596/**
597 * Enables / disables the lock validator for new locks.
598 *
599 * @returns The old setting.
600 * @param fEnabled The new setting.
601 */
602RTDECL(bool) RTLockValidatorSetEnabled(bool fEnabled);
603
604/**
605 * Is the lock validator enabled?
606 *
607 * @returns True if enabled, false if not.
608 */
609RTDECL(bool) RTLockValidatorIsEnabled(void);
610
611
612RT_C_DECLS_END
613
614/** @} */
615
616#endif
617
618
Note: See TracBrowser for help on using the repository browser.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette