2

如何识别负责跨核心上下文切换的线程,以及保持同步的线程?

(PS:我是 Visual Studio 的这一部分的新手……边学习边学习,感谢提示!)

在此处输入图像描述

花费最多时间同步的线程的各种堆栈跟踪,我不知道为什么:

线程 12384

 Category = Synchronization Delay = 650947.5375 ms
 ntoskrnl.exe!SwapContext_PatchXRstor ntoskrnl.exe!KiSwapContext
 ntoskrnl.exe!KiCommitThreadWait ntoskrnl.exe!KeWaitForSingleObject
 ntoskrnl.exe!NtWaitForSingleObject ntoskrnl.exe!KiSystemServiceCopyEnd

线程 8792

 Category = Synchronization API = WaitForMultipleObjects
 Delay = 8993.9801 ms Unblocked by thread 3052; click 'Unblocking
 Stack' for details. kernel32.dll!_WaitForMultipleObjects@16
 clr.dll!WKS::WaitForFinalizerEvent
 clr.dll!WKS::GCHeap::FinalizerThreadWorker
 clr.dll!Thread::DoExtraWorkForFinalizer
 clr.dll!Thread::ShouldChangeAbortToUnload
 clr.dll!Thread::ShouldChangeAbortToUnload
 clr.dll!ManagedThreadBase_NoADTransition
 clr.dll!ManagedThreadBase::FinalizerBase
 clr.dll!WKS::GCHeap::FinalizerThreadStart
 clr.dll!Thread::intermediateThreadProc
 kernel32.dll!@BaseThreadInitThunk@12 ntdll.dll!___RtlUserThreadStart@8
 ntdll.dll!__RtlUserThreadStart@8


 The Unblocking stack for the above is

 Thread 8792 was unblocked by thread 3052 The unblocking call stack
 follows: ntoskrnl.exe! ?? ?? ::FNODOBFM::`string'
 ntoskrnl.exe!NtSetEvent ntoskrnl.exe!KiSystemServiceCopyEnd
 wow64cpu.dll!CpupSyscallStub wow64cpu.dll!Thunk0Arg
 wow64.dll!RunCpuSimulation wow64.dll!Wow64LdrpInitialize ntdll.dll! ??
 ?? ::FNODOBFM::`string' ntdll.dll!LdrInitializeThunk
 ntdll.dll!_ZwSetEvent@8 kernelbase.dll!_SetEvent@4
 clr.dll!CLREvent::Set clr.dll!WKS::gc_heap::try_allocate_more_space
 clr.dll!WKS::gc_heap::allocate_more_space clr.dll!WKS::GCHeap::Alloc
 clr.dll!Alloc clr.dll!FastAllocatePrimitiveArray clr.dll!JIT_NewArr1
 mscorlib.ni.dll![mscorlib.dll] mscorlib.ni.dll![mscorlib.dll]
 mscorlib.ni.dll![mscorlib.dll] mscorlib.ni.dll![mscorlib.dll]
 !0x206b89 system.core.ni.dll![<Unknown>]
 system.core.ni.dll![<Unknown>] system.core.ni.dll![<Unknown>]

在此处输入图像描述

4

1 回答 1

1

没有完全回答您的确切问题,但我发现解决这些问题的最快方法是获取进程转储然后打开 windbg。

确定哪些线程正在阻塞的快速命令是 !syncblk,因此类似下面的内容应该有助于识别正在阻塞的方法调用

.load C:\Windows\Microsoft.NET\Framework64\v2.0.50727\sos

。链

!syncblk

于 2012-06-12T17:13:52.780 回答