Exemplo n.º 1
0
void CrstBase::PostEnter()
{
    if (g_pThreadStore->IsCrstForThreadStore(this))
        return;
    
    Thread* pThread = GetThread();
    if (pThread)
    {
        if (!m_heldInSuspension)
            m_ulReadyForSuspensionCount =
                pThread->GetReadyForSuspensionCount();
        if (!m_enterInCoopGCMode)
            m_enterInCoopGCMode = pThread->PreemptiveGCDisabled();
    }
}
Exemplo n.º 2
0
void SpinLock::dbg_EnterLock()
{
    Thread  *pThread = GetThread();
	if (pThread)
	{
        if (!m_heldInSuspension)
            m_ulReadyForSuspensionCount =
                pThread->GetReadyForSuspensionCount();
        if (!m_enterInCoopGCMode)
            m_enterInCoopGCMode = (pThread->PreemptiveGCDisabled() == TRUE);
	}
	else
	{
		_ASSERTE(g_fProcessDetach == TRUE || dbgOnly_IsSpecialEEThread());
	}
}
Exemplo n.º 3
0
void SpinLock::dbg_LeaveLock()
{
    Thread  *pThread = GetThread();
	if (pThread)
	{
        if (!m_heldInSuspension &&
            m_ulReadyForSuspensionCount !=
            pThread->GetReadyForSuspensionCount())
        {
            m_heldInSuspension = TRUE;
        }
        if (m_heldInSuspension && m_enterInCoopGCMode)
        {
            _ASSERTE (!"Deadlock situation 2: lock may be held during GC, but were not entered in PreemptiveGC mode earlier");
        }
	}
	else
	{
		_ASSERTE(g_fProcessDetach == TRUE || dbgOnly_IsSpecialEEThread());
	}
}
Exemplo n.º 4
0
void CrstBase::PreLeave()
{
    if (g_pThreadStore->IsCrstForThreadStore(this))
        return;
    
    Thread* pThread = GetThread();
    if (pThread)
    {
        if (!m_heldInSuspension &&
            m_ulReadyForSuspensionCount !=
            pThread->GetReadyForSuspensionCount())
        {
            m_heldInSuspension = TRUE;
        }
        if (m_heldInSuspension && m_enterInCoopGCMode)
        {
            // The GC thread calls into the handle table to scan handles.  Sometimes
            // the GC thread is a random application thread that is provoking a GC.
            // Sometimes the GC thread is a secret GC thread (server or concurrent).
            // This can happen if a DllMain notification executes managed code, as in
            // an IJW scenario.  In the case of the secret thread, we will take this
            // lock in preemptive mode.
            //
            // Normally this would be a dangerous combination.  But, in the case of
            // this particular Crst, we only ever take the critical section on a thread
            // which is identified as the GC thread and which is therefore not subject
            // to GC suspensions.
            //
            // The easiest way to handle this is to weaken the assert for this precise
            // case.  The alternative would be to have a notion of locks that are
            // only ever taken by threads identified as the GC thread.
            if (m_crstlevel != CrstHandleTable ||
                pThread != g_pGCHeap->GetGCThread())
            {
                _ASSERTE (!"Deadlock situation 2: lock may be held during GC, but were not entered in PreemptiveGC mode earlier");
            }
        }
    }
}