PDMCritSect.cpp revision 9ad5e3912962c3dbccc1afc4e7d62890fe906814
/* $Id$ */
/** @file
* PDM - Critical Sections, Ring-3.
*/
/*
* Copyright (C) 2006-2007 Sun Microsystems, Inc.
*
* 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 (GPL) 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.
*
* Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
* Clara, CA 95054 USA or visit http://www.sun.com if you need
* additional information or have any questions.
*/
/*******************************************************************************
* 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->StatContentionRZLock, STAMTYPE_COUNTER, STAMVISIBILITY_ALWAYS, STAMUNIT_OCCURENCES, NULL, "/PDM/CritSects/%s/ContentionRZLock", pszName);
STAMR3RegisterF(pVM, &pCritSect->StatContentionRZUnlock,STAMTYPE_COUNTER, STAMVISIBILITY_ALWAYS, STAMUNIT_OCCURENCES, NULL, "/PDM/CritSects/%s/ContentionRZUnlock", 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).
*/
{
#endif
}
/**
* 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++)
{
}
}
/**
* Try enter a critical section.
*
* @returns VINF_SUCCESS on success.
* @returns VERR_SEM_BUSY if the critsect was owned.
* @returns VERR_SEM_NESTED if nested enter on a no nesting section. (Asserted.)
* @returns VERR_SEM_DESTROYED if RTCritSectDelete was called while waiting.
* @param pCritSect The critical section.
*/
{
}
/**
* Schedule a event semaphore for signalling upon critsect exit.
*
* @returns VINF_SUCCESS on success.
* @returns VERR_TOO_MANY_SEMAPHORES if an event was already scheduled.
* @returns VERR_NOT_OWNER if we're not the critsect owner.
* @returns VERR_SEM_DESTROYED if RTCritSectDelete was called while waiting.
* @param pCritSect The critical section.
* @param EventToSignal The semapore that should be signalled.
*/
{
return VERR_NOT_OWNER;
{
return VINF_SUCCESS;
}
return VERR_TOO_MANY_SEMAPHORES;
}