Skip to content
This repository was archived by the owner on Jan 23, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 2 additions & 9 deletions src/debug/daccess/dacdbiimpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5452,15 +5452,8 @@ CorDebugUserState DacDbiInterfaceImpl::GetPartialUserState(VMPTR_Thread vmThread
result |= USER_WAIT_SLEEP_JOIN;
}

// Don't report a SuspendRequested if the thread has actually Suspended.
if ((ts & Thread::TS_UserSuspendPending) && (ts & Thread::TS_SyncSuspended))
{
result |= USER_SUSPENDED;
}
else if (ts & Thread::TS_UserSuspendPending)
{
result |= USER_SUSPEND_REQUESTED;
}
// CoreCLR does not support user-requested thread suspension
_ASSERTE(!(ts & Thread::TS_UserSuspendPending));

if (pThread->IsThreadPoolThread())
{
Expand Down
6 changes: 6 additions & 0 deletions src/inc/clrconfigvalues.h
Original file line number Diff line number Diff line change
Expand Up @@ -936,6 +936,12 @@ CONFIG_DWORD_INFO(INTERNAL_SuspendDeadlockTimeout, W("SuspendDeadlockTimeout"),
CONFIG_DWORD_INFO(INTERNAL_SuspendThreadDeadlockTimeoutMs, W("SuspendThreadDeadlockTimeoutMs"), 2000, "")
RETAIL_CONFIG_DWORD_INFO(INTERNAL_ThreadSuspendInjection, W("INTERNAL_ThreadSuspendInjection"), 1, "Specifies whether to inject activations for thread suspension on Unix")

//
// Thread (miscellaneous)
//
RETAIL_CONFIG_DWORD_INFO(INTERNAL_Thread_DeadThreadCountThresholdForGCTrigger, W("Thread_DeadThreadCountThresholdForGCTrigger"), 75, "In the heuristics to clean up dead threads, this threshold must be reached before triggering a GC will be considered. Set to 0 to disable triggering a GC based on dead threads.")
RETAIL_CONFIG_DWORD_INFO(INTERNAL_Thread_DeadThreadGCTriggerPeriodMilliseconds, W("Thread_DeadThreadGCTriggerPeriodMilliseconds"), 1000 * 60 * 30, "In the heuristics to clean up dead threads, this much time must have elapsed since the previous max-generation GC before triggering another GC will be considered")

//
// Threadpool
//
Expand Down
14 changes: 2 additions & 12 deletions src/vm/comsynchronizable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -926,18 +926,8 @@ FCIMPL1(INT32, ThreadNative::GetThreadState, ThreadBaseObject* pThisUNSAFE)
if (state & Thread::TS_Interruptible)
res |= ThreadWaitSleepJoin;

// Don't report a SuspendRequested if the thread has actually Suspended.
if ((state & Thread::TS_UserSuspendPending) &&
(state & Thread::TS_SyncSuspended)
)
{
res |= ThreadSuspended;
}
else
if (state & Thread::TS_UserSuspendPending)
{
res |= ThreadSuspendRequested;
}
// CoreCLR does not support user-requested thread suspension
_ASSERTE(!(state & Thread::TS_UserSuspendPending));

HELPER_METHOD_POLL();
HELPER_METHOD_FRAME_END();
Expand Down
58 changes: 2 additions & 56 deletions src/vm/debugdebugger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -937,62 +937,8 @@ void DebugStackTrace::GetStackFramesHelper(Frame *pStartFrame,
goto LSafeToTrace;
}

if (state & Thread::TS_UserSuspendPending)
{
if (state & Thread::TS_SyncSuspended)
{
goto LSafeToTrace;
}

#ifndef DISABLE_THREADSUSPEND
// On Mac don't perform the optimization below, but rather wait for
// the suspendee to set the TS_SyncSuspended flag

// The target thread is not actually suspended yet, but if it is
// in preemptive mode, then it is still safe to trace. Before we
// can look at another thread's GC mode, we have to suspend it:
// The target thread updates its GC mode flag with non-interlocked
// operations, and Thread::SuspendThread drains the CPU's store
// buffer (by virtue of calling GetThreadContext).
switch (pThread->SuspendThread())
{
case Thread::STR_Success:
if (!pThread->PreemptiveGCDisabledOther())
{
pThread->ResumeThread();
goto LSafeToTrace;
}

// Refuse to trace the stack.
//
// Note that there is a pretty large window in-between when the
// target thread sets the GC mode to cooperative, and when it
// actually sets the TS_SyncSuspended bit. In this window, we
// will refuse to take a stack trace even though it would be
// safe to do so.
pThread->ResumeThread();
break;
case Thread::STR_Failure:
case Thread::STR_NoStressLog:
break;
case Thread::STR_UnstartedOrDead:
// We know the thread is not unstarted, because we checked for
// TS_Unstarted above.
_ASSERTE(!(state & Thread::TS_Unstarted));

// Since the thread is dead, it is safe to trace.
goto LSafeToTrace;
case Thread::STR_SwitchedOut:
if (!pThread->PreemptiveGCDisabledOther())
{
goto LSafeToTrace;
}
break;
default:
UNREACHABLE();
}
#endif // DISABLE_THREADSUSPEND
}
// CoreCLR does not support user-requested thread suspension
_ASSERTE(!(state & Thread::TS_UserSuspendPending));

COMPlusThrow(kThreadStateException, IDS_EE_THREAD_BAD_STATE);

Expand Down
11 changes: 2 additions & 9 deletions src/vm/eedbginterfaceimpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1588,15 +1588,8 @@ CorDebugUserState EEDbgInterfaceImpl::GetPartialUserState(Thread *pThread)
ret |= (unsigned)USER_WAIT_SLEEP_JOIN;
}

// Don't report a SuspendRequested if the thread has actually Suspended.
if ( ((ts & Thread::TS_UserSuspendPending) && (ts & Thread::TS_SyncSuspended)))
{
ret |= (unsigned)USER_SUSPENDED;
}
else if (ts & Thread::TS_UserSuspendPending)
{
ret |= (unsigned)USER_SUSPEND_REQUESTED;
}
// CoreCLR does not support user-requested thread suspension
_ASSERTE(!(ts & Thread::TS_UserSuspendPending));

LOG((LF_CORDB,LL_INFO1000, "EEDbgII::GUS: thread 0x%x (id:0x%x)"
" userThreadState is 0x%x\n", pThread, pThread->GetThreadId(), ret));
Expand Down
2 changes: 2 additions & 0 deletions src/vm/finalizerthread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1345,6 +1345,8 @@ BOOL FinalizerThread::FinalizerThreadWatchDogHelper()
}
ULONGLONG dwCurTickCount = CLRGetTickCount64();
if (pThread && pThread->m_State & (Thread::TS_UserSuspendPending | Thread::TS_DebugSuspendPending)) {
// CoreCLR does not support user-requested thread suspension
_ASSERTE(!(pThread->m_State & Thread::TS_UserSuspendPending));
dwBeginTickCount = dwCurTickCount;
}
if (dwCurTickCount - dwBeginTickCount >= maxTotalWait)
Expand Down
5 changes: 5 additions & 0 deletions src/vm/gcenv.ee.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -626,6 +626,11 @@ void GCToEEInterface::GcStartWork (int condemned, int max_gen)
//
RCWWalker::OnGCStarted(condemned);
#endif // FEATURE_COMINTEROP

if (condemned == max_gen)
{
ThreadStore::s_pThreadStore->OnMaxGenerationGCStarted();
}
}

void GCToEEInterface::GcDone(int condemned)
Expand Down
Loading