PDMAllCritSect.cpp revision 78c4607fa52a68fbe9a396cd8795ed05f3e1ef40
/* $Id$ */
/** @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"
#ifdef IN_RING3
# include <iprt/semaphore.h>
#endif
/**
* Leaves a critical section entered with PDMCritSectEnter().
*
* @returns VINF_SUCCESS if entered successfully.
* @returns VERR_SEM_DESTROYED if the critical section is dead.
*
* @param pCritSect The PDM critical section to enter.
* @param rcBusy The status code to return when we're in GC or R0
* and the section is busy.
*/
{
#ifdef IN_RING3
STAM_STATS({ if (pCritSect->s.Core.cLockers >= 0 && !RTCritSectIsOwner(&pCritSect->s.Core)) STAM_COUNTER_INC(&pCritSect->s.StatContentionR3); });
STAM_STATS({ if (pCritSect->s.Core.cNestings == 1) STAM_PROFILE_ADV_START(&pCritSect->s.StatLocked, l); });
return rc;
#else
AssertMsgReturn(pCritSect->s.Core.u32Magic == RTCRITSECT_MAGIC, ("%RX32\n", pCritSect->s.Core.u32Magic),
/*
* Try take the lock.
*/
{
return VINF_SUCCESS;
}
/*
* Nested?
*/
{
return VINF_SUCCESS;
}
/*
* Failed.
*/
return rcBusy;
#endif
}
/**
* Leaves a critical section entered with PDMCritSectEnter().
*
* @param pCritSect The PDM critical section to leave.
*/
{
#ifdef IN_RING3
# ifdef VBOX_WITH_STATISTICS
# endif
{
}
else
{
}
#else /* !IN_RING3 */
/*
* Deal with nested attempts first.
* (We're exploiting nesting to avoid queuing multiple R3 leaves for the same section.)
*/
{
return;
}
/*
* Try leave it.
*/
{
return;
/* darn, someone raced in on us. */
}
/*
* Queue the request.
*/
#endif
}
/**
* Checks the caller is the owner of the critical section.
*
* @returns true if owner.
* @returns false if not owner.
* @param pCritSect The critical section.
*/
{
#ifdef IN_RING3
#else
#endif
}