private void OnThreadCSwitch(CSwitchTraceData data) { // Start blocking on the old thread. // Ignore the idle thread. if (data.OldThreadID != 0) { TraceThread oldThread = m_Configuration.TraceLog.Threads.GetThread(data.OldThreadID, data.TimeStampRelativeMSec); if (null != oldThread) { ComputingResourceThreadState oldThreadState = m_ThreadState[(int)oldThread.ThreadIndex]; oldThreadState.LogBlockingStart(this, oldThread, data); } } // Stop blocking on the new thread. // Ignore the idle thread. if (data.ThreadID != 0) { TraceThread newThread = data.Thread(); if (null != newThread) { ComputingResourceThreadState newThreadState = m_ThreadState[(int)newThread.ThreadIndex]; newThreadState.LogBlockingStop(this, newThread, data); } } }
public ComputingResourceStateMachine(MutableTraceEventStackSource outputStackSource, ScenarioConfiguration configuration, ComputingResourceViewType viewType) { m_OutputStackSource = outputStackSource; m_Sample = new StackSourceSample(outputStackSource); m_Configuration = configuration; m_ViewType = viewType; m_ThreadState = new ComputingResourceThreadState[configuration.TraceLog.Threads.Count]; for (int i = 0; i < m_ThreadState.Length; ++i) { m_ThreadState[i] = new ComputingResourceThreadState(i); } }
// callbacks for pariticular ETW events private void OnCpuSample(SampledProfileTraceData data) { TraceThread thread = data.Thread(); Debug.Assert(thread != null); if (null == thread) { return; } // Log the CPU sample. ComputingResourceThreadState threadState = m_ThreadState[(int)thread.ThreadIndex]; threadState.LogCPUSample(this, thread, data); }
private void OnThreadEnd(ThreadTraceData data) { TraceThread thread = data.Thread(); Debug.Assert(thread != null); if (null == thread) { return; } // Get the thread state. ComputingResourceThreadState threadState = m_ThreadState[(int)thread.ThreadIndex]; // Mark the thread as dead. threadState.BlockTimeStartRelativeMSec = double.NegativeInfinity; }
private void OnThreadStart(ThreadTraceData data) { TraceThread thread = data.Thread(); Debug.Assert(thread != null); if (null == thread) { return; } // Get the thread state. ComputingResourceThreadState threadState = m_ThreadState[(int)thread.ThreadIndex]; // Mark that blocking has started. threadState.LogBlockingStart(this, thread, data); }