VirtualBox

source: vbox/trunk/src/VBox/Runtime/include/internal/lockvalidator.h

Last change on this file was 98103, checked in by vboxsync, 17 months ago

Copyright year updates by scm.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 4.6 KB
RevLine 
[25406]1/* $Id: lockvalidator.h 98103 2023-01-17 14:15:46Z vboxsync $ */
2/** @file
3 * IPRT - Internal RTLockValidator header.
4 */
5
6/*
[98103]7 * Copyright (C) 2006-2023 Oracle and/or its affiliates.
[25406]8 *
[96407]9 * This file is part of VirtualBox base platform packages, as
10 * available from https://www.virtualbox.org.
[25406]11 *
[96407]12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation, in version 3 of the
15 * License.
16 *
17 * This program is distributed in the hope that it will be useful, but
18 * WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20 * General Public License for more details.
21 *
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, see <https://www.gnu.org/licenses>.
24 *
[25406]25 * The contents of this file may alternatively be used under the terms
26 * of the Common Development and Distribution License Version 1.0
[96407]27 * (CDDL), a copy of it is provided in the "COPYING.CDDL" file included
28 * in the VirtualBox distribution, in which case the provisions of the
[25406]29 * CDDL are applicable instead of those of the GPL.
30 *
31 * You may elect to license modified versions of this file under the
32 * terms and conditions of either the GPL or the CDDL or both.
[96407]33 *
34 * SPDX-License-Identifier: GPL-3.0-only OR CDDL-1.0
[25406]35 */
36
[76559]37#ifndef IPRT_INCLUDED_INTERNAL_lockvalidator_h
38#define IPRT_INCLUDED_INTERNAL_lockvalidator_h
[76513]39#ifndef RT_WITHOUT_PRAGMA_ONCE
40# pragma once
41#endif
[25406]42
43#include <iprt/types.h>
44#include <iprt/lockvalidator.h>
45
46RT_C_DECLS_BEGIN
47
[25690]48
[25602]49/**
[25690]50 * Record used only on the lock stack for recording the stack and source
51 * position of a recursive lock acquisition.
52 */
53typedef struct RTLOCKVALRECNEST
54{
55 RTLOCKVALRECCORE Core;
56 /** The recursion level at this point in the stack. */
57 uint32_t cRecursion;
58 /** Pointer to the next record on the stack. */
59 PRTLOCKVALRECUNION volatile pDown;
60 /** Pointer to the first recursion. */
61 PRTLOCKVALRECUNION volatile pRec;
62 /** Pointer to the next free record when in the
63 * RTLOCKVALPERTHREAD::pFreeNestRecs list. */
64 struct RTLOCKVALRECNEST *pNextFree;
65 /** The source position. */
66 RTLOCKVALSRCPOS SrcPos;
67} RTLOCKVALRECNEST;
68/** Pointer to a recursion record. */
69typedef RTLOCKVALRECNEST *PRTLOCKVALRECNEST;
70
71
72/**
[25602]73 * Record union for simplifying internal processing.
74 */
[25607]75typedef union RTLOCKVALRECUNION
[25602]76{
[25690]77 RTLOCKVALRECCORE Core;
78 RTLOCKVALRECEXCL Excl;
79 RTLOCKVALRECSHRD Shared;
80 RTLOCKVALRECSHRDOWN ShrdOwner;
81 RTLOCKVALRECNEST Nest;
[25607]82} RTLOCKVALRECUNION;
[25406]83
[25602]84
[25406]85/**
86 * Per thread data for the lock validator.
87 *
88 * This is part of the RTTHREADINT structure.
89 */
[25611]90typedef struct RTLOCKVALPERTHREAD
[25406]91{
[25611]92 /** Where we are blocking. */
93 RTLOCKVALSRCPOS SrcPos;
[25690]94 /** Top of the lock stack. */
95 PRTLOCKVALRECUNION volatile pStackTop;
96 /** List of free recursion (nesting) record. */
97 PRTLOCKVALRECNEST pFreeNestRecs;
[25648]98 /** What we're blocking on.
99 * The lock validator sets this, RTThreadUnblock clears it. */
[25607]100 PRTLOCKVALRECUNION volatile pRec;
[25648]101 /** The state in which pRec that goes with pRec.
102 * RTThreadUnblocking uses this to figure out when to clear pRec. */
103 RTTHREADSTATE volatile enmRecState;
104 /** The thread is running inside the lock validator. */
105 bool volatile fInValidator;
106 /** Reserved for alignment purposes. */
107 bool afReserved[3];
[25406]108 /** Number of registered write locks, mutexes and critsects that this thread owns. */
[25607]109 int32_t volatile cWriteLocks;
[25406]110 /** Number of registered read locks that this thread owns, nesting included. */
[25607]111 int32_t volatile cReadLocks;
[25611]112 /** Bitmap indicating which entires are free (set) and allocated (clear). */
[25638]113 uint32_t volatile bmFreeShrdOwners;
[25648]114 /** Reserved for alignment purposes. */
115 uint32_t u32Reserved;
[25611]116 /** Statically allocated shared owner records */
117 RTLOCKVALRECSHRDOWN aShrdOwners[32];
118} RTLOCKVALPERTHREAD;
[25406]119
[25436]120
[25611]121DECLHIDDEN(void) rtLockValidatorInitPerThread(RTLOCKVALPERTHREAD *pPerThread);
[25690]122DECLHIDDEN(void) rtLockValidatorDeletePerThread(RTLOCKVALPERTHREAD *pPerThread);
[25436]123DECLHIDDEN(void) rtLockValidatorSerializeDestructEnter(void);
124DECLHIDDEN(void) rtLockValidatorSerializeDestructLeave(void);
125
[25406]126RT_C_DECLS_END
127
[76585]128#endif /* !IPRT_INCLUDED_INTERNAL_lockvalidator_h */
[25406]129
Note: See TracBrowser for help on using the repository browser.

© 2023 Oracle
ContactPrivacy policyTerms of Use