lockvalidator.h revision 3e9c5c3e44de15c28695c7b570bc2551639187e3
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync/** @file
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync * IPRT - Lock Validator.
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync */
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync
2f0d866e126dd288169fed591c259c1c6b4016e5vboxsync/*
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync * Copyright (C) 2009 Sun Microsystems, Inc.
b2bc8de1367ae24e1b27b53921d0b32ee3df7acdvboxsync *
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync * This file is part of VirtualBox Open Source Edition (OSE), as
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync * available from http://www.virtualbox.org. This file is free software;
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync * you can redistribute it and/or modify it under the terms of the GNU
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync * General Public License (GPL) as published by the Free Software
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync * Foundation, in version 2 as it comes in the "COPYING" file of the
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync *
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync * The contents of this file may alternatively be used under the terms
2f0d866e126dd288169fed591c259c1c6b4016e5vboxsync * of the Common Development and Distribution License Version 1.0
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync * VirtualBox OSE distribution, in which case the provisions of the
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync * CDDL are applicable instead of those of the GPL.
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync *
43747b1f0bc8302a238fb35e55857a5e9aa1933dvboxsync * You may elect to license modified versions of this file under the
43747b1f0bc8302a238fb35e55857a5e9aa1933dvboxsync * terms and conditions of either the GPL or the CDDL or both.
b2bc8de1367ae24e1b27b53921d0b32ee3df7acdvboxsync *
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
2f0d866e126dd288169fed591c259c1c6b4016e5vboxsync * Clara, CA 95054 USA or visit http://www.sun.com if you need
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync * additional information or have any questions.
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync */
f5e53763b0a581b0299e98028c6c52192eb06785vboxsync
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync#ifndef ___iprt_lockvalidator_h
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync#define ___iprt_lockvalidator_h
2f0d866e126dd288169fed591c259c1c6b4016e5vboxsync
2f0d866e126dd288169fed591c259c1c6b4016e5vboxsync#include <iprt/cdefs.h>
2f0d866e126dd288169fed591c259c1c6b4016e5vboxsync#include <iprt/types.h>
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync#include <iprt/assert.h>
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync#include <iprt/thread.h>
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync#include <iprt/stdarg.h>
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync
9b7ab382b3f9667e8847020e1e58f7143c4d2334vboxsync/** @defgroup grp_rtlockval RTLockValidator - Lock Validator
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync * @ingroup grp_rt
8742e4a4ddb7b62d21d96d56dd1baf01c9f22cecvboxsync * @{
8742e4a4ddb7b62d21d96d56dd1baf01c9f22cecvboxsync */
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsyncRT_C_DECLS_BEGIN
8742e4a4ddb7b62d21d96d56dd1baf01c9f22cecvboxsync
8742e4a4ddb7b62d21d96d56dd1baf01c9f22cecvboxsync/** Pointer to a record union.
8742e4a4ddb7b62d21d96d56dd1baf01c9f22cecvboxsync * @internal */
fe554d9c0e3a6de4ba221610ac95a44c7d288e01vboxsynctypedef union RTLOCKVALRECUNION *PRTLOCKVALRECUNION;
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync
63787aca0a2a16ec959a5294148726ccf898ddf1vboxsync/**
63787aca0a2a16ec959a5294148726ccf898ddf1vboxsync * Source position.
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync */
63787aca0a2a16ec959a5294148726ccf898ddf1vboxsynctypedef struct RTLOCKVALSRCPOS
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync{
63787aca0a2a16ec959a5294148726ccf898ddf1vboxsync /** The file where the lock was taken. */
63787aca0a2a16ec959a5294148726ccf898ddf1vboxsync R3R0PTRTYPE(const char * volatile) pszFile;
fe554d9c0e3a6de4ba221610ac95a44c7d288e01vboxsync /** The function where the lock was taken. */
b2bc8de1367ae24e1b27b53921d0b32ee3df7acdvboxsync R3R0PTRTYPE(const char * volatile) pszFunction;
fe554d9c0e3a6de4ba221610ac95a44c7d288e01vboxsync /** Some ID indicating where the lock was taken, typically an address. */
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync RTHCUINTPTR volatile uId;
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync /** The line number in the file. */
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync uint32_t volatile uLine;
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync#if HC_ARCH_BITS == 64
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync uint32_t u32Padding; /**< Alignment padding. */
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync#endif
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync} RTLOCKVALSRCPOS;
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsyncAssertCompileSize(RTLOCKVALSRCPOS, HC_ARCH_BITS == 32 ? 16 : 32);
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync/* The pointer types are defined in iprt/types.h. */
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync/** @def RTLOCKVALSRCPOS_INIT
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync * Initializer for a RTLOCKVALSRCPOS variable.
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync *
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync * @param pszFile The file name. Optional (NULL).
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync * @param uLine The line number in that file. Optional (0).
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync * @param pszFunction The function. Optional (NULL).
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync * @param uId Some location ID, normally the return address.
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync * Optional (NULL).
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync */
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync#if HC_ARCH_BITS == 64
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync# define RTLOCKVALSRCPOS_INIT(pszFile, uLine, pszFunction, uId) \
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync { (pszFile), (pszFunction), (uId), (uLine), 0 }
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync#else
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync# define RTLOCKVALSRCPOS_INIT(pszFile, uLine, pszFunction, uId) \
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync { (pszFile), (pszFunction), (uId), (uLine) }
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync#endif
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync/** @def RTLOCKVALSRCPOS_INIT_DEBUG_API
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync * Initializer for a RTLOCKVALSRCPOS variable in a typicial debug API
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync * variant. Assumes RT_SRC_POS_DECL and RTHCUINTPTR uId as arguments.
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync */
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync#define RTLOCKVALSRCPOS_INIT_DEBUG_API() \
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync RTLOCKVALSRCPOS_INIT(pszFile, iLine, pszFunction, uId)
7c48fdac0546978ed14617c8096734ce2d18c8e5vboxsync
7c48fdac0546978ed14617c8096734ce2d18c8e5vboxsync/** @def RTLOCKVALSRCPOS_INIT_NORMAL_API
7c48fdac0546978ed14617c8096734ce2d18c8e5vboxsync * Initializer for a RTLOCKVALSRCPOS variable in a normal API
7c48fdac0546978ed14617c8096734ce2d18c8e5vboxsync * variant. Assumes iprt/asm.h is included.
7c48fdac0546978ed14617c8096734ce2d18c8e5vboxsync */
7c48fdac0546978ed14617c8096734ce2d18c8e5vboxsync#define RTLOCKVALSRCPOS_INIT_NORMAL_API() \
7c48fdac0546978ed14617c8096734ce2d18c8e5vboxsync RTLOCKVALSRCPOS_INIT(__FILE__, __LINE__, __PRETTY_FUNCTION__, (uintptr_t)ASMReturnAddress())
7c48fdac0546978ed14617c8096734ce2d18c8e5vboxsync
7c48fdac0546978ed14617c8096734ce2d18c8e5vboxsync/** @def RTLOCKVALSRCPOS_INIT_POS_NO_ID
9b7ab382b3f9667e8847020e1e58f7143c4d2334vboxsync * Initializer for a RTLOCKVALSRCPOS variable when no @c uId is present.
9b7ab382b3f9667e8847020e1e58f7143c4d2334vboxsync * Assumes iprt/asm.h is included.
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync */
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync#define RTLOCKVALSRCPOS_INIT_POS_NO_ID() \
63e3a547845f7c31bb4e892a66684b560dc63611vboxsync RTLOCKVALSRCPOS_INIT(pszFile, iLine, pszFunction, (uintptr_t)ASMReturnAddress())
63e3a547845f7c31bb4e892a66684b560dc63611vboxsync
63787aca0a2a16ec959a5294148726ccf898ddf1vboxsync/** Pointer to a record of one ownership share. */
63e3a547845f7c31bb4e892a66684b560dc63611vboxsynctypedef struct RTLOCKVALRECSHRD *PRTLOCKVALRECSHRD;
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync
b2bc8de1367ae24e1b27b53921d0b32ee3df7acdvboxsync/**
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync * Lock validator record core.
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync */
2f0d866e126dd288169fed591c259c1c6b4016e5vboxsynctypedef struct RTLOCKVALRECORE
c060166f65b9dd2f1ed53e6e4cffdad948e01722vboxsync{
c060166f65b9dd2f1ed53e6e4cffdad948e01722vboxsync /** The magic value indicating the record type. */
c060166f65b9dd2f1ed53e6e4cffdad948e01722vboxsync uint32_t volatile u32Magic;
c060166f65b9dd2f1ed53e6e4cffdad948e01722vboxsync} RTLOCKVALRECCORE;
c060166f65b9dd2f1ed53e6e4cffdad948e01722vboxsync/** Pointer to a lock validator record core. */
c060166f65b9dd2f1ed53e6e4cffdad948e01722vboxsynctypedef RTLOCKVALRECCORE *PRTLOCKVALRECCORE;
c060166f65b9dd2f1ed53e6e4cffdad948e01722vboxsync/** Pointer to a const lock validator record core. */
c060166f65b9dd2f1ed53e6e4cffdad948e01722vboxsynctypedef RTLOCKVALRECCORE const *PCRTLOCKVALRECCORE;
c060166f65b9dd2f1ed53e6e4cffdad948e01722vboxsync
c060166f65b9dd2f1ed53e6e4cffdad948e01722vboxsync
c060166f65b9dd2f1ed53e6e4cffdad948e01722vboxsync/**
c060166f65b9dd2f1ed53e6e4cffdad948e01722vboxsync * Record recording the exclusive ownership of a lock.
c060166f65b9dd2f1ed53e6e4cffdad948e01722vboxsync *
c060166f65b9dd2f1ed53e6e4cffdad948e01722vboxsync * This is typically part of the per-lock data structure when compiling with
c060166f65b9dd2f1ed53e6e4cffdad948e01722vboxsync * the lock validator.
c060166f65b9dd2f1ed53e6e4cffdad948e01722vboxsync */
c060166f65b9dd2f1ed53e6e4cffdad948e01722vboxsynctypedef struct RTLOCKVALRECEXCL
e562a8bb17c0dfa1c316708e085a3a92fcc80521vboxsync{
e562a8bb17c0dfa1c316708e085a3a92fcc80521vboxsync /** Record core with RTLOCKVALRECEXCL_MAGIC as the magic value. */
e562a8bb17c0dfa1c316708e085a3a92fcc80521vboxsync RTLOCKVALRECCORE Core;
e562a8bb17c0dfa1c316708e085a3a92fcc80521vboxsync /** Whether it's enabled or not. */
e562a8bb17c0dfa1c316708e085a3a92fcc80521vboxsync bool fEnabled;
e562a8bb17c0dfa1c316708e085a3a92fcc80521vboxsync /** Reserved. */
e562a8bb17c0dfa1c316708e085a3a92fcc80521vboxsync bool afReserved[3];
e562a8bb17c0dfa1c316708e085a3a92fcc80521vboxsync /** Source position where the lock was taken. */
e562a8bb17c0dfa1c316708e085a3a92fcc80521vboxsync RTLOCKVALSRCPOS SrcPos;
e562a8bb17c0dfa1c316708e085a3a92fcc80521vboxsync /** The current owner thread. */
e562a8bb17c0dfa1c316708e085a3a92fcc80521vboxsync RTTHREAD volatile hThread;
e562a8bb17c0dfa1c316708e085a3a92fcc80521vboxsync /** Pointer to the lock record below us. Only accessed by the owner. */
e562a8bb17c0dfa1c316708e085a3a92fcc80521vboxsync R3R0PTRTYPE(PRTLOCKVALRECUNION) pDown;
e562a8bb17c0dfa1c316708e085a3a92fcc80521vboxsync /** Recursion count */
e562a8bb17c0dfa1c316708e085a3a92fcc80521vboxsync uint32_t cRecursion;
e562a8bb17c0dfa1c316708e085a3a92fcc80521vboxsync /** The lock sub-class. */
e562a8bb17c0dfa1c316708e085a3a92fcc80521vboxsync uint32_t volatile uSubClass;
e562a8bb17c0dfa1c316708e085a3a92fcc80521vboxsync /** The lock class. */
e562a8bb17c0dfa1c316708e085a3a92fcc80521vboxsync RTLOCKVALCLASS hClass;
e562a8bb17c0dfa1c316708e085a3a92fcc80521vboxsync /** Pointer to the lock. */
e562a8bb17c0dfa1c316708e085a3a92fcc80521vboxsync RTHCPTR hLock;
e562a8bb17c0dfa1c316708e085a3a92fcc80521vboxsync /** Pointer to the next sibling record.
e562a8bb17c0dfa1c316708e085a3a92fcc80521vboxsync * This is used to find the read side of a read-write lock. */
e562a8bb17c0dfa1c316708e085a3a92fcc80521vboxsync R3R0PTRTYPE(PRTLOCKVALRECUNION) pSibling;
e562a8bb17c0dfa1c316708e085a3a92fcc80521vboxsync /** The lock name.
e562a8bb17c0dfa1c316708e085a3a92fcc80521vboxsync * @remarks The bytes beyond 32 are for better size alignment and can be
e562a8bb17c0dfa1c316708e085a3a92fcc80521vboxsync * taken and used for other purposes if it becomes necessary. */
2f0d866e126dd288169fed591c259c1c6b4016e5vboxsync char szName[32 + (HC_ARCH_BITS == 32 ? 12 : 8)];
2f0d866e126dd288169fed591c259c1c6b4016e5vboxsync} RTLOCKVALRECEXCL;
2f0d866e126dd288169fed591c259c1c6b4016e5vboxsyncAssertCompileSize(RTLOCKVALRECEXCL, HC_ARCH_BITS == 32 ? 0x60 : 0x80);
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync/* The pointer type is defined in iprt/types.h. */
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync/**
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync * For recording the one ownership share.
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync */
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsynctypedef struct RTLOCKVALRECSHRDOWN
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync{
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync /** Record core with RTLOCKVALRECSHRDOWN_MAGIC as the magic value. */
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync RTLOCKVALRECCORE Core;
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync /** Recursion count */
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync uint16_t cRecursion;
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync /** Static (true) or dynamic (false) allocated record. */
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync bool fStaticAlloc;
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync /** Reserved. */
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync bool fReserved;
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync /** The current owner thread. */
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync RTTHREAD volatile hThread;
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync /** Pointer to the lock record below us. Only accessed by the owner. */
b2bc8de1367ae24e1b27b53921d0b32ee3df7acdvboxsync R3R0PTRTYPE(PRTLOCKVALRECUNION) pDown;
b2bc8de1367ae24e1b27b53921d0b32ee3df7acdvboxsync /** Pointer back to the shared record. */
b2bc8de1367ae24e1b27b53921d0b32ee3df7acdvboxsync R3R0PTRTYPE(PRTLOCKVALRECSHRD) pSharedRec;
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync#if HC_ARCH_BITS == 32
b2bc8de1367ae24e1b27b53921d0b32ee3df7acdvboxsync /** Reserved. */
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync RTHCPTR pvReserved;
b2bc8de1367ae24e1b27b53921d0b32ee3df7acdvboxsync#endif
b2bc8de1367ae24e1b27b53921d0b32ee3df7acdvboxsync /** Source position where the lock was taken. */
b2bc8de1367ae24e1b27b53921d0b32ee3df7acdvboxsync RTLOCKVALSRCPOS SrcPos;
b2bc8de1367ae24e1b27b53921d0b32ee3df7acdvboxsync} RTLOCKVALRECSHRDOWN;
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsyncAssertCompileSize(RTLOCKVALRECSHRDOWN, HC_ARCH_BITS == 32 ? 24 + 16 : 32 + 32);
b2bc8de1367ae24e1b27b53921d0b32ee3df7acdvboxsync/** Pointer to a RTLOCKVALRECSHRDOWN. */
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsynctypedef RTLOCKVALRECSHRDOWN *PRTLOCKVALRECSHRDOWN;
b2bc8de1367ae24e1b27b53921d0b32ee3df7acdvboxsync
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync/**
b2bc8de1367ae24e1b27b53921d0b32ee3df7acdvboxsync * Record recording the shared ownership of a lock.
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync *
b2bc8de1367ae24e1b27b53921d0b32ee3df7acdvboxsync * This is typically part of the per-lock data structure when compiling with
b2bc8de1367ae24e1b27b53921d0b32ee3df7acdvboxsync * the lock validator.
b2bc8de1367ae24e1b27b53921d0b32ee3df7acdvboxsync */
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsynctypedef struct RTLOCKVALRECSHRD
b2bc8de1367ae24e1b27b53921d0b32ee3df7acdvboxsync{
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync /** Record core with RTLOCKVALRECSHRD_MAGIC as the magic value. */
b2bc8de1367ae24e1b27b53921d0b32ee3df7acdvboxsync RTLOCKVALRECCORE Core;
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync /** The lock sub-class. */
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync uint32_t volatile uSubClass;
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync /** The lock class. */
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync RTLOCKVALCLASS hClass;
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync /** Pointer to the lock. */
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync RTHCPTR hLock;
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync /** Pointer to the next sibling record.
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync * This is used to find the write side of a read-write lock. */
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync R3R0PTRTYPE(PRTLOCKVALRECUNION) pSibling;
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync /** The number of entries in the table.
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync * Updated before inserting and after removal. */
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync uint32_t volatile cEntries;
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync /** The index of the last entry (approximately). */
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync uint32_t volatile iLastEntry;
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync /** The max table size. */
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync uint32_t volatile cAllocated;
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync /** Set if the table is being reallocated, clear if not.
8287c906b9b1d215824d4cdf6c1eaf40681ebfa8vboxsync * This is used together with rtLockValidatorSerializeDetectionEnter to make
8742e4a4ddb7b62d21d96d56dd1baf01c9f22cecvboxsync * sure there is exactly one thread doing the reallocation and that nobody is
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync * using the table at that point. */
8287c906b9b1d215824d4cdf6c1eaf40681ebfa8vboxsync bool volatile fReallocating;
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync /** Whether it's enabled or not. */
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync bool fEnabled;
8287c906b9b1d215824d4cdf6c1eaf40681ebfa8vboxsync /** Set if event semaphore signaller, clear if read-write semaphore. */
8287c906b9b1d215824d4cdf6c1eaf40681ebfa8vboxsync bool fSignaller;
8287c906b9b1d215824d4cdf6c1eaf40681ebfa8vboxsync /** Alignment padding. */
63787aca0a2a16ec959a5294148726ccf898ddf1vboxsync bool fPadding;
63787aca0a2a16ec959a5294148726ccf898ddf1vboxsync /** Pointer to a table containing pointers to records of all the owners. */
63787aca0a2a16ec959a5294148726ccf898ddf1vboxsync R3R0PTRTYPE(PRTLOCKVALRECSHRDOWN volatile *) papOwners;
8287c906b9b1d215824d4cdf6c1eaf40681ebfa8vboxsync
762a68c2bb3ccde807330e3d1cb05f8b244a5f72vboxsync /** The lock name.
8287c906b9b1d215824d4cdf6c1eaf40681ebfa8vboxsync * @remarks The bytes beyond 32 are for better size alignment and can be
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync * taken and used for other purposes if it becomes necessary. */
8287c906b9b1d215824d4cdf6c1eaf40681ebfa8vboxsync char szName[32 + (HC_ARCH_BITS == 32 ? 8 : 8)];
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync} RTLOCKVALRECSHRD;
8287c906b9b1d215824d4cdf6c1eaf40681ebfa8vboxsyncAssertCompileSize(RTLOCKVALRECSHRD, HC_ARCH_BITS == 32 ? 0x50 : 0x60);
9540eeb13face31ddc1c5f15338556fe46f18a77vboxsync
8287c906b9b1d215824d4cdf6c1eaf40681ebfa8vboxsync
9540eeb13face31ddc1c5f15338556fe46f18a77vboxsync/**
fe554d9c0e3a6de4ba221610ac95a44c7d288e01vboxsync * Makes the two records siblings.
f2a212e40c7307d2b8ef9b2658a539f5ac41e683vboxsync *
3ebd5757516d21eccdad25ddd456d2913c2fb215vboxsync * @returns VINF_SUCCESS on success, VERR_SEM_LV_INVALID_PARAMETER if either of
fe554d9c0e3a6de4ba221610ac95a44c7d288e01vboxsync * the records are invalid.
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync * @param pRec1 Record 1.
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync * @param pRec2 Record 2.
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync */
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsyncRTDECL(int) RTLockValidatorRecMakeSiblings(PRTLOCKVALRECCORE pRec1, PRTLOCKVALRECCORE pRec2);
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync/**
b2bc8de1367ae24e1b27b53921d0b32ee3df7acdvboxsync * Initialize a lock validator record.
7c48fdac0546978ed14617c8096734ce2d18c8e5vboxsync *
b2bc8de1367ae24e1b27b53921d0b32ee3df7acdvboxsync * Use RTLockValidatorRecExclDelete to deinitialize it.
7c48fdac0546978ed14617c8096734ce2d18c8e5vboxsync *
7c48fdac0546978ed14617c8096734ce2d18c8e5vboxsync * @param pRec The record.
7c48fdac0546978ed14617c8096734ce2d18c8e5vboxsync * @param hClass The class (no reference consumed). If NIL, the
7c48fdac0546978ed14617c8096734ce2d18c8e5vboxsync * no lock order validation will be performed on
b2bc8de1367ae24e1b27b53921d0b32ee3df7acdvboxsync * this lock.
7c48fdac0546978ed14617c8096734ce2d18c8e5vboxsync * @param uSubClass The sub-class. This is used to define lock
b2bc8de1367ae24e1b27b53921d0b32ee3df7acdvboxsync * order inside the same class. If you don't know,
7c48fdac0546978ed14617c8096734ce2d18c8e5vboxsync * then pass RTLOCKVAL_SUB_CLASS_NONE.
7c48fdac0546978ed14617c8096734ce2d18c8e5vboxsync * @param hLock The lock handle.
7c48fdac0546978ed14617c8096734ce2d18c8e5vboxsync * @param fEnabled Pass @c false to explicitly disable lock
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync * validation, otherwise @c true.
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync * @param pszNameFmt Name format string for the lock validator,
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync * optional (NULL). Max length is 32 bytes.
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync * @param ... Format string arguments.
7c48fdac0546978ed14617c8096734ce2d18c8e5vboxsync */
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsyncRTDECL(void) RTLockValidatorRecExclInit(PRTLOCKVALRECEXCL pRec, RTLOCKVALCLASS hClass, uint32_t uSubClass,
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync void *hLock, bool fEnabled, const char *pszNameFmt, ...);
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync/**
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync * Initialize a lock validator record.
3ebd5757516d21eccdad25ddd456d2913c2fb215vboxsync *
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync * Use RTLockValidatorRecExclDelete to deinitialize it.
63787aca0a2a16ec959a5294148726ccf898ddf1vboxsync *
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync * @param pRec The record.
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync * @param hClass The class (no reference consumed). If NIL, the
3ebd5757516d21eccdad25ddd456d2913c2fb215vboxsync * no lock order validation will be performed on
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync * this lock.
63787aca0a2a16ec959a5294148726ccf898ddf1vboxsync * @param uSubClass The sub-class. This is used to define lock
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync * order inside the same class. If you don't know,
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync * then pass RTLOCKVAL_SUB_CLASS_NONE.
3ebd5757516d21eccdad25ddd456d2913c2fb215vboxsync * @param hLock The lock handle.
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync * @param fEnabled Pass @c false to explicitly disable lock
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync * validation, otherwise @c true.
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync * @param pszNameFmt Name format string for the lock validator,
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync * optional (NULL). Max length is 32 bytes.
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync * @param va Format string arguments.
b2bc8de1367ae24e1b27b53921d0b32ee3df7acdvboxsync */
b2bc8de1367ae24e1b27b53921d0b32ee3df7acdvboxsyncRTDECL(void) RTLockValidatorRecExclInitV(PRTLOCKVALRECEXCL pRec, RTLOCKVALCLASS hClass, uint32_t uSubClass,
b2bc8de1367ae24e1b27b53921d0b32ee3df7acdvboxsync void *hLock, bool fEnabled, const char *pszNameFmt, va_list va);
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync/**
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync * Uninitialize a lock validator record previously initialized by
7c48fdac0546978ed14617c8096734ce2d18c8e5vboxsync * RTLockRecValidatorInit.
7c48fdac0546978ed14617c8096734ce2d18c8e5vboxsync *
7c48fdac0546978ed14617c8096734ce2d18c8e5vboxsync * @param pRec The record. Must be valid.
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync */
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsyncRTDECL(void) RTLockValidatorRecExclDelete(PRTLOCKVALRECEXCL pRec);
762a68c2bb3ccde807330e3d1cb05f8b244a5f72vboxsync
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync/**
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync * Create and initialize a lock validator record.
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync *
7c48fdac0546978ed14617c8096734ce2d18c8e5vboxsync * Use RTLockValidatorRecExclDestroy to deinitialize and destroy the returned
7c48fdac0546978ed14617c8096734ce2d18c8e5vboxsync * record.
7c48fdac0546978ed14617c8096734ce2d18c8e5vboxsync *
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync * @return VINF_SUCCESS or VERR_NO_MEMORY.
3ebd5757516d21eccdad25ddd456d2913c2fb215vboxsync * @param ppRec Where to return the record pointer.
3ebd5757516d21eccdad25ddd456d2913c2fb215vboxsync * @param hClass The class (no reference consumed). If NIL, the
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync * no lock order validation will be performed on
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync * this lock.
7c48fdac0546978ed14617c8096734ce2d18c8e5vboxsync * @param uSubClass The sub-class. This is used to define lock
7c48fdac0546978ed14617c8096734ce2d18c8e5vboxsync * order inside the same class. If you don't know,
7c48fdac0546978ed14617c8096734ce2d18c8e5vboxsync * then pass RTLOCKVAL_SUB_CLASS_NONE.
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync * @param hLock The lock handle.
3ebd5757516d21eccdad25ddd456d2913c2fb215vboxsync * @param fEnabled Pass @c false to explicitly disable lock
3ebd5757516d21eccdad25ddd456d2913c2fb215vboxsync * validation, otherwise @c true.
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync * @param pszNameFmt Name format string for the lock validator,
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync * optional (NULL). Max length is 32 bytes.
b2bc8de1367ae24e1b27b53921d0b32ee3df7acdvboxsync * @param ... Format string arguments.
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync */
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsyncRTDECL(int) RTLockValidatorRecExclCreate(PRTLOCKVALRECEXCL *ppRec, RTLOCKVALCLASS hClass, uint32_t uSubClass,
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync void *hLock, bool fEnabled, const char *pszNameFmt, ...);
b2bc8de1367ae24e1b27b53921d0b32ee3df7acdvboxsync
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync/**
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync * Create and initialize a lock validator record.
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync *
b2bc8de1367ae24e1b27b53921d0b32ee3df7acdvboxsync * Use RTLockValidatorRecExclDestroy to deinitialize and destroy the returned
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync * record.
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync *
7697e43970d863558b6c168a55e8948ccb18d8d1vboxsync * @return VINF_SUCCESS or VERR_NO_MEMORY.
7697e43970d863558b6c168a55e8948ccb18d8d1vboxsync * @param ppRec Where to return the record pointer.
7697e43970d863558b6c168a55e8948ccb18d8d1vboxsync * @param hClass The class (no reference consumed). If NIL, the
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync * no lock order validation will be performed on
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync * this lock.
b2bc8de1367ae24e1b27b53921d0b32ee3df7acdvboxsync * @param uSubClass The sub-class. This is used to define lock
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync * order inside the same class. If you don't know,
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync * then pass RTLOCKVAL_SUB_CLASS_NONE.
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync * @param hLock The lock handle.
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync * @param fEnabled Pass @c false to explicitly disable lock
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync * validation, otherwise @c true.
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync * @param pszNameFmt Name format string for the lock validator,
b2bc8de1367ae24e1b27b53921d0b32ee3df7acdvboxsync * optional (NULL). Max length is 32 bytes.
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync * @param va Format string arguments.
b2bc8de1367ae24e1b27b53921d0b32ee3df7acdvboxsync */
b2bc8de1367ae24e1b27b53921d0b32ee3df7acdvboxsyncRTDECL(int) RTLockValidatorRecExclCreateV(PRTLOCKVALRECEXCL *ppRec, RTLOCKVALCLASS hClass, uint32_t uSubClass,
b2bc8de1367ae24e1b27b53921d0b32ee3df7acdvboxsync void *hLock, bool fEnabled, const char *pszNameFmt, va_list va);
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync/**
b2bc8de1367ae24e1b27b53921d0b32ee3df7acdvboxsync * Deinitialize and destroy a record created by RTLockValidatorRecExclCreate.
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync *
b2bc8de1367ae24e1b27b53921d0b32ee3df7acdvboxsync * @param ppRec Pointer to the record pointer. Will be set to
b2bc8de1367ae24e1b27b53921d0b32ee3df7acdvboxsync * NULL.
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync */
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsyncRTDECL(void) RTLockValidatorRecExclDestroy(PRTLOCKVALRECEXCL *ppRec);
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync
b2bc8de1367ae24e1b27b53921d0b32ee3df7acdvboxsync/**
b2bc8de1367ae24e1b27b53921d0b32ee3df7acdvboxsync * Sets the sub-class of the record.
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync *
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync * It is recommended to try make sure that nobody is using this class while
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync * changing the value.
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync *
9674ed871d32468dd791ad601151f46d2e843350vboxsync * @returns The old sub-class. RTLOCKVAL_SUB_CLASS_INVALID is returns if the
9674ed871d32468dd791ad601151f46d2e843350vboxsync * lock validator isn't compiled in or either of the parameters are
9674ed871d32468dd791ad601151f46d2e843350vboxsync * invalid.
9674ed871d32468dd791ad601151f46d2e843350vboxsync * @param pRec The validator record.
9674ed871d32468dd791ad601151f46d2e843350vboxsync * @param uSubClass The new sub-class value.
9674ed871d32468dd791ad601151f46d2e843350vboxsync */
9674ed871d32468dd791ad601151f46d2e843350vboxsyncRTDECL(uint32_t) RTLockValidatorRecExclSetSubClass(PRTLOCKVALRECEXCL pRec, uint32_t uSubClass);
9674ed871d32468dd791ad601151f46d2e843350vboxsync
9674ed871d32468dd791ad601151f46d2e843350vboxsync/**
9674ed871d32468dd791ad601151f46d2e843350vboxsync * Record the specified thread as lock owner and increment the write lock count.
9674ed871d32468dd791ad601151f46d2e843350vboxsync *
9674ed871d32468dd791ad601151f46d2e843350vboxsync * This function is typically called after acquiring the lock. It accounts for
9674ed871d32468dd791ad601151f46d2e843350vboxsync * recursions so it can be used instead of RTLockValidatorRecExclRecursion. Use
9674ed871d32468dd791ad601151f46d2e843350vboxsync * RTLockValidatorRecExclReleaseOwner to reverse the effect.
9674ed871d32468dd791ad601151f46d2e843350vboxsync *
9674ed871d32468dd791ad601151f46d2e843350vboxsync * @param pRec The validator record.
9674ed871d32468dd791ad601151f46d2e843350vboxsync * @param hThreadSelf The handle of the calling thread. If not known,
9674ed871d32468dd791ad601151f46d2e843350vboxsync * pass NIL_RTTHREAD and we'll figure it out.
9674ed871d32468dd791ad601151f46d2e843350vboxsync * @param pSrcPos The source position of the lock operation.
b2bc8de1367ae24e1b27b53921d0b32ee3df7acdvboxsync * @param fFirstRecursion Set if it is the first recursion, clear if not
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync * sure.
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync */
b2bc8de1367ae24e1b27b53921d0b32ee3df7acdvboxsyncRTDECL(void) RTLockValidatorRecExclSetOwner(PRTLOCKVALRECEXCL pRec, RTTHREAD hThreadSelf,
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync PCRTLOCKVALSRCPOS pSrcPos, bool fFirstRecursion);
e562a8bb17c0dfa1c316708e085a3a92fcc80521vboxsync
b2bc8de1367ae24e1b27b53921d0b32ee3df7acdvboxsync/**
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync * Check the exit order and release (unset) the ownership.
e562a8bb17c0dfa1c316708e085a3a92fcc80521vboxsync *
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync * This is called by routines implementing releasing an exclusive lock,
7c48fdac0546978ed14617c8096734ce2d18c8e5vboxsync * typically before getting down to the final lock releaseing. Can be used for
7c48fdac0546978ed14617c8096734ce2d18c8e5vboxsync * recursive releasing instead of RTLockValidatorRecExclUnwind.
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync *
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync * @retval VINF_SUCCESS on success.
b2bc8de1367ae24e1b27b53921d0b32ee3df7acdvboxsync * @retval VERR_SEM_LV_WRONG_RELEASE_ORDER if the order is wrong. Will have
b2bc8de1367ae24e1b27b53921d0b32ee3df7acdvboxsync * done all necessary whining and breakpointing before returning.
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync * @retval VERR_SEM_LV_INVALID_PARAMETER if the input is invalid.
e562a8bb17c0dfa1c316708e085a3a92fcc80521vboxsync *
7c48fdac0546978ed14617c8096734ce2d18c8e5vboxsync * @param pRec The validator record.
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync * @param fFinalRecursion Set if it's the final recursion, clear if not
3956d0151065a11e49d2213b38a5efdad46807e0vboxsync * sure.
b2bc8de1367ae24e1b27b53921d0b32ee3df7acdvboxsync */
7c48fdac0546978ed14617c8096734ce2d18c8e5vboxsyncRTDECL(int) RTLockValidatorRecExclReleaseOwner(PRTLOCKVALRECEXCL pRec, bool fFinalRecursion);
b2bc8de1367ae24e1b27b53921d0b32ee3df7acdvboxsync
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync/**
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync * Clear the lock ownership and decrement the write lock count.
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync *
e562a8bb17c0dfa1c316708e085a3a92fcc80521vboxsync * This is only for special cases where we wish to drop lock validation
e562a8bb17c0dfa1c316708e085a3a92fcc80521vboxsync * recording. See RTLockValidatorRecExclCheckAndRelease.
e562a8bb17c0dfa1c316708e085a3a92fcc80521vboxsync *
e562a8bb17c0dfa1c316708e085a3a92fcc80521vboxsync * @param pRec The validator record.
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync */
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsyncRTDECL(void) RTLockValidatorRecExclReleaseOwnerUnchecked(PRTLOCKVALRECEXCL pRec);
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync/**
b2bc8de1367ae24e1b27b53921d0b32ee3df7acdvboxsync * Checks and records a lock recursion.
b2bc8de1367ae24e1b27b53921d0b32ee3df7acdvboxsync *
9674ed871d32468dd791ad601151f46d2e843350vboxsync * @retval VINF_SUCCESS on success.
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync * @retval VERR_SEM_LV_NESTED if the semaphore class forbids recursion. Gone
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync * thru the motions.
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync * @retval VERR_SEM_LV_WRONG_ORDER if the locking order is wrong. Gone thru
3b1aa24d99d0f9cc157cf72ca76444b2feca3277vboxsync * the motions.
8a54ed337392872c7cfcfb96f173468bbbb0f7fcvboxsync * @retval VERR_SEM_LV_INVALID_PARAMETER if the input is invalid.
8a54ed337392872c7cfcfb96f173468bbbb0f7fcvboxsync *
3ebd5757516d21eccdad25ddd456d2913c2fb215vboxsync * @param pRec The validator record.
3ebd5757516d21eccdad25ddd456d2913c2fb215vboxsync * @param pSrcPos The source position of the lock operation.
3ebd5757516d21eccdad25ddd456d2913c2fb215vboxsync */
3ebd5757516d21eccdad25ddd456d2913c2fb215vboxsyncRTDECL(int) RTLockValidatorRecExclRecursion(PRTLOCKVALRECEXCL pRec, PCRTLOCKVALSRCPOS pSrcPos);
3ebd5757516d21eccdad25ddd456d2913c2fb215vboxsync
3ebd5757516d21eccdad25ddd456d2913c2fb215vboxsync/**
3ebd5757516d21eccdad25ddd456d2913c2fb215vboxsync * Checks and records a lock unwind (releasing one recursion).
3ebd5757516d21eccdad25ddd456d2913c2fb215vboxsync *
3ebd5757516d21eccdad25ddd456d2913c2fb215vboxsync * This should be coupled with called to RTLockValidatorRecExclRecursion.
3ebd5757516d21eccdad25ddd456d2913c2fb215vboxsync *
3ebd5757516d21eccdad25ddd456d2913c2fb215vboxsync * @retval VINF_SUCCESS on success.
3ebd5757516d21eccdad25ddd456d2913c2fb215vboxsync * @retval VERR_SEM_LV_WRONG_RELEASE_ORDER if the release order is wrong. Gone
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync * thru the motions.
e562a8bb17c0dfa1c316708e085a3a92fcc80521vboxsync * @retval VERR_SEM_LV_INVALID_PARAMETER if the input is invalid.
e562a8bb17c0dfa1c316708e085a3a92fcc80521vboxsync *
63787aca0a2a16ec959a5294148726ccf898ddf1vboxsync * @param pRec The validator record.
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync */
3ebd5757516d21eccdad25ddd456d2913c2fb215vboxsyncRTDECL(int) RTLockValidatorRecExclUnwind(PRTLOCKVALRECEXCL pRec);
3ebd5757516d21eccdad25ddd456d2913c2fb215vboxsync
3ebd5757516d21eccdad25ddd456d2913c2fb215vboxsync/**
3ebd5757516d21eccdad25ddd456d2913c2fb215vboxsync * Checks and records a mixed recursion.
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync *
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync * An example of a mixed recursion is a writer requesting read access to a
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync * SemRW.
3ebd5757516d21eccdad25ddd456d2913c2fb215vboxsync *
3ebd5757516d21eccdad25ddd456d2913c2fb215vboxsync * This should be coupled with called to RTLockValidatorRecExclUnwindMixed.
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync *
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync * @retval VINF_SUCCESS on success.
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync * @retval VERR_SEM_LV_NESTED if the semaphore class forbids recursion. Gone
3ebd5757516d21eccdad25ddd456d2913c2fb215vboxsync * thru the motions.
3ebd5757516d21eccdad25ddd456d2913c2fb215vboxsync * @retval VERR_SEM_LV_WRONG_ORDER if the locking order is wrong. Gone thru
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync * the motions.
3ebd5757516d21eccdad25ddd456d2913c2fb215vboxsync * @retval VERR_SEM_LV_INVALID_PARAMETER if the input is invalid.
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync *
3ebd5757516d21eccdad25ddd456d2913c2fb215vboxsync * @param pRec The validator record it to accounted it to.
3ebd5757516d21eccdad25ddd456d2913c2fb215vboxsync * @param pRecMixed The validator record it came in on.
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync * @param pSrcPos The source position of the lock operation.
3ebd5757516d21eccdad25ddd456d2913c2fb215vboxsync */
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsyncRTDECL(int) RTLockValidatorRecExclRecursionMixed(PRTLOCKVALRECEXCL pRec, PRTLOCKVALRECCORE pRecMixed, PCRTLOCKVALSRCPOS pSrcPos);
3ebd5757516d21eccdad25ddd456d2913c2fb215vboxsync
3ebd5757516d21eccdad25ddd456d2913c2fb215vboxsync/**
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync * Checks and records the unwinding of a mixed recursion.
3ebd5757516d21eccdad25ddd456d2913c2fb215vboxsync *
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync * This should be coupled with called to RTLockValidatorRecExclRecursionMixed.
3ebd5757516d21eccdad25ddd456d2913c2fb215vboxsync *
3ebd5757516d21eccdad25ddd456d2913c2fb215vboxsync * @retval VINF_SUCCESS on success.
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync * @retval VERR_SEM_LV_WRONG_RELEASE_ORDER if the release order is wrong. Gone
3ebd5757516d21eccdad25ddd456d2913c2fb215vboxsync * thru the motions.
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync * @retval VERR_SEM_LV_INVALID_PARAMETER if the input is invalid.
3ebd5757516d21eccdad25ddd456d2913c2fb215vboxsync *
3ebd5757516d21eccdad25ddd456d2913c2fb215vboxsync * @param pRec The validator record it was accounted to.
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync * @param pRecMixed The validator record it came in on.
3ebd5757516d21eccdad25ddd456d2913c2fb215vboxsync */
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsyncRTDECL(int) RTLockValidatorRecExclUnwindMixed(PRTLOCKVALRECEXCL pRec, PRTLOCKVALRECCORE pRecMixed);
3ebd5757516d21eccdad25ddd456d2913c2fb215vboxsync
3ebd5757516d21eccdad25ddd456d2913c2fb215vboxsync/**
3ebd5757516d21eccdad25ddd456d2913c2fb215vboxsync * Check the exclusive locking order.
3ebd5757516d21eccdad25ddd456d2913c2fb215vboxsync *
3ebd5757516d21eccdad25ddd456d2913c2fb215vboxsync * This is called by routines implementing exclusive lock acquisition.
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync *
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync * @retval VINF_SUCCESS on success.
3ebd5757516d21eccdad25ddd456d2913c2fb215vboxsync * @retval VERR_SEM_LV_WRONG_ORDER if the order is wrong. Will have done all
3ebd5757516d21eccdad25ddd456d2913c2fb215vboxsync * necessary whining and breakpointing before returning.
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync * @retval VERR_SEM_LV_INVALID_PARAMETER if the input is invalid.
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync *
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync * @param pRec The validator record.
3ebd5757516d21eccdad25ddd456d2913c2fb215vboxsync * @param hThreadSelf The handle of the calling thread. If not known,
3ebd5757516d21eccdad25ddd456d2913c2fb215vboxsync * pass NIL_RTTHREAD and we'll figure it out.
3ebd5757516d21eccdad25ddd456d2913c2fb215vboxsync * @param pSrcPos The source position of the lock operation.
3ebd5757516d21eccdad25ddd456d2913c2fb215vboxsync * @param cMillies The timeout, in milliseconds.
3ebd5757516d21eccdad25ddd456d2913c2fb215vboxsync */
3ebd5757516d21eccdad25ddd456d2913c2fb215vboxsyncRTDECL(int) RTLockValidatorRecExclCheckOrder(PRTLOCKVALRECEXCL pRec, RTTHREAD hThreadSelf,
3ebd5757516d21eccdad25ddd456d2913c2fb215vboxsync PCRTLOCKVALSRCPOS pSrcPos, RTMSINTERVAL cMillies);
3ebd5757516d21eccdad25ddd456d2913c2fb215vboxsync
3ebd5757516d21eccdad25ddd456d2913c2fb215vboxsync/**
e562a8bb17c0dfa1c316708e085a3a92fcc80521vboxsync * Do deadlock detection before blocking on exclusive access to a lock and
e562a8bb17c0dfa1c316708e085a3a92fcc80521vboxsync * change the thread state.
e562a8bb17c0dfa1c316708e085a3a92fcc80521vboxsync *
3ebd5757516d21eccdad25ddd456d2913c2fb215vboxsync * @retval VINF_SUCCESS - thread is in the specified sleep state.
3ebd5757516d21eccdad25ddd456d2913c2fb215vboxsync * @retval VERR_SEM_LV_DEADLOCK if blocking would deadlock. Gone thru the
3ebd5757516d21eccdad25ddd456d2913c2fb215vboxsync * motions.
e562a8bb17c0dfa1c316708e085a3a92fcc80521vboxsync * @retval VERR_SEM_LV_NESTED if the semaphore isn't recursive and hThread is
e562a8bb17c0dfa1c316708e085a3a92fcc80521vboxsync * already the owner. Gone thru the motions.
63787aca0a2a16ec959a5294148726ccf898ddf1vboxsync * @retval VERR_SEM_LV_ILLEGAL_UPGRADE if it's a deadlock on the same lock.
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync * The caller must handle any legal upgrades without invoking this
f2a212e40c7307d2b8ef9b2658a539f5ac41e683vboxsync * function (for now).
f2a212e40c7307d2b8ef9b2658a539f5ac41e683vboxsync * @retval VERR_SEM_LV_INVALID_PARAMETER if the input is invalid.
f2a212e40c7307d2b8ef9b2658a539f5ac41e683vboxsync *
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync * @param pRec The validator record we're blocking on.
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync * @param hThreadSelf The current thread. Shall not be NIL_RTTHREAD!
b2bc8de1367ae24e1b27b53921d0b32ee3df7acdvboxsync * @param pSrcPos The source position of the lock operation.
3ebd5757516d21eccdad25ddd456d2913c2fb215vboxsync * @param fRecursiveOk Whether it's ok to recurse.
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync * @param cMillies The timeout, in milliseconds.
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync * @param enmSleepState The sleep state to enter on successful return.
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync * @param fReallySleeping Is it really going to sleep now or not. Use
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync * false before calls to other IPRT synchronization
648b0a0e189323afe4d836f1848f82c7dded0e58vboxsync * methods.
3ebd5757516d21eccdad25ddd456d2913c2fb215vboxsync */
067712a8118321d460f98b437ecafb6b8dbce301vboxsyncRTDECL(int) RTLockValidatorRecExclCheckBlocking(PRTLOCKVALRECEXCL pRec, RTTHREAD hThreadSelf,
7c48fdac0546978ed14617c8096734ce2d18c8e5vboxsync PCRTLOCKVALSRCPOS pSrcPos, bool fRecursiveOk, RTMSINTERVAL cMillies,
3ebd5757516d21eccdad25ddd456d2913c2fb215vboxsync RTTHREADSTATE enmSleepState, bool fReallySleeping);
f2a212e40c7307d2b8ef9b2658a539f5ac41e683vboxsync
7c48fdac0546978ed14617c8096734ce2d18c8e5vboxsync/**
7c48fdac0546978ed14617c8096734ce2d18c8e5vboxsync * RTLockValidatorRecExclCheckOrder and RTLockValidatorRecExclCheckBlocking
f2a212e40c7307d2b8ef9b2658a539f5ac41e683vboxsync * baked into one call.
7c48fdac0546978ed14617c8096734ce2d18c8e5vboxsync *
7c48fdac0546978ed14617c8096734ce2d18c8e5vboxsync * @returns Any of the statuses returned by the two APIs.
3ebd5757516d21eccdad25ddd456d2913c2fb215vboxsync * @param pRec The validator record.
7c48fdac0546978ed14617c8096734ce2d18c8e5vboxsync * @param hThreadSelf The current thread. Shall not be NIL_RTTHREAD!
f2a212e40c7307d2b8ef9b2658a539f5ac41e683vboxsync * @param pSrcPos The source position of the lock operation.
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync * @param fRecursiveOk Whether it's ok to recurse.
7c48fdac0546978ed14617c8096734ce2d18c8e5vboxsync * @param cMillies The timeout, in milliseconds.
b2bc8de1367ae24e1b27b53921d0b32ee3df7acdvboxsync * @param enmSleepState The sleep state to enter on successful return.
b2bc8de1367ae24e1b27b53921d0b32ee3df7acdvboxsync * @param fReallySleeping Is it really going to sleep now or not. Use
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync * false before calls to other IPRT synchronization
3ebd5757516d21eccdad25ddd456d2913c2fb215vboxsync * methods.
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync */
f2a212e40c7307d2b8ef9b2658a539f5ac41e683vboxsyncRTDECL(int) RTLockValidatorRecExclCheckOrderAndBlocking(PRTLOCKVALRECEXCL pRec, RTTHREAD hThreadSelf,
f2a212e40c7307d2b8ef9b2658a539f5ac41e683vboxsync PCRTLOCKVALSRCPOS pSrcPos, bool fRecursiveOk, RTMSINTERVAL cMillies,
f2a212e40c7307d2b8ef9b2658a539f5ac41e683vboxsync RTTHREADSTATE enmSleepState, bool fReallySleeping);
fe554d9c0e3a6de4ba221610ac95a44c7d288e01vboxsync
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync/**
3ebd5757516d21eccdad25ddd456d2913c2fb215vboxsync * Initialize a lock validator record for a shared lock.
b2bc8de1367ae24e1b27b53921d0b32ee3df7acdvboxsync *
3ebd5757516d21eccdad25ddd456d2913c2fb215vboxsync * Use RTLockValidatorRecSharedDelete to deinitialize it.
e562a8bb17c0dfa1c316708e085a3a92fcc80521vboxsync *
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync * @param pRec The shared lock record.
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync * @param hClass The class (no reference consumed). If NIL, the
b2bc8de1367ae24e1b27b53921d0b32ee3df7acdvboxsync * no lock order validation will be performed on
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync * this lock.
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync * @param uSubClass The sub-class. This is used to define lock
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync * order inside the same class. If you don't know,
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync * then pass RTLOCKVAL_SUB_CLASS_NONE.
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync * @param hLock The lock handle.
b2bc8de1367ae24e1b27b53921d0b32ee3df7acdvboxsync * @param fSignaller Set if event semaphore signaller logic should be
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync * applied to this record, clear if read-write
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync * semaphore logic should be used.
648b0a0e189323afe4d836f1848f82c7dded0e58vboxsync * @param fEnabled Pass @c false to explicitly disable lock
e562a8bb17c0dfa1c316708e085a3a92fcc80521vboxsync * validation, otherwise @c true.
e562a8bb17c0dfa1c316708e085a3a92fcc80521vboxsync * @param pszNameFmt Name format string for the lock validator,
b2bc8de1367ae24e1b27b53921d0b32ee3df7acdvboxsync * optional (NULL). Max length is 32 bytes.
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync * @param ... Format string arguments.
f2a212e40c7307d2b8ef9b2658a539f5ac41e683vboxsync */
f2a212e40c7307d2b8ef9b2658a539f5ac41e683vboxsyncRTDECL(void) RTLockValidatorRecSharedInit(PRTLOCKVALRECSHRD pRec, RTLOCKVALCLASS hClass, uint32_t uSubClass,
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync void *hLock, bool fSignaller, bool fEnabled, const char *pszNameFmt, ...);
f2a212e40c7307d2b8ef9b2658a539f5ac41e683vboxsync/**
b2bc8de1367ae24e1b27b53921d0b32ee3df7acdvboxsync * Initialize a lock validator record for a shared lock.
e562a8bb17c0dfa1c316708e085a3a92fcc80521vboxsync *
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync * Use RTLockValidatorRecSharedDelete to deinitialize it.
762a68c2bb3ccde807330e3d1cb05f8b244a5f72vboxsync *
b2bc8de1367ae24e1b27b53921d0b32ee3df7acdvboxsync * @param pRec The shared lock record.
e562a8bb17c0dfa1c316708e085a3a92fcc80521vboxsync * @param hClass The class (no reference consumed). If NIL, the
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync * no lock order validation will be performed on
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync * this lock.
b2bc8de1367ae24e1b27b53921d0b32ee3df7acdvboxsync * @param uSubClass The sub-class. This is used to define lock
36fbf6dcd3e6b2e5891456b730577ff0eb355c9fvboxsync * order inside the same class. If you don't know,
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync * then pass RTLOCKVAL_SUB_CLASS_NONE.
648b0a0e189323afe4d836f1848f82c7dded0e58vboxsync * @param hLock The lock handle.
e562a8bb17c0dfa1c316708e085a3a92fcc80521vboxsync * @param fSignaller Set if event semaphore signaller logic should be
e562a8bb17c0dfa1c316708e085a3a92fcc80521vboxsync * applied to this record, clear if read-write
e562a8bb17c0dfa1c316708e085a3a92fcc80521vboxsync * semaphore logic should be used.
e562a8bb17c0dfa1c316708e085a3a92fcc80521vboxsync * @param fEnabled Pass @c false to explicitly disable lock
e562a8bb17c0dfa1c316708e085a3a92fcc80521vboxsync * validation, otherwise @c true.
e562a8bb17c0dfa1c316708e085a3a92fcc80521vboxsync * @param pszNameFmt Name format string for the lock validator,
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync * optional (NULL). Max length is 32 bytes.
e562a8bb17c0dfa1c316708e085a3a92fcc80521vboxsync * @param va Format string arguments.
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync */
e562a8bb17c0dfa1c316708e085a3a92fcc80521vboxsyncRTDECL(void) RTLockValidatorRecSharedInitV(PRTLOCKVALRECSHRD pRec, RTLOCKVALCLASS hClass, uint32_t uSubClass,
7c48fdac0546978ed14617c8096734ce2d18c8e5vboxsync void *hLock, bool fSignaller, bool fEnabled, const char *pszNameFmt, va_list va);
e562a8bb17c0dfa1c316708e085a3a92fcc80521vboxsync/**
e562a8bb17c0dfa1c316708e085a3a92fcc80521vboxsync * Uninitialize a lock validator record previously initialized by
e562a8bb17c0dfa1c316708e085a3a92fcc80521vboxsync * RTLockValidatorRecSharedInit.
e562a8bb17c0dfa1c316708e085a3a92fcc80521vboxsync *
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync * @param pRec The shared lock record. Must be valid.
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync */
b2bc8de1367ae24e1b27b53921d0b32ee3df7acdvboxsyncRTDECL(void) RTLockValidatorRecSharedDelete(PRTLOCKVALRECSHRD pRec);
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync/**
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync * Sets the sub-class of the record.
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync *
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync * It is recommended to try make sure that nobody is using this class while
b2bc8de1367ae24e1b27b53921d0b32ee3df7acdvboxsync * changing the value.
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync *
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync * @returns The old sub-class. RTLOCKVAL_SUB_CLASS_INVALID is returns if the
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync * lock validator isn't compiled in or either of the parameters are
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync * invalid.
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync * @param pRec The validator record.
b2bc8de1367ae24e1b27b53921d0b32ee3df7acdvboxsync * @param uSubClass The new sub-class value.
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync */
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsyncRTDECL(uint32_t) RTLockValidatorRecSharedSetSubClass(PRTLOCKVALRECSHRD pRec, uint32_t uSubClass);
e562a8bb17c0dfa1c316708e085a3a92fcc80521vboxsync
e562a8bb17c0dfa1c316708e085a3a92fcc80521vboxsync/**
e562a8bb17c0dfa1c316708e085a3a92fcc80521vboxsync * Check the shared locking order.
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync *
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync * This is called by routines implementing shared lock acquisition.
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync *
b2bc8de1367ae24e1b27b53921d0b32ee3df7acdvboxsync * @retval VINF_SUCCESS on success.
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync * @retval VERR_SEM_LV_WRONG_ORDER if the order is wrong. Will have done all
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync * necessary whining and breakpointing before returning.
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync * @retval VERR_SEM_LV_INVALID_PARAMETER if the input is invalid.
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync *
3b1aa24d99d0f9cc157cf72ca76444b2feca3277vboxsync * @param pRec The validator record.
8a54ed337392872c7cfcfb96f173468bbbb0f7fcvboxsync * @param hThreadSelf The handle of the calling thread. If not known,
8a54ed337392872c7cfcfb96f173468bbbb0f7fcvboxsync * pass NIL_RTTHREAD and we'll figure it out.
8a54ed337392872c7cfcfb96f173468bbbb0f7fcvboxsync * @param pSrcPos The source position of the lock operation.
8a54ed337392872c7cfcfb96f173468bbbb0f7fcvboxsync */
8a54ed337392872c7cfcfb96f173468bbbb0f7fcvboxsyncRTDECL(int) RTLockValidatorRecSharedCheckOrder(PRTLOCKVALRECSHRD pRec, RTTHREAD hThreadSelf,
8a54ed337392872c7cfcfb96f173468bbbb0f7fcvboxsync PCRTLOCKVALSRCPOS pSrcPos, RTMSINTERVAL cMillies);
8a54ed337392872c7cfcfb96f173468bbbb0f7fcvboxsync
8a54ed337392872c7cfcfb96f173468bbbb0f7fcvboxsync/**
8a54ed337392872c7cfcfb96f173468bbbb0f7fcvboxsync * Do deadlock detection before blocking on shared access to a lock and change
e562a8bb17c0dfa1c316708e085a3a92fcc80521vboxsync * the thread state.
e562a8bb17c0dfa1c316708e085a3a92fcc80521vboxsync *
8a54ed337392872c7cfcfb96f173468bbbb0f7fcvboxsync * @retval VINF_SUCCESS - thread is in the specified sleep state.
e562a8bb17c0dfa1c316708e085a3a92fcc80521vboxsync * @retval VERR_SEM_LV_DEADLOCK if blocking would deadlock. Gone thru the
8a54ed337392872c7cfcfb96f173468bbbb0f7fcvboxsync * motions.
e562a8bb17c0dfa1c316708e085a3a92fcc80521vboxsync * @retval VERR_SEM_LV_NESTED if the semaphore isn't recursive and hThread is
e562a8bb17c0dfa1c316708e085a3a92fcc80521vboxsync * already the owner. Gone thru the motions.
8a54ed337392872c7cfcfb96f173468bbbb0f7fcvboxsync * @retval VERR_SEM_LV_ILLEGAL_UPGRADE if it's a deadlock on the same lock.
8a54ed337392872c7cfcfb96f173468bbbb0f7fcvboxsync * The caller must handle any legal upgrades without invoking this
8a54ed337392872c7cfcfb96f173468bbbb0f7fcvboxsync * function (for now).
8a54ed337392872c7cfcfb96f173468bbbb0f7fcvboxsync * @retval VERR_SEM_LV_INVALID_PARAMETER if the input is invalid.
648b0a0e189323afe4d836f1848f82c7dded0e58vboxsync *
63787aca0a2a16ec959a5294148726ccf898ddf1vboxsync * @param pRec The validator record we're blocking on.
e562a8bb17c0dfa1c316708e085a3a92fcc80521vboxsync * @param hThreadSelf The current thread. Shall not be NIL_RTTHREAD!
8a54ed337392872c7cfcfb96f173468bbbb0f7fcvboxsync * @param pSrcPos The source position of the lock operation.
8a54ed337392872c7cfcfb96f173468bbbb0f7fcvboxsync * @param fRecursiveOk Whether it's ok to recurse.
8a54ed337392872c7cfcfb96f173468bbbb0f7fcvboxsync * @param enmSleepState The sleep state to enter on successful return.
8a54ed337392872c7cfcfb96f173468bbbb0f7fcvboxsync * @param fReallySleeping Is it really going to sleep now or not. Use
648b0a0e189323afe4d836f1848f82c7dded0e58vboxsync * false before calls to other IPRT synchronization
63787aca0a2a16ec959a5294148726ccf898ddf1vboxsync * methods.
e562a8bb17c0dfa1c316708e085a3a92fcc80521vboxsync */
8a54ed337392872c7cfcfb96f173468bbbb0f7fcvboxsyncRTDECL(int) RTLockValidatorRecSharedCheckBlocking(PRTLOCKVALRECSHRD pRec, RTTHREAD hThreadSelf,
8a54ed337392872c7cfcfb96f173468bbbb0f7fcvboxsync PCRTLOCKVALSRCPOS pSrcPos, bool fRecursiveOk, RTMSINTERVAL cMillies,
8a54ed337392872c7cfcfb96f173468bbbb0f7fcvboxsync RTTHREADSTATE enmSleepState, bool fReallySleeping);
8a54ed337392872c7cfcfb96f173468bbbb0f7fcvboxsync
648b0a0e189323afe4d836f1848f82c7dded0e58vboxsync/**
8a54ed337392872c7cfcfb96f173468bbbb0f7fcvboxsync * RTLockValidatorRecSharedCheckOrder and RTLockValidatorRecSharedCheckBlocking
e562a8bb17c0dfa1c316708e085a3a92fcc80521vboxsync * baked into one call.
8a54ed337392872c7cfcfb96f173468bbbb0f7fcvboxsync *
8a54ed337392872c7cfcfb96f173468bbbb0f7fcvboxsync * @returns Any of the statuses returned by the two APIs.
8a54ed337392872c7cfcfb96f173468bbbb0f7fcvboxsync * @param pRec The validator record.
8a54ed337392872c7cfcfb96f173468bbbb0f7fcvboxsync * @param hThreadSelf The current thread. Shall not be NIL_RTTHREAD!
648b0a0e189323afe4d836f1848f82c7dded0e58vboxsync * @param pSrcPos The source position of the lock operation.
8a54ed337392872c7cfcfb96f173468bbbb0f7fcvboxsync * @param fRecursiveOk Whether it's ok to recurse.
e562a8bb17c0dfa1c316708e085a3a92fcc80521vboxsync * @param enmSleepState The sleep state to enter on successful return.
8a54ed337392872c7cfcfb96f173468bbbb0f7fcvboxsync * @param fReallySleeping Is it really going to sleep now or not. Use
8a54ed337392872c7cfcfb96f173468bbbb0f7fcvboxsync * false before calls to other IPRT synchronization
8a54ed337392872c7cfcfb96f173468bbbb0f7fcvboxsync * methods.
8a54ed337392872c7cfcfb96f173468bbbb0f7fcvboxsync */
8a54ed337392872c7cfcfb96f173468bbbb0f7fcvboxsyncRTDECL(int) RTLockValidatorRecSharedCheckOrderAndBlocking(PRTLOCKVALRECSHRD pRec, RTTHREAD hThreadSelf,
8a54ed337392872c7cfcfb96f173468bbbb0f7fcvboxsync PCRTLOCKVALSRCPOS pSrcPos, bool fRecursiveOk, RTMSINTERVAL cMillies,
648b0a0e189323afe4d836f1848f82c7dded0e58vboxsync RTTHREADSTATE enmSleepState, bool fReallySleeping);
e562a8bb17c0dfa1c316708e085a3a92fcc80521vboxsync
8a54ed337392872c7cfcfb96f173468bbbb0f7fcvboxsync/**
8a54ed337392872c7cfcfb96f173468bbbb0f7fcvboxsync * Removes all current owners and makes hThread the only owner.
8a54ed337392872c7cfcfb96f173468bbbb0f7fcvboxsync *
8a54ed337392872c7cfcfb96f173468bbbb0f7fcvboxsync * @param pRec The validator record.
8a54ed337392872c7cfcfb96f173468bbbb0f7fcvboxsync * @param hThread The thread handle of the owner. NIL_RTTHREAD is
e562a8bb17c0dfa1c316708e085a3a92fcc80521vboxsync * an alias for the current thread.
e562a8bb17c0dfa1c316708e085a3a92fcc80521vboxsync * @param pSrcPos The source position of the lock operation.
e562a8bb17c0dfa1c316708e085a3a92fcc80521vboxsync */
8a54ed337392872c7cfcfb96f173468bbbb0f7fcvboxsyncRTDECL(void) RTLockValidatorRecSharedResetOwner(PRTLOCKVALRECSHRD pRec, RTTHREAD hThread, PCRTLOCKVALSRCPOS pSrcPos);
8a54ed337392872c7cfcfb96f173468bbbb0f7fcvboxsync
8a54ed337392872c7cfcfb96f173468bbbb0f7fcvboxsync/**
8a54ed337392872c7cfcfb96f173468bbbb0f7fcvboxsync * Adds an owner to a shared locking record.
8a54ed337392872c7cfcfb96f173468bbbb0f7fcvboxsync *
8a54ed337392872c7cfcfb96f173468bbbb0f7fcvboxsync * Takes recursion into account. This function is typically called after
8a54ed337392872c7cfcfb96f173468bbbb0f7fcvboxsync * acquiring the lock in shared mode.
8a54ed337392872c7cfcfb96f173468bbbb0f7fcvboxsync *
648b0a0e189323afe4d836f1848f82c7dded0e58vboxsync * @param pRec The validator record.
8a54ed337392872c7cfcfb96f173468bbbb0f7fcvboxsync * @param hThread The thread handle of the owner. NIL_RTTHREAD is
e562a8bb17c0dfa1c316708e085a3a92fcc80521vboxsync * an alias for the current thread.
e562a8bb17c0dfa1c316708e085a3a92fcc80521vboxsync * @param pSrcPos The source position of the lock operation.
8a54ed337392872c7cfcfb96f173468bbbb0f7fcvboxsync */
8a54ed337392872c7cfcfb96f173468bbbb0f7fcvboxsyncRTDECL(void) RTLockValidatorRecSharedAddOwner(PRTLOCKVALRECSHRD pRec, RTTHREAD hThread, PCRTLOCKVALSRCPOS pSrcPos);
8a54ed337392872c7cfcfb96f173468bbbb0f7fcvboxsync
8a54ed337392872c7cfcfb96f173468bbbb0f7fcvboxsync/**
8a54ed337392872c7cfcfb96f173468bbbb0f7fcvboxsync * Removes an owner from a shared locking record.
8a54ed337392872c7cfcfb96f173468bbbb0f7fcvboxsync *
8a54ed337392872c7cfcfb96f173468bbbb0f7fcvboxsync * Takes recursion into account. This function is typically called before
8a54ed337392872c7cfcfb96f173468bbbb0f7fcvboxsync * releaseing the lock.
8a54ed337392872c7cfcfb96f173468bbbb0f7fcvboxsync *
8a54ed337392872c7cfcfb96f173468bbbb0f7fcvboxsync * @param pRec The validator record.
8a54ed337392872c7cfcfb96f173468bbbb0f7fcvboxsync * @param hThread The thread handle of the owner. NIL_RTTHREAD is
8a54ed337392872c7cfcfb96f173468bbbb0f7fcvboxsync * an alias for the current thread.
8a54ed337392872c7cfcfb96f173468bbbb0f7fcvboxsync */
3ebd5757516d21eccdad25ddd456d2913c2fb215vboxsyncRTDECL(void) RTLockValidatorRecSharedRemoveOwner(PRTLOCKVALRECSHRD pRec, RTTHREAD hThread);
3ebd5757516d21eccdad25ddd456d2913c2fb215vboxsync
3ebd5757516d21eccdad25ddd456d2913c2fb215vboxsync/**
3ebd5757516d21eccdad25ddd456d2913c2fb215vboxsync * Check the exit order and release (unset) the shared ownership.
3ebd5757516d21eccdad25ddd456d2913c2fb215vboxsync *
3ebd5757516d21eccdad25ddd456d2913c2fb215vboxsync * This is called by routines implementing releasing the read/write lock.
3ebd5757516d21eccdad25ddd456d2913c2fb215vboxsync *
3ebd5757516d21eccdad25ddd456d2913c2fb215vboxsync * @retval VINF_SUCCESS on success.
e562a8bb17c0dfa1c316708e085a3a92fcc80521vboxsync * @retval VERR_SEM_LV_WRONG_RELEASE_ORDER if the order is wrong. Will have
e562a8bb17c0dfa1c316708e085a3a92fcc80521vboxsync * done all necessary whining and breakpointing before returning.
e562a8bb17c0dfa1c316708e085a3a92fcc80521vboxsync * @retval VERR_SEM_LV_INVALID_PARAMETER if the input is invalid.
3ebd5757516d21eccdad25ddd456d2913c2fb215vboxsync *
3ebd5757516d21eccdad25ddd456d2913c2fb215vboxsync * @param pRec The validator record.
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync * @param hThreadSelf The handle of the calling thread. NIL_RTTHREAD
e562a8bb17c0dfa1c316708e085a3a92fcc80521vboxsync * is an alias for the current thread.
e562a8bb17c0dfa1c316708e085a3a92fcc80521vboxsync */
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsyncRTDECL(int) RTLockValidatorRecSharedCheckAndRelease(PRTLOCKVALRECSHRD pRec, RTTHREAD hThreadSelf);
3ebd5757516d21eccdad25ddd456d2913c2fb215vboxsync
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync/**
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync * Check the signaller of an event.
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync *
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync * This is called by routines implementing releasing the event sempahore (both
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync * kinds).
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync *
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync * @retval VINF_SUCCESS on success.
b2bc8de1367ae24e1b27b53921d0b32ee3df7acdvboxsync * @retval VERR_SEM_LV_NOT_SIGNALLER if the thread is not in the record. Will
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync * have done all necessary whining and breakpointing before returning.
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync * @retval VERR_SEM_LV_INVALID_PARAMETER if the input is invalid.
648b0a0e189323afe4d836f1848f82c7dded0e58vboxsync *
b2bc8de1367ae24e1b27b53921d0b32ee3df7acdvboxsync * @param pRec The validator record.
3ebd5757516d21eccdad25ddd456d2913c2fb215vboxsync * @param hThreadSelf The handle of the calling thread. NIL_RTTHREAD
3614117c1132a61599e6190939e775cafe549411vboxsync * is an alias for the current thread.
034f0367d3b0431c6346b1a3af3abb435ee50d4evboxsync */
3614117c1132a61599e6190939e775cafe549411vboxsyncRTDECL(int) RTLockValidatorRecSharedCheckSignaller(PRTLOCKVALRECSHRD pRec, RTTHREAD hThreadSelf);
3614117c1132a61599e6190939e775cafe549411vboxsync
3614117c1132a61599e6190939e775cafe549411vboxsync/**
3ebd5757516d21eccdad25ddd456d2913c2fb215vboxsync * Gets the number of write locks and critical sections the specified
3ebd5757516d21eccdad25ddd456d2913c2fb215vboxsync * thread owns.
3ebd5757516d21eccdad25ddd456d2913c2fb215vboxsync *
3ebd5757516d21eccdad25ddd456d2913c2fb215vboxsync * This number does not include any nested lock/critect entries.
3ebd5757516d21eccdad25ddd456d2913c2fb215vboxsync *
3ebd5757516d21eccdad25ddd456d2913c2fb215vboxsync * Note that it probably will return 0 for non-strict builds since
3ebd5757516d21eccdad25ddd456d2913c2fb215vboxsync * release builds doesn't do unnecessary diagnostic counting like this.
648b0a0e189323afe4d836f1848f82c7dded0e58vboxsync *
3ebd5757516d21eccdad25ddd456d2913c2fb215vboxsync * @returns Number of locks on success (0+) and VERR_INVALID_HANDLER on failure
e562a8bb17c0dfa1c316708e085a3a92fcc80521vboxsync * @param Thread The thread we're inquiring about.
e562a8bb17c0dfa1c316708e085a3a92fcc80521vboxsync * @remarks Will only work for strict builds.
e562a8bb17c0dfa1c316708e085a3a92fcc80521vboxsync */
e562a8bb17c0dfa1c316708e085a3a92fcc80521vboxsyncRTDECL(int32_t) RTLockValidatorWriteLockGetCount(RTTHREAD Thread);
3ebd5757516d21eccdad25ddd456d2913c2fb215vboxsync
3ebd5757516d21eccdad25ddd456d2913c2fb215vboxsync/**
3ebd5757516d21eccdad25ddd456d2913c2fb215vboxsync * Works the THREADINT::cWriteLocks member, mostly internal.
3ebd5757516d21eccdad25ddd456d2913c2fb215vboxsync *
63787aca0a2a16ec959a5294148726ccf898ddf1vboxsync * @param Thread The current thread.
3ebd5757516d21eccdad25ddd456d2913c2fb215vboxsync */
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsyncRTDECL(void) RTLockValidatorWriteLockInc(RTTHREAD Thread);
3ebd5757516d21eccdad25ddd456d2913c2fb215vboxsync
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync/**
fe554d9c0e3a6de4ba221610ac95a44c7d288e01vboxsync * Works the THREADINT::cWriteLocks member, mostly internal.
b2bc8de1367ae24e1b27b53921d0b32ee3df7acdvboxsync *
63e3a547845f7c31bb4e892a66684b560dc63611vboxsync * @param Thread The current thread.
7c48fdac0546978ed14617c8096734ce2d18c8e5vboxsync */
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsyncRTDECL(void) RTLockValidatorWriteLockDec(RTTHREAD Thread);
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync
3ebd5757516d21eccdad25ddd456d2913c2fb215vboxsync/**
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync * Gets the number of read locks the specified thread owns.
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync *
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync * Note that nesting read lock entry will be included in the
63e3a547845f7c31bb4e892a66684b560dc63611vboxsync * total sum. And that it probably will return 0 for non-strict
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync * builds since release builds doesn't do unnecessary diagnostic
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync * counting like this.
e562a8bb17c0dfa1c316708e085a3a92fcc80521vboxsync *
e562a8bb17c0dfa1c316708e085a3a92fcc80521vboxsync * @returns Number of read locks on success (0+) and VERR_INVALID_HANDLER on failure
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync * @param Thread The thread we're inquiring about.
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync */
b2bc8de1367ae24e1b27b53921d0b32ee3df7acdvboxsyncRTDECL(int32_t) RTLockValidatorReadLockGetCount(RTTHREAD Thread);
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync/**
648b0a0e189323afe4d836f1848f82c7dded0e58vboxsync * Works the THREADINT::cReadLocks member.
3ebd5757516d21eccdad25ddd456d2913c2fb215vboxsync *
762a68c2bb3ccde807330e3d1cb05f8b244a5f72vboxsync * @param Thread The current thread.
b2bc8de1367ae24e1b27b53921d0b32ee3df7acdvboxsync */
3ebd5757516d21eccdad25ddd456d2913c2fb215vboxsyncRTDECL(void) RTLockValidatorReadLockInc(RTTHREAD Thread);
e562a8bb17c0dfa1c316708e085a3a92fcc80521vboxsync
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync/**
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync * Works the THREADINT::cReadLocks member.
b2bc8de1367ae24e1b27b53921d0b32ee3df7acdvboxsync *
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync * @param Thread The current thread.
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync */
648b0a0e189323afe4d836f1848f82c7dded0e58vboxsyncRTDECL(void) RTLockValidatorReadLockDec(RTTHREAD Thread);
3ebd5757516d21eccdad25ddd456d2913c2fb215vboxsync
3ebd5757516d21eccdad25ddd456d2913c2fb215vboxsync/**
3ebd5757516d21eccdad25ddd456d2913c2fb215vboxsync * Query which lock the specified thread is waiting on.
e562a8bb17c0dfa1c316708e085a3a92fcc80521vboxsync *
ac6445a70a26cb69d08734f1d9dbc171cec86cd8vboxsync * @returns The lock handle value or NULL.
ac6445a70a26cb69d08734f1d9dbc171cec86cd8vboxsync * @param hThread The thread in question.
b2bc8de1367ae24e1b27b53921d0b32ee3df7acdvboxsync */
ac6445a70a26cb69d08734f1d9dbc171cec86cd8vboxsyncRTDECL(void *) RTLockValidatorQueryBlocking(RTTHREAD hThread);
ac6445a70a26cb69d08734f1d9dbc171cec86cd8vboxsync
3ebd5757516d21eccdad25ddd456d2913c2fb215vboxsync/**
3ebd5757516d21eccdad25ddd456d2913c2fb215vboxsync * Checks if the thread is running in the lock validator after it has entered a
3ebd5757516d21eccdad25ddd456d2913c2fb215vboxsync * block state.
3ebd5757516d21eccdad25ddd456d2913c2fb215vboxsync *
3ebd5757516d21eccdad25ddd456d2913c2fb215vboxsync * @returns true if it is, false if it isn't.
3ebd5757516d21eccdad25ddd456d2913c2fb215vboxsync * @param hThread The thread in question.
3ebd5757516d21eccdad25ddd456d2913c2fb215vboxsync */
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsyncRTDECL(bool) RTLockValidatorIsBlockedThreadInValidator(RTTHREAD hThread);
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync
b2bc8de1367ae24e1b27b53921d0b32ee3df7acdvboxsync
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync/**
648b0a0e189323afe4d836f1848f82c7dded0e58vboxsync * Creates a new lock validator class, all properties specified.
3ebd5757516d21eccdad25ddd456d2913c2fb215vboxsync *
3ebd5757516d21eccdad25ddd456d2913c2fb215vboxsync * @returns IPRT status code
e562a8bb17c0dfa1c316708e085a3a92fcc80521vboxsync * @param phClass Where to return the class handle.
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync * @param pSrcPos The source position of the create call.
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync * @param fAutodidact Whether the class should be allowed to teach
b2bc8de1367ae24e1b27b53921d0b32ee3df7acdvboxsync * itself new locking order rules (true), or if the
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync * user will teach it all it needs to know (false).
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync * @param fRecursionOk Whether to allow lock recursion or not.
648b0a0e189323afe4d836f1848f82c7dded0e58vboxsync * @param fStrictReleaseOrder Enforce strict lock release order or not.
3ebd5757516d21eccdad25ddd456d2913c2fb215vboxsync * @param cMsMinDeadlock Used to raise the sleep interval at which
3ebd5757516d21eccdad25ddd456d2913c2fb215vboxsync * deadlock detection kicks in. Minimum is 1 ms,
e562a8bb17c0dfa1c316708e085a3a92fcc80521vboxsync * while RT_INDEFINITE_WAIT will disable it.
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync * @param cMsMinOrder Used to raise the sleep interval at which lock
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync * order validation kicks in. Minimum is 1 ms,
b2bc8de1367ae24e1b27b53921d0b32ee3df7acdvboxsync * while RT_INDEFINITE_WAIT will disable it.
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync * @param pszNameFmt Class name format string, optional (NULL). Max
e562a8bb17c0dfa1c316708e085a3a92fcc80521vboxsync * length is 32 bytes.
e562a8bb17c0dfa1c316708e085a3a92fcc80521vboxsync * @param ... Format string arguments.
e562a8bb17c0dfa1c316708e085a3a92fcc80521vboxsync *
e562a8bb17c0dfa1c316708e085a3a92fcc80521vboxsync * @remarks The properties can be modified after creation by the
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync * RTLockValidatorClassSet* methods.
e562a8bb17c0dfa1c316708e085a3a92fcc80521vboxsync */
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsyncRTDECL(int) RTLockValidatorClassCreateEx(PRTLOCKVALCLASS phClass, PCRTLOCKVALSRCPOS pSrcPos,
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync bool fAutodidact, bool fRecursionOk, bool fStrictReleaseOrder,
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync RTMSINTERVAL cMsMinDeadlock, RTMSINTERVAL cMsMinOrder,
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync const char *pszNameFmt, ...);
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync
3ebd5757516d21eccdad25ddd456d2913c2fb215vboxsync/**
3ebd5757516d21eccdad25ddd456d2913c2fb215vboxsync * Creates a new lock validator class, all properties specified.
3ebd5757516d21eccdad25ddd456d2913c2fb215vboxsync *
3ebd5757516d21eccdad25ddd456d2913c2fb215vboxsync * @returns IPRT status code
3ebd5757516d21eccdad25ddd456d2913c2fb215vboxsync * @param phClass Where to return the class handle.
3ebd5757516d21eccdad25ddd456d2913c2fb215vboxsync * @param pSrcPos The source position of the create call.
3ebd5757516d21eccdad25ddd456d2913c2fb215vboxsync * @param fAutodidact Whether the class should be allowed to teach
3ebd5757516d21eccdad25ddd456d2913c2fb215vboxsync * itself new locking order rules (true), or if the
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync * user will teach it all it needs to know (false).
3ebd5757516d21eccdad25ddd456d2913c2fb215vboxsync * @param fRecursionOk Whether to allow lock recursion or not.
3ebd5757516d21eccdad25ddd456d2913c2fb215vboxsync * @param fStrictReleaseOrder Enforce strict lock release order or not.
f7f5cd7b1e530eb5636da51c974b48ae0c1775b3vboxsync * @param cMsMinDeadlock Used to raise the sleep interval at which
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync * deadlock detection kicks in. Minimum is 1 ms,
3ebd5757516d21eccdad25ddd456d2913c2fb215vboxsync * while RT_INDEFINITE_WAIT will disable it.
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync * @param cMsMinOrder Used to raise the sleep interval at which lock
3ebd5757516d21eccdad25ddd456d2913c2fb215vboxsync * order validation kicks in. Minimum is 1 ms,
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync * while RT_INDEFINITE_WAIT will disable it.
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync * @param pszNameFmt Class name format string, optional (NULL). Max
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync * length is 32 bytes.
3ebd5757516d21eccdad25ddd456d2913c2fb215vboxsync * @param va Format string arguments.
e562a8bb17c0dfa1c316708e085a3a92fcc80521vboxsync *
648b0a0e189323afe4d836f1848f82c7dded0e58vboxsync * @remarks The properties can be modified after creation by the
3ebd5757516d21eccdad25ddd456d2913c2fb215vboxsync * RTLockValidatorClassSet* methods.
3ebd5757516d21eccdad25ddd456d2913c2fb215vboxsync */
3ebd5757516d21eccdad25ddd456d2913c2fb215vboxsyncRTDECL(int) RTLockValidatorClassCreateExV(PRTLOCKVALCLASS phClass, PCRTLOCKVALSRCPOS pSrcPos,
3ebd5757516d21eccdad25ddd456d2913c2fb215vboxsync bool fAutodidact, bool fRecursionOk, bool fStrictReleaseOrder,
e562a8bb17c0dfa1c316708e085a3a92fcc80521vboxsync RTMSINTERVAL cMsMinDeadlock, RTMSINTERVAL cMsMinOrder,
e562a8bb17c0dfa1c316708e085a3a92fcc80521vboxsync const char *pszNameFmt, va_list va);
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync
3ebd5757516d21eccdad25ddd456d2913c2fb215vboxsync/**
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync * Creates a new lock validator class.
3ebd5757516d21eccdad25ddd456d2913c2fb215vboxsync *
ac6445a70a26cb69d08734f1d9dbc171cec86cd8vboxsync * @returns IPRT status code
ac6445a70a26cb69d08734f1d9dbc171cec86cd8vboxsync * @param phClass Where to return the class handle.
3ebd5757516d21eccdad25ddd456d2913c2fb215vboxsync * @param fAutodidact Whether the class should be allowed to teach
3ebd5757516d21eccdad25ddd456d2913c2fb215vboxsync * itself new locking order rules (true), or if the
7697e43970d863558b6c168a55e8948ccb18d8d1vboxsync * user will teach it all it needs to know (false).
3ebd5757516d21eccdad25ddd456d2913c2fb215vboxsync * @param pszFile The source position of the call, file.
3ebd5757516d21eccdad25ddd456d2913c2fb215vboxsync * @param iLine The source position of the call, line.
3ebd5757516d21eccdad25ddd456d2913c2fb215vboxsync * @param pszFunction The source position of the call, function.
ac6445a70a26cb69d08734f1d9dbc171cec86cd8vboxsync * @param pszNameFmt Class name format string, optional (NULL). Max
3ebd5757516d21eccdad25ddd456d2913c2fb215vboxsync * length is 32 bytes.
3ebd5757516d21eccdad25ddd456d2913c2fb215vboxsync * @param ... Format string arguments.
3ebd5757516d21eccdad25ddd456d2913c2fb215vboxsync */
3ebd5757516d21eccdad25ddd456d2913c2fb215vboxsyncRTDECL(int) RTLockValidatorClassCreate(PRTLOCKVALCLASS phClass, bool fAutodidact, RT_SRC_POS_DECL, const char *pszNameFmt, ...);
ac6445a70a26cb69d08734f1d9dbc171cec86cd8vboxsync
3ebd5757516d21eccdad25ddd456d2913c2fb215vboxsync/**
3ebd5757516d21eccdad25ddd456d2913c2fb215vboxsync * Finds a class for the specified source position.
648b0a0e189323afe4d836f1848f82c7dded0e58vboxsync *
e562a8bb17c0dfa1c316708e085a3a92fcc80521vboxsync * @returns A handle to the class (not retained!) or NIL_RTLOCKVALCLASS.
e562a8bb17c0dfa1c316708e085a3a92fcc80521vboxsync * @param pSrcPos The source position.
e562a8bb17c0dfa1c316708e085a3a92fcc80521vboxsync */
e562a8bb17c0dfa1c316708e085a3a92fcc80521vboxsyncRTDECL(RTLOCKVALCLASS) RTLockValidatorClassFindForSrcPos(PRTLOCKVALSRCPOS pSrcPos);
e562a8bb17c0dfa1c316708e085a3a92fcc80521vboxsync
ac6445a70a26cb69d08734f1d9dbc171cec86cd8vboxsync/**
ac6445a70a26cb69d08734f1d9dbc171cec86cd8vboxsync * Finds or creates a class given the source position.
ac6445a70a26cb69d08734f1d9dbc171cec86cd8vboxsync *
648b0a0e189323afe4d836f1848f82c7dded0e58vboxsync * @returns Class handle (not retained!) or NIL_RTLOCKVALCLASS.
e562a8bb17c0dfa1c316708e085a3a92fcc80521vboxsync * @param pszFile The source file.
e562a8bb17c0dfa1c316708e085a3a92fcc80521vboxsync * @param iLine The line in that source file.
e562a8bb17c0dfa1c316708e085a3a92fcc80521vboxsync * @param pszFunction The function name.
e562a8bb17c0dfa1c316708e085a3a92fcc80521vboxsync * @param pszNameFmt Class name format string, optional (NULL). Max
e562a8bb17c0dfa1c316708e085a3a92fcc80521vboxsync * length is 32 bytes.
e562a8bb17c0dfa1c316708e085a3a92fcc80521vboxsync * @param ... Format string arguments.
e562a8bb17c0dfa1c316708e085a3a92fcc80521vboxsync */
e562a8bb17c0dfa1c316708e085a3a92fcc80521vboxsyncRTDECL(RTLOCKVALCLASS) RTLockValidatorClassForSrcPos(RT_SRC_POS_DECL, const char *pszNameFmt, ...);
e562a8bb17c0dfa1c316708e085a3a92fcc80521vboxsync
e562a8bb17c0dfa1c316708e085a3a92fcc80521vboxsync/**
e562a8bb17c0dfa1c316708e085a3a92fcc80521vboxsync * Retains a reference to a lock validator class.
e562a8bb17c0dfa1c316708e085a3a92fcc80521vboxsync *
e562a8bb17c0dfa1c316708e085a3a92fcc80521vboxsync * @returns New reference count; UINT32_MAX if the handle is invalid.
e562a8bb17c0dfa1c316708e085a3a92fcc80521vboxsync * @param hClass Handle to the class.
e562a8bb17c0dfa1c316708e085a3a92fcc80521vboxsync */
e562a8bb17c0dfa1c316708e085a3a92fcc80521vboxsyncRTDECL(uint32_t) RTLockValidatorClassRetain(RTLOCKVALCLASS hClass);
ac6445a70a26cb69d08734f1d9dbc171cec86cd8vboxsync
ac6445a70a26cb69d08734f1d9dbc171cec86cd8vboxsync/**
ac6445a70a26cb69d08734f1d9dbc171cec86cd8vboxsync * Releases a reference to a lock validator class.
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync *
3ebd5757516d21eccdad25ddd456d2913c2fb215vboxsync * @returns New reference count. 0 if hClass is NIL_RTLOCKVALCLASS. UINT32_MAX
3ebd5757516d21eccdad25ddd456d2913c2fb215vboxsync * if the handle is invalid.
3ebd5757516d21eccdad25ddd456d2913c2fb215vboxsync * @param hClass Handle to the class.
3ebd5757516d21eccdad25ddd456d2913c2fb215vboxsync */
3ebd5757516d21eccdad25ddd456d2913c2fb215vboxsyncRTDECL(uint32_t) RTLockValidatorClassRelease(RTLOCKVALCLASS hClass);
3ebd5757516d21eccdad25ddd456d2913c2fb215vboxsync
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync/**
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync * Teaches the class @a hClass that locks in the class @a hPriorClass can be
009d969fa3276b108ddb99a9c1a7a26c003438a7vboxsync * held when taking a lock of class @hClass
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync *
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync * @returns IPRT status.
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync * @param hClass Handle to the pupil class.
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync * @param hPriorClass Handle to the class that can be held prior to
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync * taking a lock in the pupil class. (No reference
3ebd5757516d21eccdad25ddd456d2913c2fb215vboxsync * is consumed.)
3ebd5757516d21eccdad25ddd456d2913c2fb215vboxsync */
3ebd5757516d21eccdad25ddd456d2913c2fb215vboxsyncRTDECL(int) RTLockValidatorClassAddPriorClass(RTLOCKVALCLASS hClass, RTLOCKVALCLASS hPriorClass);
3ebd5757516d21eccdad25ddd456d2913c2fb215vboxsync
6826c1a65f586b47c2abbbabab801950c9a0bb75vboxsync/**
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync * Enables or disables the strict release order enforcing.
b2bc8de1367ae24e1b27b53921d0b32ee3df7acdvboxsync *
3ebd5757516d21eccdad25ddd456d2913c2fb215vboxsync * @returns IPRT status.
3ebd5757516d21eccdad25ddd456d2913c2fb215vboxsync * @param hClass Handle to the class to change.
3ebd5757516d21eccdad25ddd456d2913c2fb215vboxsync * @param fEnable Enable it (true) or disable it (false).
f7f5cd7b1e530eb5636da51c974b48ae0c1775b3vboxsync */
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsyncRTDECL(int) RTLockValidatorClassEnforceStrictReleaseOrder(RTLOCKVALCLASS hClass, bool fEnabled);
3ebd5757516d21eccdad25ddd456d2913c2fb215vboxsync
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync/**
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync * Enables / disables the lock validator for new locks.
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync *
3ebd5757516d21eccdad25ddd456d2913c2fb215vboxsync * @returns The old setting.
762a68c2bb3ccde807330e3d1cb05f8b244a5f72vboxsync * @param fEnabled The new setting.
3ebd5757516d21eccdad25ddd456d2913c2fb215vboxsync */
3ebd5757516d21eccdad25ddd456d2913c2fb215vboxsyncRTDECL(bool) RTLockValidatorSetEnabled(bool fEnabled);
3ebd5757516d21eccdad25ddd456d2913c2fb215vboxsync
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync/**
3ebd5757516d21eccdad25ddd456d2913c2fb215vboxsync * Is the lock validator enabled?
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync *
b2bc8de1367ae24e1b27b53921d0b32ee3df7acdvboxsync * @returns True if enabled, false if not.
ac6445a70a26cb69d08734f1d9dbc171cec86cd8vboxsync */
ac6445a70a26cb69d08734f1d9dbc171cec86cd8vboxsyncRTDECL(bool) RTLockValidatorIsEnabled(void);
3ebd5757516d21eccdad25ddd456d2913c2fb215vboxsync
3ebd5757516d21eccdad25ddd456d2913c2fb215vboxsync/**
ac6445a70a26cb69d08734f1d9dbc171cec86cd8vboxsync * Controls whether the lock validator should be quiet or noisy (default).
3ebd5757516d21eccdad25ddd456d2913c2fb215vboxsync *
ac6445a70a26cb69d08734f1d9dbc171cec86cd8vboxsync * @returns The old setting.
ac6445a70a26cb69d08734f1d9dbc171cec86cd8vboxsync * @param fQuiet The new setting.
b2bc8de1367ae24e1b27b53921d0b32ee3df7acdvboxsync */
3ebd5757516d21eccdad25ddd456d2913c2fb215vboxsyncRTDECL(bool) RTLockValidatorSetQuiet(bool fQuiet);
648b0a0e189323afe4d836f1848f82c7dded0e58vboxsync
3ebd5757516d21eccdad25ddd456d2913c2fb215vboxsync/**
3ebd5757516d21eccdad25ddd456d2913c2fb215vboxsync * Is the lock validator quiet or noisy?
3ebd5757516d21eccdad25ddd456d2913c2fb215vboxsync *
ac6445a70a26cb69d08734f1d9dbc171cec86cd8vboxsync * @returns True if it is quiet, false if noisy.
3ebd5757516d21eccdad25ddd456d2913c2fb215vboxsync */
3ebd5757516d21eccdad25ddd456d2913c2fb215vboxsyncRTDECL(bool) RTLockValidatorIsQuiet(void);
3ebd5757516d21eccdad25ddd456d2913c2fb215vboxsync
3ebd5757516d21eccdad25ddd456d2913c2fb215vboxsync/**
b2bc8de1367ae24e1b27b53921d0b32ee3df7acdvboxsync * Makes the lock validator panic (default) or not.
3ebd5757516d21eccdad25ddd456d2913c2fb215vboxsync *
ac6445a70a26cb69d08734f1d9dbc171cec86cd8vboxsync * @returns The old setting.
ac6445a70a26cb69d08734f1d9dbc171cec86cd8vboxsync * @param fPanic The new setting.
ac6445a70a26cb69d08734f1d9dbc171cec86cd8vboxsync */
3ebd5757516d21eccdad25ddd456d2913c2fb215vboxsyncRTDECL(bool) RTLockValidatorSetMayPanic(bool fPanic);
b2bc8de1367ae24e1b27b53921d0b32ee3df7acdvboxsync
3ebd5757516d21eccdad25ddd456d2913c2fb215vboxsync/**
ac6445a70a26cb69d08734f1d9dbc171cec86cd8vboxsync * Can the lock validator cause panic.
e562a8bb17c0dfa1c316708e085a3a92fcc80521vboxsync *
ac6445a70a26cb69d08734f1d9dbc171cec86cd8vboxsync * @returns True if it can, false if not.
ac6445a70a26cb69d08734f1d9dbc171cec86cd8vboxsync */
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsyncRTDECL(bool) RTLockValidatorMayPanic(void);
3ebd5757516d21eccdad25ddd456d2913c2fb215vboxsync
3ebd5757516d21eccdad25ddd456d2913c2fb215vboxsync
3ebd5757516d21eccdad25ddd456d2913c2fb215vboxsyncRT_C_DECLS_END
3ebd5757516d21eccdad25ddd456d2913c2fb215vboxsync
3ebd5757516d21eccdad25ddd456d2913c2fb215vboxsync/** @} */
3ebd5757516d21eccdad25ddd456d2913c2fb215vboxsync
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync#endif
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync
b2bc8de1367ae24e1b27b53921d0b32ee3df7acdvboxsync