From 9f463a1917a7fed72ac5e2bc0325a65667e7e59f Mon Sep 17 00:00:00 2001 From: Ingo Weinhold Date: Sat, 9 May 2009 16:09:57 +0000 Subject: [PATCH] * ThreadActivityData::GetSamples(): - When guessing the initial thread state for an unschedule event also check the previous event, so we can decide whether the thread is still ready. Previously the time to the first schedule event could be accounted incorrectly. - Made the main loop a bit more robust with respect to unexpected thread states. * The check boxes for latency and preemption time were labeled the wrong way around. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@30680 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- .../gui/thread_window/ActivityPage.cpp | 51 +++++++++++++------ 1 file changed, 36 insertions(+), 15 deletions(-) diff --git a/src/apps/debuganalyzer/gui/thread_window/ActivityPage.cpp b/src/apps/debuganalyzer/gui/thread_window/ActivityPage.cpp index c4f965d857..9f61a268f1 100644 --- a/src/apps/debuganalyzer/gui/thread_window/ActivityPage.cpp +++ b/src/apps/debuganalyzer/gui/thread_window/ActivityPage.cpp @@ -99,10 +99,23 @@ public: { system_profiler_thread_scheduled* event = (system_profiler_thread_scheduled*)(header + 1); - if (event->thread == threadID) + if (event->thread == threadID) { + // thread scheduled -- it must have been ready before state = READY; - else - state = RUNNING; + } else { + // thread unscheduled -- it was running earlier, but should + // now be "still running" or "running", depending on whether + // it had been added to the run queue before + const system_profiler_event_header* previousHeader + = fModel->SchedulingEventAt(startIndex - 1); + if (previousHeader != NULL + && previousHeader->event + == B_SYSTEM_PROFILER_THREAD_ENQUEUED_IN_RUN_QUEUE) { + state = STILL_RUNNING; + } else + state = RUNNING; + } + previousEventTime = event->time; break; } @@ -154,27 +167,33 @@ public: // thread scheduled after having been preempted // before timeType = PREEMPTION_TIME; + } else if (state == STILL_RUNNING) { + // Thread was running and continues to run. + timeType = RUN_TIME; + } else { + // Can only happen, if we're missing context. + // Impossible to guess what the thread was doing + // before. + timeType = UNSPECIFIED_TIME; } - if (state == STILL_RUNNING) { - // Thread was running and continues to run. - state = RUNNING; - timeType = RUN_TIME; - } else if (state != RUNNING) { - state = RUNNING; - } + state = RUNNING; } else { // thread unscheduled if (state == STILL_RUNNING) { // thread preempted state = PREEMPTED; - timeType = RUN_TIME; } else if (state == RUNNING) { // thread starts waiting (it hadn't been added // to the run queue before being unscheduled) state = WAITING; - timeType = RUN_TIME; + } else { + // Can only happen, if we're missing context. + // Obviously the thread was running, but we + // can't guess the new thread state. } + + timeType = RUN_TIME; } break; @@ -248,9 +267,11 @@ public: timeType = LATENCY_TIME; break; case WAITING: - case UNKNOWN: timeType = WAIT_TIME; break; + case UNKNOWN: + timeType = UNSPECIFIED_TIME; + break; } if (fModel->GetThread()->DeletionTime() >= 0) { @@ -336,11 +357,11 @@ ThreadWindow::ActivityPage::ActivityPage() .Add(fWaitTimeCheckBox = new ColorCheckBox("Wait Time", kWaitTimeColor, new BMessage(MSG_CHECK_BOX_WAIT_TIME)), 1, 0) - .Add(fPreemptionTimeCheckBox = new ColorCheckBox("Latency Time", + .Add(fPreemptionTimeCheckBox = new ColorCheckBox("Preemption Time", kPreemptionTimeColor, new BMessage(MSG_CHECK_BOX_PREEMPTION_TIME)), 0, 1) - .Add(fLatencyTimeCheckBox = new ColorCheckBox("Preemption Time", + .Add(fLatencyTimeCheckBox = new ColorCheckBox("Latency Time", kLatencyTimeColor, new BMessage(MSG_CHECK_BOX_LATENCY_TIME)), 1, 1)