Changeset 12983 in vbox
- Timestamp:
- Oct 4, 2008 10:17:38 PM (16 years ago)
- svn:sync-xref-src-repo-rev:
- 37416
- Location:
- trunk
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/VBox/pdmcritsect.h
r9216 r12983 59 59 typedef const PDMCRITSECT *PCPDMCRITSECT; 60 60 61 /** 62 * Initializes a PDM critical section for internal use. 63 * 64 * The PDM critical sections are derived from the IPRT critical sections, but 65 * works in GC as well. 66 * 67 * @returns VBox status code. 68 * @param pVM The VM handle. 69 * @param pDevIns Device instance. 70 * @param pCritSect Pointer to the critical section. 71 * @param pszName The name of the critical section (for statistics). 72 */ 73 PDMR3DECL(int) PDMR3CritSectInit(PVM pVM, PPDMCRITSECT pCritSect, const char *pszName); 74 75 /** 76 * Enters a PDM critical section. 77 * 78 * @returns VINF_SUCCESS if entered successfully. 79 * @returns rcBusy when encountering a busy critical section in GC/R0. 80 * @returns VERR_SEM_DESTROYED if the critical section is dead. 81 * 82 * @param pCritSect The PDM critical section to enter. 83 * @param rcBusy The status code to return when we're in GC or R0 84 * and the section is busy. 85 */ 86 PDMDECL(int) PDMCritSectEnter(PPDMCRITSECT pCritSect, int rcBusy); 87 88 /** 89 * Enters a PDM critical section. 90 * 91 * @returns VINF_SUCCESS if entered successfully. 92 * @returns rcBusy when encountering a busy critical section in GC/R0. 93 * @returns VERR_SEM_DESTROYED if the critical section is dead. 94 * 95 * @param pCritSect The PDM critical section to enter. 96 * @param fCallHost Whether this is a VMMGCCallHost() or VMMR0CallHost() request. 97 */ 98 PDMR3DECL(int) PDMR3CritSectEnterEx(PPDMCRITSECT pCritSect, bool fCallHost); 99 100 /** 101 * Leaves a critical section entered with PDMCritSectEnter(). 102 * 103 * @param pCritSect The PDM critical section to leave. 104 */ 105 PDMDECL(void) PDMCritSectLeave(PPDMCRITSECT pCritSect); 106 107 /** 108 * Checks the caller is the owner of the critical section. 109 * 110 * @returns true if owner. 111 * @returns false if not owner. 112 * @param pCritSect The critical section. 113 */ 114 PDMDECL(bool) PDMCritSectIsOwner(PCPDMCRITSECT pCritSect); 115 116 /** 117 * Checks if a critical section is initialized or not. 118 * 119 * @returns true if initialized. 120 * @returns false if not initialized. 121 * @param pCritSect The critical section. 122 */ 123 PDMDECL(bool) PDMCritSectIsInitialized(PCPDMCRITSECT pCritSect); 124 125 /** 126 * Try enter a critical section. 127 * 128 * @returns VINF_SUCCESS on success. 129 * @returns VERR_SEM_BUSY if the critsect was owned. 130 * @returns VERR_SEM_NESTED if nested enter on a no nesting section. (Asserted.) 131 * @returns VERR_SEM_DESTROYED if RTCritSectDelete was called while waiting. 132 * @param pCritSect The critical section. 133 */ 134 PDMR3DECL(int) PDMR3CritSectTryEnter(PPDMCRITSECT pCritSect); 135 136 /** 137 * Schedule a event semaphore for signalling upon critsect exit. 138 * 139 * @returns VINF_SUCCESS on success. 140 * @returns VERR_TOO_MANY_SEMAPHORES if an event was already scheduled. 141 * @returns VERR_NOT_OWNER if we're not the critsect owner. 142 * @returns VERR_SEM_DESTROYED if RTCritSectDelete was called while waiting. 143 * @param pCritSect The critical section. 144 * @param EventToSignal The semapore that should be signalled. 145 */ 146 PDMR3DECL(int) PDMR3CritSectScheduleExitEvent(PPDMCRITSECT pCritSect, RTSEMEVENT EventToSignal); 147 148 /** 149 * Deletes the critical section. 150 * 151 * @returns VBox status code. 152 * @param pCritSect The PDM critical section to destroy. 153 */ 154 PDMR3DECL(int) PDMR3CritSectDelete(PPDMCRITSECT pCritSect); 155 156 /** 157 * Deletes all remaining critical sections. 158 * 159 * This is called at the end of the termination process. 160 * 161 * @returns VBox status. 162 * First error code, rest is lost. 163 * @param pVM The VM handle. 164 * @remark Don't confuse this with PDMR3CritSectDelete. 165 */ 166 PDMDECL(int) PDMR3CritSectTerm(PVM pVM); 167 168 /** 169 * Process the critical sections queued for ring-3 'leave'. 170 * 171 * @param pVM The VM handle. 172 */ 61 PDMR3DECL(int) PDMR3CritSectInit(PVM pVM, PPDMCRITSECT pCritSect, const char *pszName); 62 PDMDECL(int) PDMCritSectEnter(PPDMCRITSECT pCritSect, int rcBusy); 63 PDMR3DECL(int) PDMR3CritSectEnterEx(PPDMCRITSECT pCritSect, bool fCallHost); 64 PDMDECL(void) PDMCritSectLeave(PPDMCRITSECT pCritSect); 65 PDMDECL(bool) PDMCritSectIsOwner(PCPDMCRITSECT pCritSect); 66 PDMDECL(bool) PDMCritSectIsInitialized(PCPDMCRITSECT pCritSect); 67 PDMR3DECL(int) PDMR3CritSectTryEnter(PPDMCRITSECT pCritSect); 68 PDMR3DECL(int) PDMR3CritSectScheduleExitEvent(PPDMCRITSECT pCritSect, RTSEMEVENT EventToSignal); 69 PDMR3DECL(int) PDMR3CritSectDelete(PPDMCRITSECT pCritSect); 70 PDMDECL(int) PDMR3CritSectTerm(PVM pVM); 173 71 PDMR3DECL(void) PDMR3CritSectFF(PVM pVM); 174 72 -
trunk/src/VBox/VMM/PDMCritSect.cpp
r9154 r12983 1 1 /* $Id$ */ 2 2 /** @file 3 * PDM Critical Sections3 * PDM - Critical Sections, Ring-3. 4 4 */ 5 5 … … 19 19 * additional information or have any questions. 20 20 */ 21 22 21 23 22 … … 71 70 pCur; 72 71 pCur = pCur->pNext) 73 pCur->pVM GC = pVM->pVMGC;72 pCur->pVMRC = pVM->pVMRC; 74 73 } 75 74 … … 117 116 pCritSect->pVMR3 = pVM; 118 117 pCritSect->pVMR0 = (RTR0PTR)pVM;//pVM->pVMR0; 119 pCritSect->pVM GC = pVM->pVMGC;118 pCritSect->pVMRC = pVM->pVMRC; 120 119 pCritSect->pvKey = pvKey; 121 120 pCritSect->EventToSignal = NIL_RTSEMEVENT; … … 123 122 pVM->pdm.s.pCritSects = pCritSect; 124 123 #ifdef VBOX_WITH_STATISTICS 125 STAMR3RegisterF(pVM, &pCritSect->StatContentionR 0GCLock, STAMTYPE_COUNTER, STAMVISIBILITY_ALWAYS, STAMUNIT_OCCURENCES, NULL, "/PDM/CritSects/%s/ContentionR0GCLock", pszName);126 STAMR3RegisterF(pVM, &pCritSect->StatContentionR 0GCUnlock, STAMTYPE_COUNTER, STAMVISIBILITY_ALWAYS, STAMUNIT_OCCURENCES, NULL, "/PDM/CritSects/%s/ContentionR0GCUnlock", pszName);127 STAMR3RegisterF(pVM, &pCritSect->StatContentionR3, 128 STAMR3RegisterF(pVM, &pCritSect->StatLocked, 124 STAMR3RegisterF(pVM, &pCritSect->StatContentionRZLock, STAMTYPE_COUNTER, STAMVISIBILITY_ALWAYS, STAMUNIT_OCCURENCES, NULL, "/PDM/CritSects/%s/ContentionRZLock", pszName); 125 STAMR3RegisterF(pVM, &pCritSect->StatContentionRZUnlock,STAMTYPE_COUNTER, STAMVISIBILITY_ALWAYS, STAMUNIT_OCCURENCES, NULL, "/PDM/CritSects/%s/ContentionRZUnlock", pszName); 126 STAMR3RegisterF(pVM, &pCritSect->StatContentionR3, STAMTYPE_COUNTER, STAMVISIBILITY_ALWAYS, STAMUNIT_OCCURENCES, NULL, "/PDM/CritSects/%s/ContentionR3", pszName); 127 STAMR3RegisterF(pVM, &pCritSect->StatLocked, STAMTYPE_PROFILE_ADV, STAMVISIBILITY_ALWAYS, STAMUNIT_TICKS_PER_OCCURENCE, NULL, "/PDM/CritSects/%s/Locked", pszName); 129 128 #endif 130 129 } … … 191 190 /* delete */ 192 191 pCritSect->pNext = NULL; 193 pCritSect->p VMGC = 0;192 pCritSect->pvKey = NULL; 194 193 pCritSect->pVMR3 = NULL; 195 194 pCritSect->pVMR0 = NIL_RTR0PTR; 196 pCritSect->p vKey = NULL;195 pCritSect->pVMRC = NIL_RTRCPTR; 197 196 #ifdef VBOX_WITH_STATISTICS 198 197 if (!fFinal) 199 198 { 200 STAMR3Deregister(pVM, &pCritSect->StatContentionR 0GCLock);201 STAMR3Deregister(pVM, &pCritSect->StatContentionR 0GCUnlock);199 STAMR3Deregister(pVM, &pCritSect->StatContentionRZLock); 200 STAMR3Deregister(pVM, &pCritSect->StatContentionRZUnlock); 202 201 STAMR3Deregister(pVM, &pCritSect->StatContentionR3); 203 202 STAMR3Deregister(pVM, &pCritSect->StatLocked); -
trunk/src/VBox/VMM/PDMInternal.h
r12980 r12983 196 196 RTCRITSECT Core; 197 197 /** Pointer to the next critical section. 198 * This chain is used for relocating pVM GC and device cleanup. */198 * This chain is used for relocating pVMRC and device cleanup. */ 199 199 R3PTRTYPE(struct PDMCRITSECTINT *) pNext; 200 200 /** Owner identifier. … … 203 203 RTR3PTR pvKey; 204 204 /** Pointer to the VM - R3Ptr. */ 205 R3PTRTYPE(PVM)pVMR3;205 PVMR3 pVMR3; 206 206 /** Pointer to the VM - R0Ptr. */ 207 R0PTRTYPE(PVM)pVMR0;207 PVMR0 pVMR0; 208 208 /** Pointer to the VM - GCPtr. */ 209 RCPTRTYPE(PVM) pVMGC;209 PVMRC pVMRC; 210 210 #if HC_ARCH_BITS == 64 211 uint32_tpadding;211 RTRCPTR padding; 212 212 #endif 213 213 /** Event semaphore that is scheduled to be signaled upon leaving the 214 214 * critical section. This is Ring-3 only of course. */ 215 215 RTSEMEVENT EventToSignal; 216 /** R0/ GC lock contention. */217 STAMCOUNTER StatContentionR 0GCLock;218 /** R0/ GC unlock contention. */219 STAMCOUNTER StatContentionR 0GCUnlock;216 /** R0/RC lock contention. */ 217 STAMCOUNTER StatContentionRZLock; 218 /** R0/RC unlock contention. */ 219 STAMCOUNTER StatContentionRZUnlock; 220 220 /** R3 lock contention. */ 221 221 STAMCOUNTER StatContentionR3; 222 222 /** Profiling the time the section is locked. */ 223 223 STAMPROFILEADV StatLocked; 224 } PDMCRITSECTINT, *PPDMCRITSECTINT; 224 } PDMCRITSECTINT; 225 typedef PDMCRITSECTINT *PPDMCRITSECTINT; 225 226 226 227 -
trunk/src/VBox/VMM/VMMAll/PDMAllCritSect.cpp
r10204 r12983 1 1 /* $Id$ */ 2 2 /** @file 3 * PDM Critical Sections3 * PDM - Critical Sections, All Contexts. 4 4 */ 5 5 … … 61 61 return rc; 62 62 63 #else 63 #else /* !IN_RING3 */ 64 64 AssertMsgReturn(pCritSect->s.Core.u32Magic == RTCRITSECT_MAGIC, ("%RX32\n", pCritSect->s.Core.u32Magic), 65 65 VERR_SEM_DESTROYED); 66 PVM pVM = pCritSect->s.CTX ALLSUFF(pVM);66 PVM pVM = pCritSect->s.CTX_SUFF(pVM); 67 67 Assert(pVM); 68 68 … … 91 91 * Failed. 92 92 */ 93 LogFlow(("PDMCritSectEnter: locked => HC(%Vrc)\n", rcBusy));94 STAM_COUNTER_INC(&pCritSect->s.StatContentionR 0GCLock);93 LogFlow(("PDMCritSectEnter: locked => R3 (%Vrc)\n", rcBusy)); 94 STAM_COUNTER_INC(&pCritSect->s.StatContentionRZLock); 95 95 return rcBusy; 96 #endif 96 #endif /* !IN_RING3 */ 97 97 } 98 98 … … 157 157 Assert(pCritSect->s.Core.cNestings > 0); 158 158 Assert(pCritSect->s.Core.cLockers >= 0); 159 PVM pVM = pCritSect->s.CTX ALLSUFF(pVM);159 PVM pVM = pCritSect->s.CTX_SUFF(pVM); 160 160 Assert(pVM); 161 161 Assert(pCritSect->s.Core.NativeThreadOwner == pVM->NativeThreadEMT); … … 198 198 VM_FF_SET(pVM, VM_FF_TO_R3); 199 199 STAM_COUNTER_INC(&pVM->pdm.s.StatQueuedCritSectLeaves); 200 STAM_COUNTER_INC(&pCritSect->s.StatContentionR 0GCUnlock);201 #endif 200 STAM_COUNTER_INC(&pCritSect->s.StatContentionRZUnlock); 201 #endif /* !IN_RING3 */ 202 202 } 203 203 … … 215 215 return RTCritSectIsOwner(&pCritSect->s.Core); 216 216 #else 217 PVM pVM = pCritSect->s.CTX ALLSUFF(pVM);217 PVM pVM = pCritSect->s.CTX_SUFF(pVM); 218 218 Assert(pVM); 219 219 return pCritSect->s.Core.NativeThreadOwner == pVM->NativeThreadEMT; -
trunk/src/VBox/VMM/testcase/tstVMStructGC.cpp
r12970 r12983 338 338 GEN_CHECK_OFF(PDMCRITSECTINT, pVMR3); 339 339 GEN_CHECK_OFF(PDMCRITSECTINT, pVMR0); 340 GEN_CHECK_OFF(PDMCRITSECTINT, pVM GC);341 GEN_CHECK_OFF(PDMCRITSECTINT, StatContentionR 0GCLock);342 GEN_CHECK_OFF(PDMCRITSECTINT, StatContentionR 0GCUnlock);340 GEN_CHECK_OFF(PDMCRITSECTINT, pVMRC); 341 GEN_CHECK_OFF(PDMCRITSECTINT, StatContentionRZLock); 342 GEN_CHECK_OFF(PDMCRITSECTINT, StatContentionRZUnlock); 343 343 GEN_CHECK_OFF(PDMCRITSECTINT, StatContentionR3); 344 344 GEN_CHECK_OFF(PDMCRITSECTINT, StatLocked);
Note:
See TracChangeset
for help on using the changeset viewer.