VirtualBox

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

Last change on this file since 76559 was 76559, checked in by vboxsync, 6 years ago

IPRT/include: Use IPRT_INCLUDED_INTERNAL_ rather than _internal_ as header guard prefix, letting scm enforce this.

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

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