From 7102ac77698f4bfd7406d6e8871db7b006c2cae2 Mon Sep 17 00:00:00 2001 From: Tedd Hansen Date: Thu, 21 Feb 2008 10:43:24 +0000 Subject: "threads" command now works. I've added manual tracking of threads (only if compiled in DEBUG mode)... Its ugly and even requires a separate thread to track the treads, but it will be very valuable in debugging. --- OpenSim/Region/Application/OpenSimMain.cs | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) (limited to 'OpenSim/Region/Application') diff --git a/OpenSim/Region/Application/OpenSimMain.cs b/OpenSim/Region/Application/OpenSimMain.cs index fc739d9..59f7c63 100644 --- a/OpenSim/Region/Application/OpenSimMain.cs +++ b/OpenSim/Region/Application/OpenSimMain.cs @@ -754,15 +754,30 @@ namespace OpenSim break; case "threads": - m_console.Notice("THREAD", Process.GetCurrentProcess().Threads.Count + " threads running:"); - int _tc = 0; + //m_console.Notice("THREAD", Process.GetCurrentProcess().Threads.Count + " threads running:"); + //int _tc = 0; - foreach (ProcessThread pt in Process.GetCurrentProcess().Threads) + //foreach (ProcessThread pt in Process.GetCurrentProcess().Threads) + //{ + // _tc++; + // m_console.Notice("THREAD", _tc + ": ID: " + pt.Id + ", Started: " + pt.StartTime.ToString() + ", CPU time: " + pt.TotalProcessorTime + ", Pri: " + pt.BasePriority.ToString() + ", State: " + pt.ThreadState.ToString()); + + //} + List threads = OpenSim.Framework.ThreadTracker.GetThreads(); + if (threads == null) + { + m_console.Notice("THREAD", "Thread tracking is only enabled in DEBUG mode."); + } + else + { + int _tc = 0; + m_console.Notice("THREAD", threads.Count + " threads are being tracked:"); + foreach (Thread t in threads) { _tc++; - m_console.Notice("THREAD", _tc + ": ID: " + pt.Id + ", Started: " + pt.StartTime.ToString() + ", CPU time: " + pt.TotalProcessorTime + ", Pri: " + pt.BasePriority.ToString() + ", State: " + pt.ThreadState.ToString()); - + m_console.Notice("THREAD", _tc + ": ID: " + t.ManagedThreadId.ToString() + ", Name: " + t.Name + ", Alive: " + t.IsAlive.ToString() + ", Pri: " + t.Priority.ToString() + ", State: " + t.ThreadState.ToString()); } + } break; -- cgit v1.1