diff options
author | Aditya Mandaleeka <adityamandaleeka@users.noreply.github.com> | 2017-03-13 18:53:34 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-03-13 18:53:34 -0700 |
commit | 2ca9cec2d982162ab4f43d1136d0c67de57387cc (patch) | |
tree | bf029aa37634aa672edc77bf7388f348f15abd45 /src/utilcode | |
parent | 3f18c89f25cccbd21e794942aeb5fbada458bb62 (diff) | |
parent | ec723a53d7a098cf5b5455f3a248bc1d3269a954 (diff) | |
download | coreclr-2ca9cec2d982162ab4f43d1136d0c67de57387cc.tar.gz coreclr-2ca9cec2d982162ab4f43d1136d0c67de57387cc.tar.bz2 coreclr-2ca9cec2d982162ab4f43d1136d0c67de57387cc.zip |
Merge pull request #10153 from adityamandaleeka/remove_stress_thread
Remove STRESS_THREAD
Diffstat (limited to 'src/utilcode')
-rw-r--r-- | src/utilcode/CMakeLists.txt | 1 | ||||
-rw-r--r-- | src/utilcode/apithreadstress.cpp | 183 |
2 files changed, 0 insertions, 184 deletions
diff --git a/src/utilcode/CMakeLists.txt b/src/utilcode/CMakeLists.txt index 7c396732a1..27b7a4a006 100644 --- a/src/utilcode/CMakeLists.txt +++ b/src/utilcode/CMakeLists.txt @@ -28,7 +28,6 @@ set(UTILCODE_COMMON_SOURCES peinformation.cpp check.cpp log.cpp - apithreadstress.cpp arraylist.cpp bitvector.cpp comex.cpp diff --git a/src/utilcode/apithreadstress.cpp b/src/utilcode/apithreadstress.cpp deleted file mode 100644 index 88b09fe006..0000000000 --- a/src/utilcode/apithreadstress.cpp +++ /dev/null @@ -1,183 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -// --------------------------------------------------------------------------- -// APIThreadStress.cpp (API thread stresser) -// --------------------------------------------------------------------------- - -#include "stdafx.h" - -#ifdef STRESS_THREAD - -#include "apithreadstress.h" -#include "clrhost.h" -#include "ex.h" -#include "log.h" - - - -// For now, thread stress is incompatible with hosting. We need a host CreateThread -// to fix this. -#undef SetEvent -#undef ResetEvent - -int APIThreadStress::s_threadStressCount = 0; - -APIThreadStress::APIThreadStress() -{ - WRAPPER_NO_CONTRACT; - - m_threadCount = 0; - - // Don't "fork" stress threads - if (ClrFlsGetValue(TlsIdx_StressThread) == NULL) - m_threadCount = s_threadStressCount; - - if (m_threadCount != 0) - { - m_setupOK = TRUE; - - m_hThreadArray = new (nothrow) HANDLE [ m_threadCount ]; - if (m_hThreadArray == NULL) - m_setupOK = FALSE; - else - { - HANDLE *p = m_hThreadArray; - HANDLE *pEnd = p + m_threadCount; - - while (p < pEnd) - { - DWORD id; - *p = ::CreateThread(NULL, 0, StartThread, this, 0, &id); - if (*p == NULL) - m_setupOK = FALSE; - p++; - } - } - - m_syncEvent = ClrCreateManualEvent(FALSE); - if (m_syncEvent == INVALID_HANDLE_VALUE) - m_setupOK = FALSE; - } -} - -APIThreadStress::~APIThreadStress() -{ - WRAPPER_NO_CONTRACT; - - if (m_threadCount > 0) - { - HANDLE *p = m_hThreadArray; - HANDLE *pEnd = p + m_threadCount; - - if (p != NULL) - { - while (p < pEnd) - { - if (*p != NULL) - { - if (m_threadCount > 0 && m_setupOK) - WaitForSingleObjectEx(*p, INFINITE, FALSE); - - ::CloseHandle(*p); - } - p++; - } - delete [] m_hThreadArray; - } - - if (m_syncEvent != INVALID_HANDLE_VALUE) - CloseHandle(m_syncEvent); - } -} - -void APIThreadStress::SetThreadStressCount(int threadCount) -{ - LIMITED_METHOD_CONTRACT; - - s_threadStressCount = threadCount; -} - - -DWORD WINAPI APIThreadStress::StartThread(void *arg) -{ - WRAPPER_NO_CONTRACT; - STATIC_CONTRACT_SO_NOT_MAINLINE; // not mainline so scenario - - APIThreadStress *pThis = (APIThreadStress *) arg; - - ClrFlsSetValue(TlsIdx_StressThread, pThis); - - EX_TRY - { - // Perform initial synchronization - WaitForSingleObjectEx(pThis->m_syncEvent, INFINITE, FALSE); - InterlockedIncrement(&pThis->m_runCount); - - LOG((LF_ALL, LL_INFO100, "Stressing operation on thread %d\n", GetCurrentThreadId())); - ((APIThreadStress *)arg)->Invoke(); - LOG((LF_ALL, LL_INFO100, "End stress operation on thread %d\n", GetCurrentThreadId())); - - if (InterlockedDecrement(&pThis->m_runCount) == 0) - ::SetEvent(pThis->m_syncEvent); - } - EX_CATCH - { - LOG((LF_ALL, LL_ERROR, "Exception during stress operation on thread %d\n", GetCurrentThreadId())); - } - EX_END_CATCH(SwallowAllExceptions); - - return 0; -} - -BOOL APIThreadStress::DoThreadStress() -{ - WRAPPER_NO_CONTRACT; - - if (m_threadCount > 0 && m_setupOK) - { - HANDLE *p = m_hThreadArray; - HANDLE *pEnd = p + m_threadCount; - - while (p < pEnd) - { - ::ResumeThread(*p); - p++; - } - - // Start the threads at the same time - ::SetEvent(m_syncEvent); - - return TRUE; - } - else - { - SyncThreadStress(); - return FALSE; - } -} - -void APIThreadStress::SyncThreadStress() -{ - WRAPPER_NO_CONTRACT; - - APIThreadStress *pThis = (APIThreadStress *) ClrFlsGetValue(TlsIdx_StressThread); - - if (pThis != NULL) - { - LOG((LF_ALL, LL_INFO1000, "Syncing stress operation on thread %d\n", GetCurrentThreadId())); - - ::ResetEvent(pThis->m_syncEvent); - - if (InterlockedDecrement(&pThis->m_runCount) == 0) - ::SetEvent(pThis->m_syncEvent); - else - WaitForSingleObjectEx(pThis->m_syncEvent, INFINITE, FALSE); - InterlockedIncrement(&pThis->m_runCount); - - LOG((LF_ALL, LL_INFO1000, "Resuming stress operation on thread %d\n", GetCurrentThreadId())); - } -} - -#endif // STRESS_THREAD |