PDMCritSect.cpp revision 677833bc953b6cb418c701facbdcf4aa18d6c44e
/** @file
*
* PDM Critical Sections
*/
/*
* Copyright (C) 2006 InnoTek Systemberatung GmbH
*
* This file is part of VirtualBox Open Source Edition (OSE), as
* available from http://www.virtualbox.org. This file is free software;
* General Public License as published by the Free Software Foundation,
* in version 2 as it comes in the "COPYING" file of the VirtualBox OSE
* distribution. VirtualBox OSE is distributed in the hope that it will
* be useful, but WITHOUT ANY WARRANTY of any kind.
*
* If you received this file as part of a commercial VirtualBox
* distribution, then only the terms of your commercial VirtualBox
* license agreement apply instead of the previous paragraph.
*/
/*******************************************************************************
* Header Files *
*******************************************************************************/
#include "PDMInternal.h"
/*******************************************************************************
* Internal Functions *
*******************************************************************************/
static int pdmR3CritSectDeleteOne(PVM pVM, PPDMCRITSECTINT pCritSect, PPDMCRITSECTINT pPrev, bool fFinal);
/**
* Initializes the critical section subcomponent.
*
* @returns VBox status code.
* @param pVM The VM handle.
* @remark Not to be confused with PDMR3CritSectInit and pdmR3CritSectInitDevice which are
* for initializing a critical section.
*/
{
STAM_REG(pVM, &pVM->pdm.s.StatQueuedCritSectLeaves, STAMTYPE_COUNTER, "/PDM/QueuedCritSectLeaves", STAMUNIT_OCCURENCES,
"Number of times a critical section leave requesed needed to be queued for ring-3 execution.");
return VINF_SUCCESS;
}
/**
* Relocates all the critical sections.
*
* @param pVM The VM handle.
*/
{
pCur;
}
/**
* Deletes all remaining critical sections.
*
* This is called at the end of the termination process.
*
* @returns VBox status.
* First error code, rest is lost.
* @param pVM The VM handle.
* @remark Don't confuse this with PDMR3CritSectDelete.
*/
{
int rc = VINF_SUCCESS;
{
}
return rc;
}
/**
* Initalizes a critical section and inserts it into the list.
*
* @returns VBox status code.
* @param pVM The Vm handle.
* @param pCritSect The critical section.
* @param pvKey The owner key.
* @param pszName The name of the critical section (for statistics).
*/
static int pdmR3CritSectInitOne(PVM pVM, PPDMCRITSECTINT pCritSect, void *pvKey, const char *pszName)
{
if (VBOX_SUCCESS(rc))
{
#ifdef VBOX_WITH_STATISTICS
STAMR3RegisterF(pVM, &pCritSect->StatContentionR0GCLock, STAMTYPE_COUNTER, STAMVISIBILITY_ALWAYS, STAMUNIT_OCCURENCES, NULL, "/PDM/CritSects/%s/ContentionR0GCLock", pszName);
STAMR3RegisterF(pVM, &pCritSect->StatContentionR0GCUnlock, STAMTYPE_COUNTER, STAMVISIBILITY_ALWAYS, STAMUNIT_OCCURENCES, NULL, "/PDM/CritSects/%s/ContentionR0GCUnlock", pszName);
STAMR3RegisterF(pVM, &pCritSect->StatContentionR3, STAMTYPE_COUNTER, STAMVISIBILITY_ALWAYS, STAMUNIT_OCCURENCES, NULL, "/PDM/CritSects/%s/ContentionR3", pszName);
STAMR3RegisterF(pVM, &pCritSect->StatLocked, STAMTYPE_PROFILE_ADV, STAMVISIBILITY_ALWAYS, STAMUNIT_TICKS_PER_OCCURENCE, NULL, "/PDM/CritSects/%s/Locked", pszName);
#endif
}
return rc;
}
/**
* Initializes a PDM critical section for internal use.
*
* The PDM critical sections are derived from the IPRT critical sections, but
* works in GC as well.
*
* @returns VBox status code.
* @param pVM The VM handle.
* @param pDevIns Device instance.
* @param pCritSect Pointer to the critical section.
* @param pszName The name of the critical section (for statistics).
*/
{
}
/**
* Initializes a PDM critical section.
*
* The PDM critical sections are derived from the IPRT critical sections, but
* works in GC as well.
*
* @returns VBox status code.
* @param pVM The VM handle.
* @param pDevIns Device instance.
* @param pCritSect Pointer to the critical section.
* @param pszName The name of the critical section (for statistics).
*/
int pdmR3CritSectInitDevice(PVM pVM, PPDMDEVINS pDevIns, PPDMCRITSECT pCritSect, const char *pszName)
{
}
/**
* Deletes one critical section.
*
* @returns Return code from RTCritSectDelete.
* @param pVM The VM handle.
* @param pCritSect The critical section.
* @param pPrev The previous critical section in the list.
* @param fFinal Set if this is the final call and statistics shouldn't be deregistered.
*/
static int pdmR3CritSectDeleteOne(PVM pVM, PPDMCRITSECTINT pCritSect, PPDMCRITSECTINT pPrev, bool fFinal)
{
/* ulink */
if (pPrev)
else
/* delete */
#ifdef VBOX_WITH_STATISTICS
if (!fFinal)
{
}
#endif
}
/**
* Deletes all critical sections with a give initializer key.
*
* @returns VBox status code.
* The entire list is processed on failure, so we'll only
* return the first error code. This shouldn't be a problem
* since errors really shouldn't happen here.
* @param pVM The VM handle.
* @param pvKey The initializer key.
*/
{
/*
* Iterate the list and match key.
*/
int rc = VINF_SUCCESS;
while (pCur)
{
{
}
/* next */
}
return rc;
}
/**
* Deletes all undeleted critical sections initalized by a given device.
*
* @returns VBox status code.
* @param pVM The VM handle.
* @param pDevIns The device handle.
*/
{
}
/**
* Deletes the critical section.
*
* @returns VBox status code.
* @param pCritSect The PDM critical section to destroy.
*/
{
return VINF_SUCCESS;
/*
* Find and unlink it.
*/
while (pCur)
{
/* next */
}
return VERR_INTERNAL_ERROR;
}
/**
* Process the critical sections queued for ring-3 'leave'.
*
* @param pVM The VM handle.
*/
{
for (RTUINT i = 0; i < c; i++)
{
}
}