lockvalidator.h revision c364b6c44a252ab65b514fa8f9a665cc5e33a1ce
9ad572a3ac0fd3845a9abecfbf41e8db9b3a5cf0vboxsync/** @file
71c8a528203c289a8585ce10ac6bafc4274058c6vboxsync * IPRT - Lock Validator.
adf2bcd2e5d07d5a11553b88e147c1f4b2249bffvboxsync */
71c8a528203c289a8585ce10ac6bafc4274058c6vboxsync
71c8a528203c289a8585ce10ac6bafc4274058c6vboxsync/*
71c8a528203c289a8585ce10ac6bafc4274058c6vboxsync * Copyright (C) 2009 Sun Microsystems, Inc.
67ee25dd0b63a61dc35a35d0aade75ca6cd06350vboxsync *
71c8a528203c289a8585ce10ac6bafc4274058c6vboxsync * This file is part of VirtualBox Open Source Edition (OSE), as
71c8a528203c289a8585ce10ac6bafc4274058c6vboxsync * available from http://www.virtualbox.org. This file is free software;
71c8a528203c289a8585ce10ac6bafc4274058c6vboxsync * you can redistribute it and/or modify it under the terms of the GNU
71c8a528203c289a8585ce10ac6bafc4274058c6vboxsync * General Public License (GPL) as published by the Free Software
71c8a528203c289a8585ce10ac6bafc4274058c6vboxsync * Foundation, in version 2 as it comes in the "COPYING" file of the
71c8a528203c289a8585ce10ac6bafc4274058c6vboxsync * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
71c8a528203c289a8585ce10ac6bafc4274058c6vboxsync * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
71c8a528203c289a8585ce10ac6bafc4274058c6vboxsync *
71c8a528203c289a8585ce10ac6bafc4274058c6vboxsync * The contents of this file may alternatively be used under the terms
71c8a528203c289a8585ce10ac6bafc4274058c6vboxsync * of the Common Development and Distribution License Version 1.0
71c8a528203c289a8585ce10ac6bafc4274058c6vboxsync * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
71c8a528203c289a8585ce10ac6bafc4274058c6vboxsync * VirtualBox OSE distribution, in which case the provisions of the
71c8a528203c289a8585ce10ac6bafc4274058c6vboxsync * CDDL are applicable instead of those of the GPL.
71c8a528203c289a8585ce10ac6bafc4274058c6vboxsync *
71c8a528203c289a8585ce10ac6bafc4274058c6vboxsync * You may elect to license modified versions of this file under the
70bb61ea2f96e80150e807529ce5df435607706bvboxsync * terms and conditions of either the GPL or the CDDL or both.
71c8a528203c289a8585ce10ac6bafc4274058c6vboxsync *
23179f1443b03947d85eccc81cbc6b5153a4abf3vboxsync * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
71c8a528203c289a8585ce10ac6bafc4274058c6vboxsync * Clara, CA 95054 USA or visit http://www.sun.com if you need
71c8a528203c289a8585ce10ac6bafc4274058c6vboxsync * additional information or have any questions.
71c8a528203c289a8585ce10ac6bafc4274058c6vboxsync */
71c8a528203c289a8585ce10ac6bafc4274058c6vboxsync
71c8a528203c289a8585ce10ac6bafc4274058c6vboxsync#ifndef ___iprt_lockvalidator_h
71c8a528203c289a8585ce10ac6bafc4274058c6vboxsync#define ___iprt_lockvalidator_h
71c8a528203c289a8585ce10ac6bafc4274058c6vboxsync
71c8a528203c289a8585ce10ac6bafc4274058c6vboxsync#include <iprt/cdefs.h>
71c8a528203c289a8585ce10ac6bafc4274058c6vboxsync#include <iprt/types.h>
71c8a528203c289a8585ce10ac6bafc4274058c6vboxsync#include <iprt/assert.h>
147e101bcd061b5e085e4a2c0cc9fc35546ff1aavboxsync#include <iprt/thread.h>
71c8a528203c289a8585ce10ac6bafc4274058c6vboxsync
71c8a528203c289a8585ce10ac6bafc4274058c6vboxsync
71c8a528203c289a8585ce10ac6bafc4274058c6vboxsync/** @defgroup grp_ldr RTLockValidator - Lock Validator
71c8a528203c289a8585ce10ac6bafc4274058c6vboxsync * @ingroup grp_rt
71c8a528203c289a8585ce10ac6bafc4274058c6vboxsync * @{
71c8a528203c289a8585ce10ac6bafc4274058c6vboxsync */
71c8a528203c289a8585ce10ac6bafc4274058c6vboxsync
71c8a528203c289a8585ce10ac6bafc4274058c6vboxsyncRT_C_DECLS_BEGIN
71c8a528203c289a8585ce10ac6bafc4274058c6vboxsync
71c8a528203c289a8585ce10ac6bafc4274058c6vboxsync/** Pointer to a record union.
71c8a528203c289a8585ce10ac6bafc4274058c6vboxsync * @internal */
71c8a528203c289a8585ce10ac6bafc4274058c6vboxsynctypedef union RTLOCKVALRECUNION *PRTLOCKVALRECUNION;
71c8a528203c289a8585ce10ac6bafc4274058c6vboxsync
9e4ea89b1085fdaa5861e45a729d9c978db1a8f1vboxsync/**
147e101bcd061b5e085e4a2c0cc9fc35546ff1aavboxsync * Source position.
9e4ea89b1085fdaa5861e45a729d9c978db1a8f1vboxsync */
9e4ea89b1085fdaa5861e45a729d9c978db1a8f1vboxsynctypedef struct RTLOCKVALSRCPOS
9e4ea89b1085fdaa5861e45a729d9c978db1a8f1vboxsync{
b304856b23107864c9c594a80cebca6006623f31vboxsync /** The file where the lock was taken. */
9e4ea89b1085fdaa5861e45a729d9c978db1a8f1vboxsync R3R0PTRTYPE(const char * volatile) pszFile;
9e4ea89b1085fdaa5861e45a729d9c978db1a8f1vboxsync /** The function where the lock was taken. */
9e4ea89b1085fdaa5861e45a729d9c978db1a8f1vboxsync R3R0PTRTYPE(const char * volatile) pszFunction;
9e4ea89b1085fdaa5861e45a729d9c978db1a8f1vboxsync /** Some ID indicating where the lock was taken, typically an address. */
9e4ea89b1085fdaa5861e45a729d9c978db1a8f1vboxsync RTHCUINTPTR volatile uId;
9e4ea89b1085fdaa5861e45a729d9c978db1a8f1vboxsync /** The line number in the file. */
9e4ea89b1085fdaa5861e45a729d9c978db1a8f1vboxsync uint32_t volatile uLine;
9e4ea89b1085fdaa5861e45a729d9c978db1a8f1vboxsync#if HC_ARCH_BITS == 64
9e4ea89b1085fdaa5861e45a729d9c978db1a8f1vboxsync uint32_t u32Padding; /**< Alignment padding. */
c33fc49611f2444dade533488bf431e29eb88bcdvboxsync#endif
9e4ea89b1085fdaa5861e45a729d9c978db1a8f1vboxsync} RTLOCKVALSRCPOS;
9e4ea89b1085fdaa5861e45a729d9c978db1a8f1vboxsyncAssertCompileSize(RTLOCKVALSRCPOS, HC_ARCH_BITS == 32 ? 16 : 32);
6e12ccc60ac657fb87e27b7a2b26e0a63bebe024vboxsync/* The pointer types are defined in iprt/types.h. */
6e12ccc60ac657fb87e27b7a2b26e0a63bebe024vboxsync
6e12ccc60ac657fb87e27b7a2b26e0a63bebe024vboxsync/** @def RTLOCKVALSRCPOS_INIT
db0ecde8f28fdb4525bc6d94056166c70b02ebb8vboxsync * Initializer for a RTLOCKVALSRCPOS variable.
db0ecde8f28fdb4525bc6d94056166c70b02ebb8vboxsync *
db0ecde8f28fdb4525bc6d94056166c70b02ebb8vboxsync * @param pszFile The file name. Optional (NULL).
9e4ea89b1085fdaa5861e45a729d9c978db1a8f1vboxsync * @param uLine The line number in that file. Optional (0).
9e4ea89b1085fdaa5861e45a729d9c978db1a8f1vboxsync * @param pszFunction The function. Optional (NULL).
9353e321b583ed6f2b42414257a5212885575b5cvboxsync * @param uId Some location ID, normally the return address.
9e4ea89b1085fdaa5861e45a729d9c978db1a8f1vboxsync * Optional (NULL).
9353e321b583ed6f2b42414257a5212885575b5cvboxsync */
9e4ea89b1085fdaa5861e45a729d9c978db1a8f1vboxsync#if HC_ARCH_BITS == 64
9e4ea89b1085fdaa5861e45a729d9c978db1a8f1vboxsync# define RTLOCKVALSRCPOS_INIT(pszFile, uLine, pszFunction, uId) \
9e4ea89b1085fdaa5861e45a729d9c978db1a8f1vboxsync { (pszFile), (pszFunction), (uId), (uLine), 0 }
9e4ea89b1085fdaa5861e45a729d9c978db1a8f1vboxsync#else
9e4ea89b1085fdaa5861e45a729d9c978db1a8f1vboxsync# define RTLOCKVALSRCPOS_INIT(pszFile, uLine, pszFunction, uId) \
9e4ea89b1085fdaa5861e45a729d9c978db1a8f1vboxsync { (pszFile), (pszFunction), (uId), (uLine) }
9e4ea89b1085fdaa5861e45a729d9c978db1a8f1vboxsync#endif
9e4ea89b1085fdaa5861e45a729d9c978db1a8f1vboxsync
2a5e5a032e6f23f8937718e4ee4d6979188bdd19vboxsync/** @def RTLOCKVALSRCPOS_INIT_DEBUG_API
2a5e5a032e6f23f8937718e4ee4d6979188bdd19vboxsync * Initializer for a RTLOCKVALSRCPOS variable in a typicial debug API
2a5e5a032e6f23f8937718e4ee4d6979188bdd19vboxsync * variant. Assumes RT_SRC_POS_DECL and RTHCUINTPTR uId as arguments.
2a5e5a032e6f23f8937718e4ee4d6979188bdd19vboxsync */
2a5e5a032e6f23f8937718e4ee4d6979188bdd19vboxsync#define RTLOCKVALSRCPOS_INIT_DEBUG_API() \
2a5e5a032e6f23f8937718e4ee4d6979188bdd19vboxsync RTLOCKVALSRCPOS_INIT(pszFile, iLine, pszFunction, uId)
2a5e5a032e6f23f8937718e4ee4d6979188bdd19vboxsync
2a5e5a032e6f23f8937718e4ee4d6979188bdd19vboxsync/** @def RTLOCKVALSRCPOS_INIT_NORMAL_API
2a5e5a032e6f23f8937718e4ee4d6979188bdd19vboxsync * Initializer for a RTLOCKVALSRCPOS variable in a normal API
2a5e5a032e6f23f8937718e4ee4d6979188bdd19vboxsync * variant. Assumes iprt/asm.h is included.
2a5e5a032e6f23f8937718e4ee4d6979188bdd19vboxsync */
2a5e5a032e6f23f8937718e4ee4d6979188bdd19vboxsync#define RTLOCKVALSRCPOS_INIT_NORMAL_API() \
2a5e5a032e6f23f8937718e4ee4d6979188bdd19vboxsync RTLOCKVALSRCPOS_INIT(__FILE__, __LINE__, __PRETTY_FUNCTION__, (uintptr_t)ASMReturnAddress())
2a5e5a032e6f23f8937718e4ee4d6979188bdd19vboxsync
9e4ea89b1085fdaa5861e45a729d9c978db1a8f1vboxsync/** Pointer to a record of one ownership share. */
9e4ea89b1085fdaa5861e45a729d9c978db1a8f1vboxsynctypedef struct RTLOCKVALRECSHRD *PRTLOCKVALRECSHRD;
aa0553becec2abc2e781f839ba1d399c31c2c07fvboxsync
9e4ea89b1085fdaa5861e45a729d9c978db1a8f1vboxsync
9e4ea89b1085fdaa5861e45a729d9c978db1a8f1vboxsync/**
f62342e2cc901a67e27fa69c0e712ee35e9c4c68vboxsync * Lock validator record core.
b604fbf16eda38d14b4999c245f032bfaa5aa85avboxsync */
13d1fd6f43e9a245a4f2b4fc6845bdaa5d0f4134vboxsynctypedef struct RTLOCKVALRECORE
9e4ea89b1085fdaa5861e45a729d9c978db1a8f1vboxsync{
9e4ea89b1085fdaa5861e45a729d9c978db1a8f1vboxsync /** The magic value indicating the record type. */
9e4ea89b1085fdaa5861e45a729d9c978db1a8f1vboxsync uint32_t volatile u32Magic;
9e4ea89b1085fdaa5861e45a729d9c978db1a8f1vboxsync} RTLOCKVALRECCORE;
9e4ea89b1085fdaa5861e45a729d9c978db1a8f1vboxsync/** Pointer to a lock validator record core. */
9e4ea89b1085fdaa5861e45a729d9c978db1a8f1vboxsynctypedef RTLOCKVALRECCORE *PRTLOCKVALRECCORE;
aa0553becec2abc2e781f839ba1d399c31c2c07fvboxsync/** Pointer to a const lock validator record core. */
cebc93936b5bb4d867e1c086dd1b206db33c31dcvboxsynctypedef RTLOCKVALRECCORE const *PCRTLOCKVALRECCORE;
cebc93936b5bb4d867e1c086dd1b206db33c31dcvboxsync
cebc93936b5bb4d867e1c086dd1b206db33c31dcvboxsync
62a515eec8de1b7804ec6997c0f2013fef5c5a6bvboxsync/**
cebc93936b5bb4d867e1c086dd1b206db33c31dcvboxsync * Record recording the exclusive ownership of a lock.
cebc93936b5bb4d867e1c086dd1b206db33c31dcvboxsync *
cebc93936b5bb4d867e1c086dd1b206db33c31dcvboxsync * This is typically part of the per-lock data structure when compiling with
cebc93936b5bb4d867e1c086dd1b206db33c31dcvboxsync * the lock validator.
cebc93936b5bb4d867e1c086dd1b206db33c31dcvboxsync */
cebc93936b5bb4d867e1c086dd1b206db33c31dcvboxsynctypedef struct RTLOCKVALRECEXCL
9e4ea89b1085fdaa5861e45a729d9c978db1a8f1vboxsync{
19cb1f8699e352d590c4946caee33863a5157241vboxsync /** Record core with RTLOCKVALRECEXCL_MAGIC as the magic value. */
19cb1f8699e352d590c4946caee33863a5157241vboxsync RTLOCKVALRECCORE Core;
9e4ea89b1085fdaa5861e45a729d9c978db1a8f1vboxsync /** Whether it's enabled or not. */
9e4ea89b1085fdaa5861e45a729d9c978db1a8f1vboxsync bool fEnabled;
67ee25dd0b63a61dc35a35d0aade75ca6cd06350vboxsync /** Reserved. */
67ee25dd0b63a61dc35a35d0aade75ca6cd06350vboxsync bool afReserved[3];
67ee25dd0b63a61dc35a35d0aade75ca6cd06350vboxsync /** Source position where the lock was taken. */
67ee25dd0b63a61dc35a35d0aade75ca6cd06350vboxsync RTLOCKVALSRCPOS SrcPos;
9e4ea89b1085fdaa5861e45a729d9c978db1a8f1vboxsync /** The current owner thread. */
9e4ea89b1085fdaa5861e45a729d9c978db1a8f1vboxsync RTTHREAD volatile hThread;
9e4ea89b1085fdaa5861e45a729d9c978db1a8f1vboxsync /** Pointer to the lock record below us. Only accessed by the owner. */
9e4ea89b1085fdaa5861e45a729d9c978db1a8f1vboxsync R3R0PTRTYPE(PRTLOCKVALRECUNION) pDown;
3933885bc0c2c93436d858a14564c6179ec72872vboxsync /** Recursion count */
3933885bc0c2c93436d858a14564c6179ec72872vboxsync uint32_t cRecursion;
3933885bc0c2c93436d858a14564c6179ec72872vboxsync /** The lock sub-class. */
3933885bc0c2c93436d858a14564c6179ec72872vboxsync uint32_t volatile uSubClass;
3933885bc0c2c93436d858a14564c6179ec72872vboxsync /** The lock class. */
3933885bc0c2c93436d858a14564c6179ec72872vboxsync RTLOCKVALIDATORCLASS hClass;
3933885bc0c2c93436d858a14564c6179ec72872vboxsync /** Pointer to the lock. */
3933885bc0c2c93436d858a14564c6179ec72872vboxsync RTHCPTR hLock;
cc74f15083bf80fbc96723a89faa06c15d0dead8vboxsync /** The lock name. */
a72b5355eb89aafe6bfcc8912cf02645d7cccceavboxsync R3R0PTRTYPE(const char *) pszName;
a72b5355eb89aafe6bfcc8912cf02645d7cccceavboxsync /** Pointer to the next sibling record.
3933885bc0c2c93436d858a14564c6179ec72872vboxsync * This is used to find the read side of a read-write lock. */
6e25221ce8ef8e656d1e15eb7ec5cf8ae758ceb2vboxsync R3R0PTRTYPE(PRTLOCKVALRECUNION) pSibling;
3933885bc0c2c93436d858a14564c6179ec72872vboxsync} RTLOCKVALRECEXCL;
3933885bc0c2c93436d858a14564c6179ec72872vboxsyncAssertCompileSize(RTLOCKVALRECEXCL, HC_ARCH_BITS == 32 ? 8 + 16 + 32 : 8 + 32 + 56);
3933885bc0c2c93436d858a14564c6179ec72872vboxsync/* The pointer type is defined in iprt/types.h. */
3933885bc0c2c93436d858a14564c6179ec72872vboxsync
9ca017ceee656f9d33f2cb6652e401b5f17fcfb7vboxsync/**
3933885bc0c2c93436d858a14564c6179ec72872vboxsync * For recording the one ownership share.
e2760cdc84c692bc46cfaf5018d313db2f122acavboxsync */
9e4ea89b1085fdaa5861e45a729d9c978db1a8f1vboxsynctypedef struct RTLOCKVALRECSHRDOWN
9e4ea89b1085fdaa5861e45a729d9c978db1a8f1vboxsync{
9e4ea89b1085fdaa5861e45a729d9c978db1a8f1vboxsync /** Record core with RTLOCKVALRECSHRDOWN_MAGIC as the magic value. */
9e4ea89b1085fdaa5861e45a729d9c978db1a8f1vboxsync RTLOCKVALRECCORE Core;
9e4ea89b1085fdaa5861e45a729d9c978db1a8f1vboxsync /** Recursion count */
9e4ea89b1085fdaa5861e45a729d9c978db1a8f1vboxsync uint16_t cRecursion;
ad9e5a61fea617d40d07390ff1737277d6aef869vboxsync /** Static (true) or dynamic (false) allocated record. */
a9315925c69e4c3bb342bb317ca5b6d29e1ee467vboxsync bool fStaticAlloc;
a9315925c69e4c3bb342bb317ca5b6d29e1ee467vboxsync /** Reserved. */
a9315925c69e4c3bb342bb317ca5b6d29e1ee467vboxsync bool fReserved;
dbabc9de5bf52ce5eb77cf82b038e9a6166c5a04vboxsync /** The current owner thread. */
4090390866c02d5d0ad061151cdb298b9a173e86vboxsync RTTHREAD volatile hThread;
4090390866c02d5d0ad061151cdb298b9a173e86vboxsync /** Pointer to the lock record below us. Only accessed by the owner. */
40dce69ff1c2949a489337922f30f1021d62d864vboxsync R3R0PTRTYPE(PRTLOCKVALRECUNION) pDown;
40dce69ff1c2949a489337922f30f1021d62d864vboxsync /** Pointer back to the shared record. */
40dce69ff1c2949a489337922f30f1021d62d864vboxsync R3R0PTRTYPE(PRTLOCKVALRECSHRD) pSharedRec;
40dce69ff1c2949a489337922f30f1021d62d864vboxsync#if HC_ARCH_BITS == 32
40dce69ff1c2949a489337922f30f1021d62d864vboxsync /** Reserved. */
657b2c9f6d33f08001e5fa6f6e0572dcf0391013vboxsync RTHCPTR pvReserved;
7a29aa5ce149ccd344a2929d2815b8e212690b92vboxsync#endif
a1b4fb3917412d2632d358ff8989f1ec971f2d5bvboxsync /** Source position where the lock was taken. */
a1b4fb3917412d2632d358ff8989f1ec971f2d5bvboxsync RTLOCKVALSRCPOS SrcPos;
a1b4fb3917412d2632d358ff8989f1ec971f2d5bvboxsync} RTLOCKVALRECSHRDOWN;
a1b4fb3917412d2632d358ff8989f1ec971f2d5bvboxsyncAssertCompileSize(RTLOCKVALRECSHRDOWN, HC_ARCH_BITS == 32 ? 24 + 16 : 32 + 32);
7a29aa5ce149ccd344a2929d2815b8e212690b92vboxsync/** Pointer to a RTLOCKVALRECSHRDOWN. */
147e101bcd061b5e085e4a2c0cc9fc35546ff1aavboxsynctypedef RTLOCKVALRECSHRDOWN *PRTLOCKVALRECSHRDOWN;
147e101bcd061b5e085e4a2c0cc9fc35546ff1aavboxsync
147e101bcd061b5e085e4a2c0cc9fc35546ff1aavboxsync/**
147e101bcd061b5e085e4a2c0cc9fc35546ff1aavboxsync * Record recording the shared ownership of a lock.
9e4ea89b1085fdaa5861e45a729d9c978db1a8f1vboxsync *
9e4ea89b1085fdaa5861e45a729d9c978db1a8f1vboxsync * This is typically part of the per-lock data structure when compiling with
9e4ea89b1085fdaa5861e45a729d9c978db1a8f1vboxsync * the lock validator.
b304856b23107864c9c594a80cebca6006623f31vboxsync */
9e4ea89b1085fdaa5861e45a729d9c978db1a8f1vboxsynctypedef struct RTLOCKVALRECSHRD
9e4ea89b1085fdaa5861e45a729d9c978db1a8f1vboxsync{
261b44f7fa60a1d4bb4102142d3aa44188908484vboxsync /** Record core with RTLOCKVALRECSHRD_MAGIC as the magic value. */
261b44f7fa60a1d4bb4102142d3aa44188908484vboxsync RTLOCKVALRECCORE Core;
261b44f7fa60a1d4bb4102142d3aa44188908484vboxsync /** The lock sub-class. */
261b44f7fa60a1d4bb4102142d3aa44188908484vboxsync uint32_t volatile uSubClass;
261b44f7fa60a1d4bb4102142d3aa44188908484vboxsync /** The lock class. */
261b44f7fa60a1d4bb4102142d3aa44188908484vboxsync RTLOCKVALIDATORCLASS hClass;
261b44f7fa60a1d4bb4102142d3aa44188908484vboxsync /** Pointer to the lock. */
c33fc49611f2444dade533488bf431e29eb88bcdvboxsync RTHCPTR hLock;
261b44f7fa60a1d4bb4102142d3aa44188908484vboxsync /** The lock name. */
db0ecde8f28fdb4525bc6d94056166c70b02ebb8vboxsync R3R0PTRTYPE(const char *) pszName;
db0ecde8f28fdb4525bc6d94056166c70b02ebb8vboxsync /** Pointer to the next sibling record.
db0ecde8f28fdb4525bc6d94056166c70b02ebb8vboxsync * This is used to find the write side of a read-write lock. */
9e4ea89b1085fdaa5861e45a729d9c978db1a8f1vboxsync R3R0PTRTYPE(PRTLOCKVALRECUNION) pSibling;
6e12ccc60ac657fb87e27b7a2b26e0a63bebe024vboxsync
6e12ccc60ac657fb87e27b7a2b26e0a63bebe024vboxsync /** The number of entries in the table.
6e12ccc60ac657fb87e27b7a2b26e0a63bebe024vboxsync * Updated before inserting and after removal. */
657b2c9f6d33f08001e5fa6f6e0572dcf0391013vboxsync uint32_t volatile cEntries;
e2760cdc84c692bc46cfaf5018d313db2f122acavboxsync /** The index of the last entry (approximately). */
9e4ea89b1085fdaa5861e45a729d9c978db1a8f1vboxsync uint32_t volatile iLastEntry;
261b44f7fa60a1d4bb4102142d3aa44188908484vboxsync /** The max table size. */
9353e321b583ed6f2b42414257a5212885575b5cvboxsync uint32_t volatile cAllocated;
261b44f7fa60a1d4bb4102142d3aa44188908484vboxsync /** Set if the table is being reallocated, clear if not.
9353e321b583ed6f2b42414257a5212885575b5cvboxsync * This is used together with rtLockValidatorSerializeDetectionEnter to make
261b44f7fa60a1d4bb4102142d3aa44188908484vboxsync * sure there is exactly one thread doing the reallocation and that nobody is
261b44f7fa60a1d4bb4102142d3aa44188908484vboxsync * using the table at that point. */
fc5f879e9508f333e20b37c63db9189a33059308vboxsync bool volatile fReallocating;
9e4ea89b1085fdaa5861e45a729d9c978db1a8f1vboxsync /** Whether it's enabled or not. */
9e4ea89b1085fdaa5861e45a729d9c978db1a8f1vboxsync bool fEnabled;
1c6ec9a3a329da6f61978a372e509cd233f0d9f9vboxsync /** Alignment padding. */
261b44f7fa60a1d4bb4102142d3aa44188908484vboxsync bool afPadding[2];
9e4ea89b1085fdaa5861e45a729d9c978db1a8f1vboxsync /** Pointer to a table containing pointers to records of all the owners. */
9e4ea89b1085fdaa5861e45a729d9c978db1a8f1vboxsync R3R0PTRTYPE(PRTLOCKVALRECSHRDOWN volatile *) papOwners;
9e4ea89b1085fdaa5861e45a729d9c978db1a8f1vboxsync#if HC_ARCH_BITS == 32
9e4ea89b1085fdaa5861e45a729d9c978db1a8f1vboxsync /** Alignment padding. */
9e4ea89b1085fdaa5861e45a729d9c978db1a8f1vboxsync uint32_t u32Alignment;
9e4ea89b1085fdaa5861e45a729d9c978db1a8f1vboxsync#endif
9e4ea89b1085fdaa5861e45a729d9c978db1a8f1vboxsync} RTLOCKVALRECSHRD;
9e4ea89b1085fdaa5861e45a729d9c978db1a8f1vboxsyncAssertCompileSize(RTLOCKVALRECSHRD, HC_ARCH_BITS == 32 ? 24 + 20 + 4 : 40 + 24);
9e4ea89b1085fdaa5861e45a729d9c978db1a8f1vboxsync
9e4ea89b1085fdaa5861e45a729d9c978db1a8f1vboxsync
9e4ea89b1085fdaa5861e45a729d9c978db1a8f1vboxsync/** @name Special sub-class values.
9e4ea89b1085fdaa5861e45a729d9c978db1a8f1vboxsync * The range 16..UINT32_MAX is available to the user, the range 0..15 is
9e4ea89b1085fdaa5861e45a729d9c978db1a8f1vboxsync * reserved for the lock validator.
9e4ea89b1085fdaa5861e45a729d9c978db1a8f1vboxsync * @{ */
9e4ea89b1085fdaa5861e45a729d9c978db1a8f1vboxsync/** Not allowed to be taken with any other locks in the same class.
9e4ea89b1085fdaa5861e45a729d9c978db1a8f1vboxsync * This is the recommended value. */
261b44f7fa60a1d4bb4102142d3aa44188908484vboxsync#define RTLOCKVALIDATOR_SUB_CLASS_NONE UINT32_C(0)
aa0553becec2abc2e781f839ba1d399c31c2c07fvboxsync/** Any order is allowed within the class. */
9e4ea89b1085fdaa5861e45a729d9c978db1a8f1vboxsync#define RTLOCKVALIDATOR_SUB_CLASS_ANY UINT32_C(1)
9e4ea89b1085fdaa5861e45a729d9c978db1a8f1vboxsync/** The first user value. */
f62342e2cc901a67e27fa69c0e712ee35e9c4c68vboxsync#define RTLOCKVALIDATOR_SUB_CLASS_USER UINT32_C(16)
b604fbf16eda38d14b4999c245f032bfaa5aa85avboxsync/** @} */
13d1fd6f43e9a245a4f2b4fc6845bdaa5d0f4134vboxsync
9e4ea89b1085fdaa5861e45a729d9c978db1a8f1vboxsync/**
261b44f7fa60a1d4bb4102142d3aa44188908484vboxsync * Makes the two records siblings.
9e4ea89b1085fdaa5861e45a729d9c978db1a8f1vboxsync *
9e4ea89b1085fdaa5861e45a729d9c978db1a8f1vboxsync * @returns VINF_SUCCESS on success, VERR_SEM_LV_INVALID_PARAMETER if either of
9e4ea89b1085fdaa5861e45a729d9c978db1a8f1vboxsync * the records are invalid.
9e4ea89b1085fdaa5861e45a729d9c978db1a8f1vboxsync * @param pRec1 Record 1.
aa0553becec2abc2e781f839ba1d399c31c2c07fvboxsync * @param pRec2 Record 2.
cebc93936b5bb4d867e1c086dd1b206db33c31dcvboxsync */
95cb8e789c1eed6f2bb3195d0b996feee11d548evboxsyncRTDECL(int) RTLockValidatorRecMakeSiblings(PRTLOCKVALRECCORE pRec1, PRTLOCKVALRECCORE pRec2);
cebc93936b5bb4d867e1c086dd1b206db33c31dcvboxsync
62a515eec8de1b7804ec6997c0f2013fef5c5a6bvboxsync/**
cebc93936b5bb4d867e1c086dd1b206db33c31dcvboxsync * Initialize a lock validator record.
cebc93936b5bb4d867e1c086dd1b206db33c31dcvboxsync *
cebc93936b5bb4d867e1c086dd1b206db33c31dcvboxsync * Use RTLockValidatorRecExclDelete to deinitialize it.
cebc93936b5bb4d867e1c086dd1b206db33c31dcvboxsync *
cebc93936b5bb4d867e1c086dd1b206db33c31dcvboxsync * @param pRec The record.
cebc93936b5bb4d867e1c086dd1b206db33c31dcvboxsync * @param hClass The class. If NIL, the no lock order
9e4ea89b1085fdaa5861e45a729d9c978db1a8f1vboxsync * validation will be performed on this lock.
19cb1f8699e352d590c4946caee33863a5157241vboxsync * @param uSubClass The sub-class. This is used to define lock
19cb1f8699e352d590c4946caee33863a5157241vboxsync * order inside the same class. If you don't know,
9e4ea89b1085fdaa5861e45a729d9c978db1a8f1vboxsync * then pass RTLOCKVALIDATOR_SUB_CLASS_NONE.
9e4ea89b1085fdaa5861e45a729d9c978db1a8f1vboxsync * @param pszName The lock name (optional).
67ee25dd0b63a61dc35a35d0aade75ca6cd06350vboxsync * @param hLock The lock handle.
67ee25dd0b63a61dc35a35d0aade75ca6cd06350vboxsync */
67ee25dd0b63a61dc35a35d0aade75ca6cd06350vboxsyncRTDECL(void) RTLockValidatorRecExclInit(PRTLOCKVALRECEXCL pRec, RTLOCKVALIDATORCLASS hClass,
67ee25dd0b63a61dc35a35d0aade75ca6cd06350vboxsync uint32_t uSubClass, const char *pszName, void *hLock);
9e4ea89b1085fdaa5861e45a729d9c978db1a8f1vboxsync/**
9e4ea89b1085fdaa5861e45a729d9c978db1a8f1vboxsync * Uninitialize a lock validator record previously initialized by
9e4ea89b1085fdaa5861e45a729d9c978db1a8f1vboxsync * RTLockRecValidatorInit.
9e4ea89b1085fdaa5861e45a729d9c978db1a8f1vboxsync *
3933885bc0c2c93436d858a14564c6179ec72872vboxsync * @param pRec The record. Must be valid.
3933885bc0c2c93436d858a14564c6179ec72872vboxsync */
3933885bc0c2c93436d858a14564c6179ec72872vboxsyncRTDECL(void) RTLockValidatorRecExclDelete(PRTLOCKVALRECEXCL pRec);
3933885bc0c2c93436d858a14564c6179ec72872vboxsync
3933885bc0c2c93436d858a14564c6179ec72872vboxsync/**
3933885bc0c2c93436d858a14564c6179ec72872vboxsync * Create and initialize a lock validator record.
060f7ec6ae5c99df18341ef2e1f3e91f4b0c89f1vboxsync *
3933885bc0c2c93436d858a14564c6179ec72872vboxsync * Use RTLockValidatorRecExclDestroy to deinitialize and destroy the returned
cc74f15083bf80fbc96723a89faa06c15d0dead8vboxsync * record.
a72b5355eb89aafe6bfcc8912cf02645d7cccceavboxsync *
a72b5355eb89aafe6bfcc8912cf02645d7cccceavboxsync * @return VINF_SUCCESS or VERR_NO_MEMORY.
3933885bc0c2c93436d858a14564c6179ec72872vboxsync * @param ppRec Where to return the record pointer.
6e25221ce8ef8e656d1e15eb7ec5cf8ae758ceb2vboxsync * @param hClass The class. If NIL, the no lock order
3933885bc0c2c93436d858a14564c6179ec72872vboxsync * validation will be performed on this lock.
3933885bc0c2c93436d858a14564c6179ec72872vboxsync * @param uSubClass The sub-class. This is used to define lock
3933885bc0c2c93436d858a14564c6179ec72872vboxsync * order inside the same class. If you don't know,
060f7ec6ae5c99df18341ef2e1f3e91f4b0c89f1vboxsync * then pass RTLOCKVALIDATOR_SUB_CLASS_NONE.
9ca017ceee656f9d33f2cb6652e401b5f17fcfb7vboxsync * @param pszName The lock name (optional).
3933885bc0c2c93436d858a14564c6179ec72872vboxsync * @param hLock The lock handle.
261b44f7fa60a1d4bb4102142d3aa44188908484vboxsync */
261b44f7fa60a1d4bb4102142d3aa44188908484vboxsyncRTDECL(int) RTLockValidatorRecExclCreate(PRTLOCKVALRECEXCL *ppRec, RTLOCKVALIDATORCLASS hClass,
9e4ea89b1085fdaa5861e45a729d9c978db1a8f1vboxsync uint32_t uSubClass, const char *pszName, void *hLock);
f106b549ead77cab51ff1e2c116060aaabb90d5evboxsync
f106b549ead77cab51ff1e2c116060aaabb90d5evboxsync/**
9e4ea89b1085fdaa5861e45a729d9c978db1a8f1vboxsync * Deinitialize and destroy a record created by RTLockValidatorRecExclCreate.
9e4ea89b1085fdaa5861e45a729d9c978db1a8f1vboxsync *
9e4ea89b1085fdaa5861e45a729d9c978db1a8f1vboxsync * @param ppRec Pointer to the record pointer. Will be set to
a9315925c69e4c3bb342bb317ca5b6d29e1ee467vboxsync * NULL.
a9315925c69e4c3bb342bb317ca5b6d29e1ee467vboxsync */
a9315925c69e4c3bb342bb317ca5b6d29e1ee467vboxsyncRTDECL(void) RTLockValidatorRecExclDestroy(PRTLOCKVALRECEXCL *ppRec);
ad9e5a61fea617d40d07390ff1737277d6aef869vboxsync
dbabc9de5bf52ce5eb77cf82b038e9a6166c5a04vboxsync/**
4090390866c02d5d0ad061151cdb298b9a173e86vboxsync * Record the specified thread as lock owner and increment the write lock count.
4090390866c02d5d0ad061151cdb298b9a173e86vboxsync *
40dce69ff1c2949a489337922f30f1021d62d864vboxsync * This function is typically called after acquiring the lock. It accounts for
40dce69ff1c2949a489337922f30f1021d62d864vboxsync * recursions so it can be used instead of RTLockValidatorRecExclRecursion. Use
40dce69ff1c2949a489337922f30f1021d62d864vboxsync * RTLockValidatorRecExclReleaseOwner to reverse the effect.
40dce69ff1c2949a489337922f30f1021d62d864vboxsync *
40dce69ff1c2949a489337922f30f1021d62d864vboxsync * @param pRec The validator record.
7a29aa5ce149ccd344a2929d2815b8e212690b92vboxsync * @param hThreadSelf The handle of the calling thread. If not known,
a1b4fb3917412d2632d358ff8989f1ec971f2d5bvboxsync * pass NIL_RTTHREAD and we'll figure it out.
505ddd00252720bfb5569fcb17bfda53dc141e3bvboxsync * @param pSrcPos The source position of the lock operation.
505ddd00252720bfb5569fcb17bfda53dc141e3bvboxsync * @param fFirstRecursion Set if it is the first recursion, clear if not
a1b4fb3917412d2632d358ff8989f1ec971f2d5bvboxsync * sure.
147e101bcd061b5e085e4a2c0cc9fc35546ff1aavboxsync */
147e101bcd061b5e085e4a2c0cc9fc35546ff1aavboxsyncRTDECL(void) RTLockValidatorRecExclSetOwner(PRTLOCKVALRECEXCL pRec, RTTHREAD hThreadSelf,
3933885bc0c2c93436d858a14564c6179ec72872vboxsync PCRTLOCKVALSRCPOS pSrcPos, bool fFirstRecursion);
3933885bc0c2c93436d858a14564c6179ec72872vboxsync
3933885bc0c2c93436d858a14564c6179ec72872vboxsync/**
3933885bc0c2c93436d858a14564c6179ec72872vboxsync * Check the exit order and release (unset) the ownership.
3933885bc0c2c93436d858a14564c6179ec72872vboxsync *
a1b4fb3917412d2632d358ff8989f1ec971f2d5bvboxsync * This is called by routines implementing releasing an exclusive lock,
a1b4fb3917412d2632d358ff8989f1ec971f2d5bvboxsync * typically before getting down to the final lock releaseing. Can be used for
a1b4fb3917412d2632d358ff8989f1ec971f2d5bvboxsync * recursive releasing instead of RTLockValidatorRecExclUnwind.
a1b4fb3917412d2632d358ff8989f1ec971f2d5bvboxsync *
a1b4fb3917412d2632d358ff8989f1ec971f2d5bvboxsync * @retval VINF_SUCCESS on success.
a1b4fb3917412d2632d358ff8989f1ec971f2d5bvboxsync * @retval VERR_SEM_LV_WRONG_RELEASE_ORDER if the order is wrong. Will have
aa0553becec2abc2e781f839ba1d399c31c2c07fvboxsync * done all necessary whining and breakpointing before returning.
a1b4fb3917412d2632d358ff8989f1ec971f2d5bvboxsync * @retval VERR_SEM_LV_INVALID_PARAMETER if the input is invalid.
a1b4fb3917412d2632d358ff8989f1ec971f2d5bvboxsync *
a1b4fb3917412d2632d358ff8989f1ec971f2d5bvboxsync * @param pRec The validator record.
aa0553becec2abc2e781f839ba1d399c31c2c07fvboxsync * @param fFinalRecursion Set if it's the final recursion, clear if not
a1b4fb3917412d2632d358ff8989f1ec971f2d5bvboxsync * sure.
a1b4fb3917412d2632d358ff8989f1ec971f2d5bvboxsync */
a1b4fb3917412d2632d358ff8989f1ec971f2d5bvboxsyncRTDECL(int) RTLockValidatorRecExclReleaseOwner(PRTLOCKVALRECEXCL pRec, bool fFinalRecursion);
a1b4fb3917412d2632d358ff8989f1ec971f2d5bvboxsync
a1b4fb3917412d2632d358ff8989f1ec971f2d5bvboxsync/**
a1b4fb3917412d2632d358ff8989f1ec971f2d5bvboxsync * Clear the lock ownership and decrement the write lock count.
a1b4fb3917412d2632d358ff8989f1ec971f2d5bvboxsync *
a1b4fb3917412d2632d358ff8989f1ec971f2d5bvboxsync * This is only for special cases where we wish to drop lock validation
a1b4fb3917412d2632d358ff8989f1ec971f2d5bvboxsync * recording. See RTLockValidatorRecExclCheckAndRelease.
a1b4fb3917412d2632d358ff8989f1ec971f2d5bvboxsync *
3933885bc0c2c93436d858a14564c6179ec72872vboxsync * @param pRec The validator record.
71c8a528203c289a8585ce10ac6bafc4274058c6vboxsync */
71c8a528203c289a8585ce10ac6bafc4274058c6vboxsyncRTDECL(void) RTLockValidatorRecExclReleaseOwnerUnchecked(PRTLOCKVALRECEXCL pRec);
147e101bcd061b5e085e4a2c0cc9fc35546ff1aavboxsync
71c8a528203c289a8585ce10ac6bafc4274058c6vboxsync/**
71c8a528203c289a8585ce10ac6bafc4274058c6vboxsync * Checks and records a lock recursion.
2823fbb1428e982169f04923472d7c94e7ed8385vboxsync *
2823fbb1428e982169f04923472d7c94e7ed8385vboxsync * @retval VINF_SUCCESS on success.
147e101bcd061b5e085e4a2c0cc9fc35546ff1aavboxsync * @retval VERR_SEM_LV_NESTED if the semaphore class forbids recursion. Gone
147e101bcd061b5e085e4a2c0cc9fc35546ff1aavboxsync * thru the motions.
71c8a528203c289a8585ce10ac6bafc4274058c6vboxsync * @retval VERR_SEM_LV_WRONG_ORDER if the locking order is wrong. Gone thru
71c8a528203c289a8585ce10ac6bafc4274058c6vboxsync * the motions.
71c8a528203c289a8585ce10ac6bafc4274058c6vboxsync * @retval VERR_SEM_LV_INVALID_PARAMETER if the input is invalid.
71c8a528203c289a8585ce10ac6bafc4274058c6vboxsync *
71c8a528203c289a8585ce10ac6bafc4274058c6vboxsync * @param pRec The validator record.
71c8a528203c289a8585ce10ac6bafc4274058c6vboxsync * @param pSrcPos The source position of the lock operation.
71c8a528203c289a8585ce10ac6bafc4274058c6vboxsync */
508452243fd3328f7b9e0405d39fb9dc004e31b8vboxsyncRTDECL(int) RTLockValidatorRecExclRecursion(PRTLOCKVALRECEXCL pRec, PCRTLOCKVALSRCPOS pSrcPos);
508452243fd3328f7b9e0405d39fb9dc004e31b8vboxsync
71c8a528203c289a8585ce10ac6bafc4274058c6vboxsync/**
89aedeb1d8af54aba6ae46dbbd256281315c1be6vboxsync * Checks and records a lock unwind (releasing one recursion).
89aedeb1d8af54aba6ae46dbbd256281315c1be6vboxsync *
89aedeb1d8af54aba6ae46dbbd256281315c1be6vboxsync * This should be coupled with called to RTLockValidatorRecExclRecursion.
89aedeb1d8af54aba6ae46dbbd256281315c1be6vboxsync *
71c8a528203c289a8585ce10ac6bafc4274058c6vboxsync * @retval VINF_SUCCESS on success.
f409459bdd4c15cdb8d7fb6c6d54338cce9ac814vboxsync * @retval VERR_SEM_LV_WRONG_RELEASE_ORDER if the release order is wrong. Gone
147e101bcd061b5e085e4a2c0cc9fc35546ff1aavboxsync * thru the motions.
147e101bcd061b5e085e4a2c0cc9fc35546ff1aavboxsync * @retval VERR_SEM_LV_INVALID_PARAMETER if the input is invalid.
147e101bcd061b5e085e4a2c0cc9fc35546ff1aavboxsync *
147e101bcd061b5e085e4a2c0cc9fc35546ff1aavboxsync * @param pRec The validator record.
71c8a528203c289a8585ce10ac6bafc4274058c6vboxsync */
1dc37bff2fb26897f5892d8330fe2bc0c9859aecvboxsyncRTDECL(int) RTLockValidatorRecExclUnwind(PRTLOCKVALRECEXCL pRec);
fb1975a6972d89de9e515bed0248db93f04ec9d8vboxsync
147e101bcd061b5e085e4a2c0cc9fc35546ff1aavboxsync/**
147e101bcd061b5e085e4a2c0cc9fc35546ff1aavboxsync * Checks and records a mixed recursion.
2823fbb1428e982169f04923472d7c94e7ed8385vboxsync *
71c8a528203c289a8585ce10ac6bafc4274058c6vboxsync * An example of a mixed recursion is a writer requesting read access to a
147e101bcd061b5e085e4a2c0cc9fc35546ff1aavboxsync * SemRW.
71c8a528203c289a8585ce10ac6bafc4274058c6vboxsync *
9e4ea89b1085fdaa5861e45a729d9c978db1a8f1vboxsync * This should be coupled with called to RTLockValidatorRecExclUnwindMixed.
71c8a528203c289a8585ce10ac6bafc4274058c6vboxsync *
1207f59aa62006952dbb0bf7700decf34d8caeb2vboxsync * @retval VINF_SUCCESS on success.
71c8a528203c289a8585ce10ac6bafc4274058c6vboxsync * @retval VERR_SEM_LV_NESTED if the semaphore class forbids recursion. Gone
71c8a528203c289a8585ce10ac6bafc4274058c6vboxsync * thru the motions.
9e4ea89b1085fdaa5861e45a729d9c978db1a8f1vboxsync * @retval VERR_SEM_LV_WRONG_ORDER if the locking order is wrong. Gone thru
71c8a528203c289a8585ce10ac6bafc4274058c6vboxsync * the motions.
d29ab0cfbeef254251f0a2458163034999abb8a0vboxsync * @retval VERR_SEM_LV_INVALID_PARAMETER if the input is invalid.
1207f59aa62006952dbb0bf7700decf34d8caeb2vboxsync *
1207f59aa62006952dbb0bf7700decf34d8caeb2vboxsync * @param pRec The validator record it to accounted it to.
d29ab0cfbeef254251f0a2458163034999abb8a0vboxsync * @param pRecMixed The validator record it came in on.
147e101bcd061b5e085e4a2c0cc9fc35546ff1aavboxsync * @param pSrcPos The source position of the lock operation.
1207f59aa62006952dbb0bf7700decf34d8caeb2vboxsync */
d29ab0cfbeef254251f0a2458163034999abb8a0vboxsyncRTDECL(int) RTLockValidatorRecExclRecursionMixed(PRTLOCKVALRECEXCL pRec, PRTLOCKVALRECCORE pRecMixed, PCRTLOCKVALSRCPOS pSrcPos);
d29ab0cfbeef254251f0a2458163034999abb8a0vboxsync
d29ab0cfbeef254251f0a2458163034999abb8a0vboxsync/**
e48239695d41f806ff02d8a60b97dc20d4822d7avboxsync * Checks and records the unwinding of a mixed recursion.
d29ab0cfbeef254251f0a2458163034999abb8a0vboxsync *
147e101bcd061b5e085e4a2c0cc9fc35546ff1aavboxsync * This should be coupled with called to RTLockValidatorRecExclRecursionMixed.
147e101bcd061b5e085e4a2c0cc9fc35546ff1aavboxsync *
71c8a528203c289a8585ce10ac6bafc4274058c6vboxsync * @retval VINF_SUCCESS on success.
147e101bcd061b5e085e4a2c0cc9fc35546ff1aavboxsync * @retval VERR_SEM_LV_WRONG_RELEASE_ORDER if the release order is wrong. Gone
9e4ea89b1085fdaa5861e45a729d9c978db1a8f1vboxsync * thru the motions.
71c8a528203c289a8585ce10ac6bafc4274058c6vboxsync * @retval VERR_SEM_LV_INVALID_PARAMETER if the input is invalid.
6efcf94383d6e48c764c6518cf1b4069ad34e210vboxsync *
71c8a528203c289a8585ce10ac6bafc4274058c6vboxsync * @param pRec The validator record it was accounted to.
71c8a528203c289a8585ce10ac6bafc4274058c6vboxsync * @param pRecMixed The validator record it came in on.
147e101bcd061b5e085e4a2c0cc9fc35546ff1aavboxsync */
b304856b23107864c9c594a80cebca6006623f31vboxsyncRTDECL(int) RTLockValidatorRecExclUnwindMixed(PRTLOCKVALRECEXCL pRec, PRTLOCKVALRECCORE pRecMixed);
b304856b23107864c9c594a80cebca6006623f31vboxsync
b304856b23107864c9c594a80cebca6006623f31vboxsync/**
b304856b23107864c9c594a80cebca6006623f31vboxsync * Check the exclusive locking order.
b304856b23107864c9c594a80cebca6006623f31vboxsync *
b304856b23107864c9c594a80cebca6006623f31vboxsync * This is called by routines implementing exclusive lock acquisition.
9e4ea89b1085fdaa5861e45a729d9c978db1a8f1vboxsync *
71c8a528203c289a8585ce10ac6bafc4274058c6vboxsync * @retval VINF_SUCCESS on success.
6efcf94383d6e48c764c6518cf1b4069ad34e210vboxsync * @retval VERR_SEM_LV_WRONG_ORDER if the order is wrong. Will have done all
147e101bcd061b5e085e4a2c0cc9fc35546ff1aavboxsync * necessary whining and breakpointing before returning.
71c8a528203c289a8585ce10ac6bafc4274058c6vboxsync * @retval VERR_SEM_LV_INVALID_PARAMETER if the input is invalid.
147e101bcd061b5e085e4a2c0cc9fc35546ff1aavboxsync *
9e4ea89b1085fdaa5861e45a729d9c978db1a8f1vboxsync * @param pRec The validator record.
71c8a528203c289a8585ce10ac6bafc4274058c6vboxsync * @param hThreadSelf The handle of the calling thread. If not known,
3a0bc95d0adf57baefd303e94b8f1b7b31a8f080vboxsync * pass NIL_RTTHREAD and we'll figure it out.
147e101bcd061b5e085e4a2c0cc9fc35546ff1aavboxsync * @param pSrcPos The source position of the lock operation.
d29ab0cfbeef254251f0a2458163034999abb8a0vboxsync */
d29ab0cfbeef254251f0a2458163034999abb8a0vboxsyncRTDECL(int) RTLockValidatorRecExclCheckOrder(PRTLOCKVALRECEXCL pRec, RTTHREAD hThreadSelf, PCRTLOCKVALSRCPOS pSrcPos);
3a0bc95d0adf57baefd303e94b8f1b7b31a8f080vboxsync
3a0bc95d0adf57baefd303e94b8f1b7b31a8f080vboxsync/**
3a0bc95d0adf57baefd303e94b8f1b7b31a8f080vboxsync * Do deadlock detection before blocking on exclusive access to a lock and
3a0bc95d0adf57baefd303e94b8f1b7b31a8f080vboxsync * change the thread state.
21ddd8aa21b8d7ad25b18ab341ede34c1cb4a125vboxsync *
21ddd8aa21b8d7ad25b18ab341ede34c1cb4a125vboxsync * @retval VINF_SUCCESS - thread is in the specified sleep state.
21ddd8aa21b8d7ad25b18ab341ede34c1cb4a125vboxsync * @retval VERR_SEM_LV_DEADLOCK if blocking would deadlock. Gone thru the
21ddd8aa21b8d7ad25b18ab341ede34c1cb4a125vboxsync * motions.
21ddd8aa21b8d7ad25b18ab341ede34c1cb4a125vboxsync * @retval VERR_SEM_LV_NESTED if the semaphore isn't recursive and hThread is
21ddd8aa21b8d7ad25b18ab341ede34c1cb4a125vboxsync * already the owner. Gone thru the motions.
21ddd8aa21b8d7ad25b18ab341ede34c1cb4a125vboxsync * @retval VERR_SEM_LV_ILLEGAL_UPGRADE if it's a deadlock on the same lock.
21ddd8aa21b8d7ad25b18ab341ede34c1cb4a125vboxsync * The caller must handle any legal upgrades without invoking this
d29ab0cfbeef254251f0a2458163034999abb8a0vboxsync * function (for now).
d29ab0cfbeef254251f0a2458163034999abb8a0vboxsync * @retval VERR_SEM_LV_INVALID_PARAMETER if the input is invalid.
d29ab0cfbeef254251f0a2458163034999abb8a0vboxsync *
d29ab0cfbeef254251f0a2458163034999abb8a0vboxsync * @param pRec The validator record we're blocking on.
d29ab0cfbeef254251f0a2458163034999abb8a0vboxsync * @param hThreadSelf The current thread. Shall not be NIL_RTTHREAD!
d29ab0cfbeef254251f0a2458163034999abb8a0vboxsync * @param pSrcPos The source position of the lock operation.
d29ab0cfbeef254251f0a2458163034999abb8a0vboxsync * @param fRecursiveOk Whether it's ok to recurse.
d29ab0cfbeef254251f0a2458163034999abb8a0vboxsync * @param enmSleepState The sleep state to enter on successful return.
147e101bcd061b5e085e4a2c0cc9fc35546ff1aavboxsync */
147e101bcd061b5e085e4a2c0cc9fc35546ff1aavboxsyncRTDECL(int) RTLockValidatorRecExclCheckBlocking(PRTLOCKVALRECEXCL pRec, RTTHREAD hThreadSelf,
71c8a528203c289a8585ce10ac6bafc4274058c6vboxsync PCRTLOCKVALSRCPOS pSrcPos, bool fRecursiveOk,
147e101bcd061b5e085e4a2c0cc9fc35546ff1aavboxsync RTTHREADSTATE enmSleepState);
9e4ea89b1085fdaa5861e45a729d9c978db1a8f1vboxsync
71c8a528203c289a8585ce10ac6bafc4274058c6vboxsync/**
261b44f7fa60a1d4bb4102142d3aa44188908484vboxsync * RTLockValidatorRecExclCheckOrder and RTLockValidatorRecExclCheckBlocking
71c8a528203c289a8585ce10ac6bafc4274058c6vboxsync * baked into one call.
71c8a528203c289a8585ce10ac6bafc4274058c6vboxsync *
147e101bcd061b5e085e4a2c0cc9fc35546ff1aavboxsync * @returns Any of the statuses returned by the two APIs.
9e4ea89b1085fdaa5861e45a729d9c978db1a8f1vboxsync * @param pRec The validator record.
71c8a528203c289a8585ce10ac6bafc4274058c6vboxsync * @param hThreadSelf The current thread. Shall not be NIL_RTTHREAD!
261b44f7fa60a1d4bb4102142d3aa44188908484vboxsync * @param pSrcPos The source position of the lock operation.
147e101bcd061b5e085e4a2c0cc9fc35546ff1aavboxsync * @param fRecursiveOk Whether it's ok to recurse.
71c8a528203c289a8585ce10ac6bafc4274058c6vboxsync * @param enmSleepState The sleep state to enter on successful return.
147e101bcd061b5e085e4a2c0cc9fc35546ff1aavboxsync */
9e4ea89b1085fdaa5861e45a729d9c978db1a8f1vboxsyncRTDECL(int) RTLockValidatorRecExclCheckOrderAndBlocking(PRTLOCKVALRECEXCL pRec, RTTHREAD hThreadSelf,
71c8a528203c289a8585ce10ac6bafc4274058c6vboxsync PCRTLOCKVALSRCPOS pSrcPos, bool fRecursiveOk,
f31ac84c1c57e23801423b5bd184fadabe6456f3vboxsync RTTHREADSTATE enmSleepState);
71c8a528203c289a8585ce10ac6bafc4274058c6vboxsync
71c8a528203c289a8585ce10ac6bafc4274058c6vboxsync/**
147e101bcd061b5e085e4a2c0cc9fc35546ff1aavboxsync * Initialize a lock validator record for a shared lock.
9e4ea89b1085fdaa5861e45a729d9c978db1a8f1vboxsync *
36929067a9d3cba77fd78f1e8fa042ed3a8ae2d6vboxsync * Use RTLockValidatorRecSharedDelete to deinitialize it.
f31ac84c1c57e23801423b5bd184fadabe6456f3vboxsync *
36929067a9d3cba77fd78f1e8fa042ed3a8ae2d6vboxsync * @param pRec The shared lock record.
36929067a9d3cba77fd78f1e8fa042ed3a8ae2d6vboxsync * @param hClass The class. If NIL, the no lock order
36929067a9d3cba77fd78f1e8fa042ed3a8ae2d6vboxsync * validation will be performed on this lock.
9e4ea89b1085fdaa5861e45a729d9c978db1a8f1vboxsync * @param uSubClass The sub-class. This is used to define lock
71c8a528203c289a8585ce10ac6bafc4274058c6vboxsync * order inside the same class. If you don't know,
261b44f7fa60a1d4bb4102142d3aa44188908484vboxsync * then pass RTLOCKVALIDATOR_SUB_CLASS_NONE.
ab2292e9c32bd271ec91123ef38699a0284b72cbvboxsync * @param pszName The lock name (optional).
ab2292e9c32bd271ec91123ef38699a0284b72cbvboxsync * @param hLock The lock handle.
ab2292e9c32bd271ec91123ef38699a0284b72cbvboxsync */
9e4ea89b1085fdaa5861e45a729d9c978db1a8f1vboxsyncRTDECL(void) RTLockValidatorRecSharedInit(PRTLOCKVALRECSHRD pRec, RTLOCKVALIDATORCLASS hClass,
ab2292e9c32bd271ec91123ef38699a0284b72cbvboxsync uint32_t uSubClass, const char *pszName, void *hLock);
261b44f7fa60a1d4bb4102142d3aa44188908484vboxsync/**
71c8a528203c289a8585ce10ac6bafc4274058c6vboxsync * Uninitialize a lock validator record previously initialized by
71c8a528203c289a8585ce10ac6bafc4274058c6vboxsync * RTLockValidatorRecSharedInit.
147e101bcd061b5e085e4a2c0cc9fc35546ff1aavboxsync *
db0ecde8f28fdb4525bc6d94056166c70b02ebb8vboxsync * @param pRec The shared lock record. Must be valid.
121568d0a1e932e6f6acd49376827a0e593815favboxsync */
121568d0a1e932e6f6acd49376827a0e593815favboxsyncRTDECL(void) RTLockValidatorRecSharedDelete(PRTLOCKVALRECSHRD pRec);
121568d0a1e932e6f6acd49376827a0e593815favboxsync
121568d0a1e932e6f6acd49376827a0e593815favboxsync/**
121568d0a1e932e6f6acd49376827a0e593815favboxsync * Check the shared locking order.
121568d0a1e932e6f6acd49376827a0e593815favboxsync *
121568d0a1e932e6f6acd49376827a0e593815favboxsync * This is called by routines implementing shared lock acquisition.
121568d0a1e932e6f6acd49376827a0e593815favboxsync *
121568d0a1e932e6f6acd49376827a0e593815favboxsync * @retval VINF_SUCCESS on success.
121568d0a1e932e6f6acd49376827a0e593815favboxsync * @retval VERR_SEM_LV_WRONG_ORDER if the order is wrong. Will have done all
121568d0a1e932e6f6acd49376827a0e593815favboxsync * necessary whining and breakpointing before returning.
121568d0a1e932e6f6acd49376827a0e593815favboxsync * @retval VERR_SEM_LV_INVALID_PARAMETER if the input is invalid.
121568d0a1e932e6f6acd49376827a0e593815favboxsync *
f31ac84c1c57e23801423b5bd184fadabe6456f3vboxsync * @param pRec The validator record.
121568d0a1e932e6f6acd49376827a0e593815favboxsync * @param hThreadSelf The handle of the calling thread. If not known,
121568d0a1e932e6f6acd49376827a0e593815favboxsync * pass NIL_RTTHREAD and we'll figure it out.
121568d0a1e932e6f6acd49376827a0e593815favboxsync * @param pSrcPos The source position of the lock operation.
db0ecde8f28fdb4525bc6d94056166c70b02ebb8vboxsync */
db0ecde8f28fdb4525bc6d94056166c70b02ebb8vboxsyncRTDECL(int) RTLockValidatorRecSharedCheckOrder(PRTLOCKVALRECSHRD pRec, RTTHREAD hThreadSelf, PCRTLOCKVALSRCPOS pSrcPos);
f31ac84c1c57e23801423b5bd184fadabe6456f3vboxsync
db0ecde8f28fdb4525bc6d94056166c70b02ebb8vboxsync/**
db0ecde8f28fdb4525bc6d94056166c70b02ebb8vboxsync * Do deadlock detection before blocking on shared access to a lock and change
db0ecde8f28fdb4525bc6d94056166c70b02ebb8vboxsync * the thread state.
db0ecde8f28fdb4525bc6d94056166c70b02ebb8vboxsync *
db0ecde8f28fdb4525bc6d94056166c70b02ebb8vboxsync * @retval VINF_SUCCESS - thread is in the specified sleep state.
f31ac84c1c57e23801423b5bd184fadabe6456f3vboxsync * @retval VERR_SEM_LV_DEADLOCK if blocking would deadlock. Gone thru the
db0ecde8f28fdb4525bc6d94056166c70b02ebb8vboxsync * motions.
db0ecde8f28fdb4525bc6d94056166c70b02ebb8vboxsync * @retval VERR_SEM_LV_NESTED if the semaphore isn't recursive and hThread is
db0ecde8f28fdb4525bc6d94056166c70b02ebb8vboxsync * already the owner. Gone thru the motions.
9e4ea89b1085fdaa5861e45a729d9c978db1a8f1vboxsync * @retval VERR_SEM_LV_ILLEGAL_UPGRADE if it's a deadlock on the same lock.
71c8a528203c289a8585ce10ac6bafc4274058c6vboxsync * The caller must handle any legal upgrades without invoking this
261b44f7fa60a1d4bb4102142d3aa44188908484vboxsync * function (for now).
71c8a528203c289a8585ce10ac6bafc4274058c6vboxsync * @retval VERR_SEM_LV_INVALID_PARAMETER if the input is invalid.
71c8a528203c289a8585ce10ac6bafc4274058c6vboxsync *
147e101bcd061b5e085e4a2c0cc9fc35546ff1aavboxsync * @param pRec The validator record we're blocking on.
c33fc49611f2444dade533488bf431e29eb88bcdvboxsync * @param hThreadSelf The current thread. Shall not be NIL_RTTHREAD!
c33fc49611f2444dade533488bf431e29eb88bcdvboxsync * @param pSrcPos The source position of the lock operation.
c33fc49611f2444dade533488bf431e29eb88bcdvboxsync * @param fRecursiveOk Whether it's ok to recurse.
c33fc49611f2444dade533488bf431e29eb88bcdvboxsync * @param enmSleepState The sleep state to enter on successful return.
c33fc49611f2444dade533488bf431e29eb88bcdvboxsync */
c33fc49611f2444dade533488bf431e29eb88bcdvboxsyncRTDECL(int) RTLockValidatorRecSharedCheckBlocking(PRTLOCKVALRECSHRD pRec, RTTHREAD hThreadSelf,
9e4ea89b1085fdaa5861e45a729d9c978db1a8f1vboxsync PCRTLOCKVALSRCPOS pSrcPos, bool fRecursiveOk,
71c8a528203c289a8585ce10ac6bafc4274058c6vboxsync RTTHREADSTATE enmSleepState);
261b44f7fa60a1d4bb4102142d3aa44188908484vboxsync
71c8a528203c289a8585ce10ac6bafc4274058c6vboxsync/**
71c8a528203c289a8585ce10ac6bafc4274058c6vboxsync * RTLockValidatorRecSharedCheckOrder and RTLockValidatorRecSharedCheckBlocking
147e101bcd061b5e085e4a2c0cc9fc35546ff1aavboxsync * baked into one call.
9e4ea89b1085fdaa5861e45a729d9c978db1a8f1vboxsync *
71c8a528203c289a8585ce10ac6bafc4274058c6vboxsync * @returns Any of the statuses returned by the two APIs.
6efcf94383d6e48c764c6518cf1b4069ad34e210vboxsync * @param pRec The validator record.
71c8a528203c289a8585ce10ac6bafc4274058c6vboxsync * @param hThreadSelf The current thread. Shall not be NIL_RTTHREAD!
71c8a528203c289a8585ce10ac6bafc4274058c6vboxsync * @param pSrcPos The source position of the lock operation.
147e101bcd061b5e085e4a2c0cc9fc35546ff1aavboxsync * @param fRecursiveOk Whether it's ok to recurse.
e2760cdc84c692bc46cfaf5018d313db2f122acavboxsync */
e2760cdc84c692bc46cfaf5018d313db2f122acavboxsyncRTDECL(int) RTLockValidatorRecSharedCheckOrderAndBlocking(PRTLOCKVALRECSHRD pRec, RTTHREAD hThreadSelf,
e2760cdc84c692bc46cfaf5018d313db2f122acavboxsync PCRTLOCKVALSRCPOS pSrcPos, bool fRecursiveOk,
e2760cdc84c692bc46cfaf5018d313db2f122acavboxsync RTTHREADSTATE enmSleepState);
e2760cdc84c692bc46cfaf5018d313db2f122acavboxsync
e2760cdc84c692bc46cfaf5018d313db2f122acavboxsync/**
6e12ccc60ac657fb87e27b7a2b26e0a63bebe024vboxsync * Adds an owner to a shared locking record.
6e12ccc60ac657fb87e27b7a2b26e0a63bebe024vboxsync *
6e12ccc60ac657fb87e27b7a2b26e0a63bebe024vboxsync * Takes recursion into account. This function is typically called after
6e12ccc60ac657fb87e27b7a2b26e0a63bebe024vboxsync * acquiring the lock in shared mode.
6e12ccc60ac657fb87e27b7a2b26e0a63bebe024vboxsync *
6e12ccc60ac657fb87e27b7a2b26e0a63bebe024vboxsync * @param pRead The validator record.
6e12ccc60ac657fb87e27b7a2b26e0a63bebe024vboxsync * @param hThreadSelf The calling thread and owner.
6e12ccc60ac657fb87e27b7a2b26e0a63bebe024vboxsync * @param pSrcPos The source position of the lock operation.
6e12ccc60ac657fb87e27b7a2b26e0a63bebe024vboxsync */
6e12ccc60ac657fb87e27b7a2b26e0a63bebe024vboxsyncRTDECL(void) RTLockValidatorSharedRecAddOwner(PRTLOCKVALRECSHRD pRec, RTTHREAD hThreadSelf, PCRTLOCKVALSRCPOS pSrcPos);
6e12ccc60ac657fb87e27b7a2b26e0a63bebe024vboxsync
6e12ccc60ac657fb87e27b7a2b26e0a63bebe024vboxsync/**
6e12ccc60ac657fb87e27b7a2b26e0a63bebe024vboxsync * Removes an owner from a shared locking record.
6e12ccc60ac657fb87e27b7a2b26e0a63bebe024vboxsync *
6e12ccc60ac657fb87e27b7a2b26e0a63bebe024vboxsync * Takes recursion into account. This function is typically called before
6e12ccc60ac657fb87e27b7a2b26e0a63bebe024vboxsync * releaseing the lock.
6e12ccc60ac657fb87e27b7a2b26e0a63bebe024vboxsync *
6e12ccc60ac657fb87e27b7a2b26e0a63bebe024vboxsync * @param pRec The validator record.
657b2c9f6d33f08001e5fa6f6e0572dcf0391013vboxsync * @param hThreadSelf The calling thread and the owner to remove.
657b2c9f6d33f08001e5fa6f6e0572dcf0391013vboxsync */
657b2c9f6d33f08001e5fa6f6e0572dcf0391013vboxsyncRTDECL(void) RTLockValidatorSharedRecRemoveOwner(PRTLOCKVALRECSHRD pRec, RTTHREAD hThreadSelf);
d6f9950e2cf4ba7fd217c083400d9812ff745374vboxsync
657b2c9f6d33f08001e5fa6f6e0572dcf0391013vboxsync/**
657b2c9f6d33f08001e5fa6f6e0572dcf0391013vboxsync * Check the exit order and release (unset) the shared ownership.
9e4ea89b1085fdaa5861e45a729d9c978db1a8f1vboxsync *
49e54e2ffe0c10864d06e9d1ebe24a8eb1327a6bvboxsync * This is called by routines implementing releasing the read/write lock.
6efcf94383d6e48c764c6518cf1b4069ad34e210vboxsync *
147e101bcd061b5e085e4a2c0cc9fc35546ff1aavboxsync * @retval VINF_SUCCESS on success.
49e54e2ffe0c10864d06e9d1ebe24a8eb1327a6bvboxsync * @retval VERR_SEM_LV_WRONG_RELEASE_ORDER if the order is wrong. Will have
147e101bcd061b5e085e4a2c0cc9fc35546ff1aavboxsync * done all necessary whining and breakpointing before returning.
9e4ea89b1085fdaa5861e45a729d9c978db1a8f1vboxsync * @retval VERR_SEM_LV_INVALID_PARAMETER if the input is invalid.
49e54e2ffe0c10864d06e9d1ebe24a8eb1327a6bvboxsync *
261b44f7fa60a1d4bb4102142d3aa44188908484vboxsync * @param pRead The validator record.
147e101bcd061b5e085e4a2c0cc9fc35546ff1aavboxsync * @param hThreadSelf The handle of the calling thread. If not known,
49e54e2ffe0c10864d06e9d1ebe24a8eb1327a6bvboxsync * pass NIL_RTTHREAD and we'll figure it out.
147e101bcd061b5e085e4a2c0cc9fc35546ff1aavboxsync */
d29ab0cfbeef254251f0a2458163034999abb8a0vboxsyncRTDECL(int) RTLockValidatorRecSharedCheckAndRelease(PRTLOCKVALRECSHRD pRec, RTTHREAD hThreadSelf);
9e4ea89b1085fdaa5861e45a729d9c978db1a8f1vboxsync
49e54e2ffe0c10864d06e9d1ebe24a8eb1327a6bvboxsync/**
261b44f7fa60a1d4bb4102142d3aa44188908484vboxsync * Gets the number of write locks and critical sections the specified
49e54e2ffe0c10864d06e9d1ebe24a8eb1327a6bvboxsync * thread owns.
49e54e2ffe0c10864d06e9d1ebe24a8eb1327a6bvboxsync *
d29ab0cfbeef254251f0a2458163034999abb8a0vboxsync * This number does not include any nested lock/critect entries.
147e101bcd061b5e085e4a2c0cc9fc35546ff1aavboxsync *
9e4ea89b1085fdaa5861e45a729d9c978db1a8f1vboxsync * Note that it probably will return 0 for non-strict builds since
91f8453d16b48876deddaba298c211071d0ca3a5vboxsync * release builds doesn't do unnecessary diagnostic counting like this.
261b44f7fa60a1d4bb4102142d3aa44188908484vboxsync *
147e101bcd061b5e085e4a2c0cc9fc35546ff1aavboxsync * @returns Number of locks on success (0+) and VERR_INVALID_HANDLER on failure
91f8453d16b48876deddaba298c211071d0ca3a5vboxsync * @param Thread The thread we're inquiring about.
147e101bcd061b5e085e4a2c0cc9fc35546ff1aavboxsync * @remarks Will only work for strict builds.
9e4ea89b1085fdaa5861e45a729d9c978db1a8f1vboxsync */
91f8453d16b48876deddaba298c211071d0ca3a5vboxsyncRTDECL(int32_t) RTLockValidatorWriteLockGetCount(RTTHREAD Thread);
261b44f7fa60a1d4bb4102142d3aa44188908484vboxsync
147e101bcd061b5e085e4a2c0cc9fc35546ff1aavboxsync/**
91f8453d16b48876deddaba298c211071d0ca3a5vboxsync * Works the THREADINT::cWriteLocks member, mostly internal.
147e101bcd061b5e085e4a2c0cc9fc35546ff1aavboxsync *
9e4ea89b1085fdaa5861e45a729d9c978db1a8f1vboxsync * @param Thread The current thread.
91f8453d16b48876deddaba298c211071d0ca3a5vboxsync */
fc5f879e9508f333e20b37c63db9189a33059308vboxsyncRTDECL(void) RTLockValidatorWriteLockInc(RTTHREAD Thread);
91f8453d16b48876deddaba298c211071d0ca3a5vboxsync
91f8453d16b48876deddaba298c211071d0ca3a5vboxsync/**
147e101bcd061b5e085e4a2c0cc9fc35546ff1aavboxsync * Works the THREADINT::cWriteLocks member, mostly internal.
9e4ea89b1085fdaa5861e45a729d9c978db1a8f1vboxsync *
71c8a528203c289a8585ce10ac6bafc4274058c6vboxsync * @param Thread The current thread.
1207f59aa62006952dbb0bf7700decf34d8caeb2vboxsync */
147e101bcd061b5e085e4a2c0cc9fc35546ff1aavboxsyncRTDECL(void) RTLockValidatorWriteLockDec(RTTHREAD Thread);
71c8a528203c289a8585ce10ac6bafc4274058c6vboxsync
147e101bcd061b5e085e4a2c0cc9fc35546ff1aavboxsync/**
9e4ea89b1085fdaa5861e45a729d9c978db1a8f1vboxsync * Gets the number of read locks the specified thread owns.
71c8a528203c289a8585ce10ac6bafc4274058c6vboxsync *
d29ab0cfbeef254251f0a2458163034999abb8a0vboxsync * Note that nesting read lock entry will be included in the
147e101bcd061b5e085e4a2c0cc9fc35546ff1aavboxsync * total sum. And that it probably will return 0 for non-strict
d29ab0cfbeef254251f0a2458163034999abb8a0vboxsync * builds since release builds doesn't do unnecessary diagnostic
d29ab0cfbeef254251f0a2458163034999abb8a0vboxsync * counting like this.
d29ab0cfbeef254251f0a2458163034999abb8a0vboxsync *
d29ab0cfbeef254251f0a2458163034999abb8a0vboxsync * @returns Number of read locks on success (0+) and VERR_INVALID_HANDLER on failure
d29ab0cfbeef254251f0a2458163034999abb8a0vboxsync * @param Thread The thread we're inquiring about.
d29ab0cfbeef254251f0a2458163034999abb8a0vboxsync */
d29ab0cfbeef254251f0a2458163034999abb8a0vboxsyncRTDECL(int32_t) RTLockValidatorReadLockGetCount(RTTHREAD Thread);
d29ab0cfbeef254251f0a2458163034999abb8a0vboxsync
d29ab0cfbeef254251f0a2458163034999abb8a0vboxsync/**
d29ab0cfbeef254251f0a2458163034999abb8a0vboxsync * Works the THREADINT::cReadLocks member.
d29ab0cfbeef254251f0a2458163034999abb8a0vboxsync *
d29ab0cfbeef254251f0a2458163034999abb8a0vboxsync * @param Thread The current thread.
d29ab0cfbeef254251f0a2458163034999abb8a0vboxsync */
d29ab0cfbeef254251f0a2458163034999abb8a0vboxsyncRTDECL(void) RTLockValidatorReadLockInc(RTTHREAD Thread);
147e101bcd061b5e085e4a2c0cc9fc35546ff1aavboxsync
147e101bcd061b5e085e4a2c0cc9fc35546ff1aavboxsync/**
71c8a528203c289a8585ce10ac6bafc4274058c6vboxsync * Works the THREADINT::cReadLocks member.
147e101bcd061b5e085e4a2c0cc9fc35546ff1aavboxsync *
9e4ea89b1085fdaa5861e45a729d9c978db1a8f1vboxsync * @param Thread The current thread.
71c8a528203c289a8585ce10ac6bafc4274058c6vboxsync */
1c6ec9a3a329da6f61978a372e509cd233f0d9f9vboxsyncRTDECL(void) RTLockValidatorReadLockDec(RTTHREAD Thread);
71c8a528203c289a8585ce10ac6bafc4274058c6vboxsync
71c8a528203c289a8585ce10ac6bafc4274058c6vboxsync/**
147e101bcd061b5e085e4a2c0cc9fc35546ff1aavboxsync * Query which lock the specified thread is waiting on.
9e4ea89b1085fdaa5861e45a729d9c978db1a8f1vboxsync *
71c8a528203c289a8585ce10ac6bafc4274058c6vboxsync * @returns The lock handle value or NULL.
261b44f7fa60a1d4bb4102142d3aa44188908484vboxsync * @param hThread The thread in question.
147e101bcd061b5e085e4a2c0cc9fc35546ff1aavboxsync */
71c8a528203c289a8585ce10ac6bafc4274058c6vboxsyncRTDECL(void *) RTLockValidatorQueryBlocking(RTTHREAD hThread);
147e101bcd061b5e085e4a2c0cc9fc35546ff1aavboxsync
9e4ea89b1085fdaa5861e45a729d9c978db1a8f1vboxsync
71c8a528203c289a8585ce10ac6bafc4274058c6vboxsync
2823fbb1428e982169f04923472d7c94e7ed8385vboxsync/*RTDECL(int) RTLockValidatorClassCreate();*/
147e101bcd061b5e085e4a2c0cc9fc35546ff1aavboxsync
1dc37bff2fb26897f5892d8330fe2bc0c9859aecvboxsync
147e101bcd061b5e085e4a2c0cc9fc35546ff1aavboxsync
2823fbb1428e982169f04923472d7c94e7ed8385vboxsync/**
147e101bcd061b5e085e4a2c0cc9fc35546ff1aavboxsync * Enables / disables the lock validator for new locks.
1dc37bff2fb26897f5892d8330fe2bc0c9859aecvboxsync *
147e101bcd061b5e085e4a2c0cc9fc35546ff1aavboxsync * @returns The old setting.
2823fbb1428e982169f04923472d7c94e7ed8385vboxsync * @param fEnabled The new setting.
147e101bcd061b5e085e4a2c0cc9fc35546ff1aavboxsync */
1dc37bff2fb26897f5892d8330fe2bc0c9859aecvboxsyncRTDECL(bool) RTLockValidatorSetEnabled(bool fEnabled);
147e101bcd061b5e085e4a2c0cc9fc35546ff1aavboxsync
2823fbb1428e982169f04923472d7c94e7ed8385vboxsync/**
147e101bcd061b5e085e4a2c0cc9fc35546ff1aavboxsync * Is the lock validator enabled?
1dc37bff2fb26897f5892d8330fe2bc0c9859aecvboxsync *
147e101bcd061b5e085e4a2c0cc9fc35546ff1aavboxsync * @returns True if enabled, false if not.
2823fbb1428e982169f04923472d7c94e7ed8385vboxsync */
147e101bcd061b5e085e4a2c0cc9fc35546ff1aavboxsyncRTDECL(bool) RTLockValidatorIsEnabled(void);
1dc37bff2fb26897f5892d8330fe2bc0c9859aecvboxsync
147e101bcd061b5e085e4a2c0cc9fc35546ff1aavboxsync/**
147e101bcd061b5e085e4a2c0cc9fc35546ff1aavboxsync * Controls whether the lock validator should be quiet or noisy (default).
2823fbb1428e982169f04923472d7c94e7ed8385vboxsync *
147e101bcd061b5e085e4a2c0cc9fc35546ff1aavboxsync * @returns The old setting.
71c8a528203c289a8585ce10ac6bafc4274058c6vboxsync * @param fQuiet The new setting.
147e101bcd061b5e085e4a2c0cc9fc35546ff1aavboxsync */
2a5e5a032e6f23f8937718e4ee4d6979188bdd19vboxsyncRTDECL(bool) RTLockValidatorSetQuiet(bool fQuiet);
2a5e5a032e6f23f8937718e4ee4d6979188bdd19vboxsync
4a0e2f51aaf27c0bca61ff0f1adb91106264f0dbvboxsync/**
4a0e2f51aaf27c0bca61ff0f1adb91106264f0dbvboxsync * Is the lock validator quiet or noisy?
147e101bcd061b5e085e4a2c0cc9fc35546ff1aavboxsync *
7922c4cd397713a387c9e854e74c31a0d5065365vboxsync * @returns True if it is quiet, false if noisy.
4a0e2f51aaf27c0bca61ff0f1adb91106264f0dbvboxsync */
4a0e2f51aaf27c0bca61ff0f1adb91106264f0dbvboxsyncRTDECL(bool) RTLockValidatorAreQuiet(void);
4a0e2f51aaf27c0bca61ff0f1adb91106264f0dbvboxsync
147e101bcd061b5e085e4a2c0cc9fc35546ff1aavboxsync/**
4a0e2f51aaf27c0bca61ff0f1adb91106264f0dbvboxsync * Makes the lock validator panic (default) or not.
4a0e2f51aaf27c0bca61ff0f1adb91106264f0dbvboxsync *
4a0e2f51aaf27c0bca61ff0f1adb91106264f0dbvboxsync * @returns The old setting.
4a0e2f51aaf27c0bca61ff0f1adb91106264f0dbvboxsync * @param fPanic The new setting.
4a0e2f51aaf27c0bca61ff0f1adb91106264f0dbvboxsync */
4a0e2f51aaf27c0bca61ff0f1adb91106264f0dbvboxsyncRTDECL(bool) RTLockValidatorSetMayPanic(bool fPanic);
4a0e2f51aaf27c0bca61ff0f1adb91106264f0dbvboxsync
4a0e2f51aaf27c0bca61ff0f1adb91106264f0dbvboxsync/**
4a0e2f51aaf27c0bca61ff0f1adb91106264f0dbvboxsync * Can the lock validator cause panic.
4a0e2f51aaf27c0bca61ff0f1adb91106264f0dbvboxsync *
4a0e2f51aaf27c0bca61ff0f1adb91106264f0dbvboxsync * @returns True if it can, false if not.
4a0e2f51aaf27c0bca61ff0f1adb91106264f0dbvboxsync */
4a0e2f51aaf27c0bca61ff0f1adb91106264f0dbvboxsyncRTDECL(bool) RTLockValidatorMayPanic(void);
4a0e2f51aaf27c0bca61ff0f1adb91106264f0dbvboxsync
4a0e2f51aaf27c0bca61ff0f1adb91106264f0dbvboxsync
4a0e2f51aaf27c0bca61ff0f1adb91106264f0dbvboxsyncRT_C_DECLS_END
4a0e2f51aaf27c0bca61ff0f1adb91106264f0dbvboxsync
4a0e2f51aaf27c0bca61ff0f1adb91106264f0dbvboxsync/** @} */
147e101bcd061b5e085e4a2c0cc9fc35546ff1aavboxsync
71c8a528203c289a8585ce10ac6bafc4274058c6vboxsync#endif
2823fbb1428e982169f04923472d7c94e7ed8385vboxsync
147e101bcd061b5e085e4a2c0cc9fc35546ff1aavboxsync
1207f59aa62006952dbb0bf7700decf34d8caeb2vboxsync