VirtualBox

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

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

iprt/lockvalidator: Record recursion on the lock stack.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 4.4 KB
Line 
1/* $Id: lockvalidator.h 25690 2010-01-08 13:20:15Z vboxsync $ */
2/** @file
3 * IPRT - Internal RTLockValidator header.
4 */
5
6/*
7 * Copyright (C) 2006-2009 Sun Microsystems, Inc.
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 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
27 * Clara, CA 95054 USA or visit http://www.sun.com if you need
28 * additional information or have any questions.
29 */
30
31#ifndef ___iprt_internal_lockvalidator_h
32#define ___iprt_internal_lockvalidator_h
33
34#include <iprt/types.h>
35#include <iprt/lockvalidator.h>
36#include "internal/lockvalidator.h"
37
38RT_C_DECLS_BEGIN
39
40
41/**
42 * Record used only on the lock stack for recording the stack and source
43 * position of a recursive lock acquisition.
44 */
45typedef struct RTLOCKVALRECNEST
46{
47 RTLOCKVALRECCORE Core;
48 /** The recursion level at this point in the stack. */
49 uint32_t cRecursion;
50 /** Pointer to the next record on the stack. */
51 PRTLOCKVALRECUNION volatile pDown;
52 /** Pointer to the first recursion. */
53 PRTLOCKVALRECUNION volatile pRec;
54 /** Pointer to the next free record when in the
55 * RTLOCKVALPERTHREAD::pFreeNestRecs list. */
56 struct RTLOCKVALRECNEST *pNextFree;
57 /** The source position. */
58 RTLOCKVALSRCPOS SrcPos;
59} RTLOCKVALRECNEST;
60/** Pointer to a recursion record. */
61typedef RTLOCKVALRECNEST *PRTLOCKVALRECNEST;
62
63
64/**
65 * Record union for simplifying internal processing.
66 */
67typedef union RTLOCKVALRECUNION
68{
69 RTLOCKVALRECCORE Core;
70 RTLOCKVALRECEXCL Excl;
71 RTLOCKVALRECSHRD Shared;
72 RTLOCKVALRECSHRDOWN ShrdOwner;
73 RTLOCKVALRECNEST Nest;
74} RTLOCKVALRECUNION;
75
76
77/**
78 * Per thread data for the lock validator.
79 *
80 * This is part of the RTTHREADINT structure.
81 */
82typedef struct RTLOCKVALPERTHREAD
83{
84 /** Where we are blocking. */
85 RTLOCKVALSRCPOS SrcPos;
86 /** Top of the lock stack. */
87 PRTLOCKVALRECUNION volatile pStackTop;
88 /** List of free recursion (nesting) record. */
89 PRTLOCKVALRECNEST pFreeNestRecs;
90 /** What we're blocking on.
91 * The lock validator sets this, RTThreadUnblock clears it. */
92 PRTLOCKVALRECUNION volatile pRec;
93 /** The state in which pRec that goes with pRec.
94 * RTThreadUnblocking uses this to figure out when to clear pRec. */
95 RTTHREADSTATE volatile enmRecState;
96 /** The thread is running inside the lock validator. */
97 bool volatile fInValidator;
98 /** Reserved for alignment purposes. */
99 bool afReserved[3];
100 /** Number of registered write locks, mutexes and critsects that this thread owns. */
101 int32_t volatile cWriteLocks;
102 /** Number of registered read locks that this thread owns, nesting included. */
103 int32_t volatile cReadLocks;
104 /** Bitmap indicating which entires are free (set) and allocated (clear). */
105 uint32_t volatile bmFreeShrdOwners;
106 /** Reserved for alignment purposes. */
107 uint32_t u32Reserved;
108 /** Statically allocated shared owner records */
109 RTLOCKVALRECSHRDOWN aShrdOwners[32];
110} RTLOCKVALPERTHREAD;
111
112
113DECLHIDDEN(void) rtLockValidatorInitPerThread(RTLOCKVALPERTHREAD *pPerThread);
114DECLHIDDEN(void) rtLockValidatorDeletePerThread(RTLOCKVALPERTHREAD *pPerThread);
115DECLHIDDEN(void) rtLockValidatorSerializeDestructEnter(void);
116DECLHIDDEN(void) rtLockValidatorSerializeDestructLeave(void);
117
118RT_C_DECLS_END
119
120#endif
121
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