BOOL InitFusionCriticalSections()
{
    WRAPPER_CONTRACT;
    BOOL fRet = FALSE;

    g_csInitClb = ClrCreateCriticalSection("Fusion: Comp Lib (global)", CrstFusionClb, CRST_REENTRANCY);
    if (!g_csInitClb) {
        goto Exit;
    }

    g_csDownload = ClrCreateCriticalSection("Fusion: Download (global)", CrstFusionDownload, CRST_REENTRANCY);
    if (!g_csDownload) {
        goto Exit;
    }

    g_csBindLog = ClrCreateCriticalSection("Fusion: Bind Log (global)", CrstFusionLog, CRST_DEFAULT);
    if (!g_csBindLog) {
        goto Exit;
    }

    g_csSingleUse = ClrCreateCriticalSection("Fusion: Single Use (global)", CrstFusionSingleUse, CRST_DEFAULT);
    if (!g_csSingleUse) {
        goto Exit;
    }

    g_csConfigSettings = ClrCreateCriticalSection("Fusion: Config Settings (global)", CrstFusionConfigSettings, CRST_DEFAULT);
    if (!g_csConfigSettings) {
        goto Exit;
    }

    fRet = TRUE;
    
Exit:
    return fRet;
}
Beispiel #2
0
void StressLog::Initialize(unsigned facilities,  unsigned level, unsigned maxBytesPerThread, 
            unsigned maxBytesTotal, HMODULE hMod) 
{
    STATIC_CONTRACT_LEAF;

    if (theLog.MaxSizePerThread != 0)
    {
        // guard ourself against multiple initialization. First init wins.
        return;
    }
    
    _ASSERTE (theLog.TLSslot == (unsigned int)TLS_OUT_OF_INDEXES);
    theLog.lock = ClrCreateCriticalSection(CrstStressLog,(CrstFlags)(CRST_UNSAFE_ANYMODE|CRST_DEBUGGER_THREAD));
    // StressLog::Terminate is going to free memory.
    if (maxBytesPerThread < STRESSLOG_CHUNK_SIZE)
    {
        maxBytesPerThread = STRESSLOG_CHUNK_SIZE;
    }
    theLog.MaxSizePerThread = maxBytesPerThread;

    if (maxBytesTotal < STRESSLOG_CHUNK_SIZE * 256)
    {
        maxBytesTotal = STRESSLOG_CHUNK_SIZE * 256;
    }
    theLog.MaxSizeTotal = maxBytesTotal;
    theLog.totalChunk = 0;
    theLog.facilitiesToLog = facilities | LF_ALWAYS;
    theLog.levelToLog = level;
    theLog.deadCount = 0;
    theLog.TLSslot = TlsIdx_StressLog;
	
    theLog.tickFrequency = getTickFrequency();
	
    GetSystemTimeAsFileTime (&theLog.startTime);
    theLog.startTimeStamp = getTimeStamp();

#ifndef FEATURE_PAL
    theLog.moduleOffset = (SIZE_T)hMod; // HMODULES are base addresses.

#ifdef _DEBUG
    HMODULE hModNtdll = GetModuleHandleA("ntdll.dll");
    theLog.RtlCaptureStackBackTrace = reinterpret_cast<PFNRtlCaptureStackBackTrace>(
            GetProcAddress(hModNtdll, "RtlCaptureStackBackTrace"));
#endif // _DEBUG

#else // !FEATURE_PAL
    theLog.moduleOffset = (SIZE_T)PAL_GetSymbolModuleBase((void *)StressLog::Initialize);
#endif // !FEATURE_PAL

#if !defined (STRESS_LOG_READONLY)    
    StressLogChunk::s_LogChunkHeap = ClrHeapCreate (0, STRESSLOG_CHUNK_SIZE * 128, 0);
    if (StressLogChunk::s_LogChunkHeap == NULL)
    {
        StressLogChunk::s_LogChunkHeap = ClrGetProcessHeap ();
    }
    _ASSERTE (StressLogChunk::s_LogChunkHeap);
#endif //!STRESS_LOG_READONLY
}
HRESULT CLoadContext::Init()
{
    HRESULT                              hr = S_OK;
    
    _cs = ClrCreateCriticalSection("Fusion: Load Context", CrstFusionLoadContext, (CrstFlags)(CRST_REENTRANCY | CRST_UNSAFE_ANYMODE));
    if (!_cs) {
        hr = E_OUTOFMEMORY;
        goto Exit;
    }

Exit:
    return hr;
}
Beispiel #4
0
BOOL InitFusionCriticalSections()
{
    WRAPPER_NO_CONTRACT;
    BOOL fRet = FALSE;

    g_csInitClb = ClrCreateCriticalSection(CrstFusionClb, CRST_REENTRANCY);
    if (!g_csInitClb) {
        goto Exit;
    }

    g_csDownload = ClrCreateCriticalSection(CrstFusionDownload, CRST_REENTRANCY);
    if (!g_csDownload) {
        goto Exit;
    }

    g_csBindLog = ClrCreateCriticalSection(CrstFusionLog, CRST_DEFAULT);
    if (!g_csBindLog) {
        goto Exit;
    }

    g_csSingleUse = ClrCreateCriticalSection(CrstFusionSingleUse, CRST_DEFAULT);
    if (!g_csSingleUse) {
        goto Exit;
    }

    // <TODO> Get rid of this critical section</TODO>
    g_csConfigSettings = ClrCreateCriticalSection(CrstFusionConfigSettings, CRST_DEFAULT);
    if (!g_csConfigSettings) {
        goto Exit;
    }

    fRet = TRUE;
    
Exit:
    return fRet;
}