Identify thread waittime in the user mode process dump

Hi All,

How can I identify the total wait time of a thread that is waiting on something from the user mode process dump file. From the kernel mode dump file we can use !thread to check the waitstart tick count but there is no equivalent for the user mode dump. The .ttime command shows only the kernel and user times but not the wait time.

Any idea how can I see the wait time from the user mode dump file?

Thanks

I’m guessing you’re using WinDbg.
Dump the _KTHREAD structure, look near the end to find the offsets of both ‘UserWaitTime’ and ‘KernelWaitTime’.
From there, you can manually read the wait time for both contexts, of the thread you’re targeting.

Thanks for the reply.

I got user mode threads id as well as the thread stacks from the dump file using “~” command . How can I get the address of the KTHREAD structure for the particular thread so that I can dump its structure to see the waittime.

AFAIK that number isn’t available in user mode. All you get for times are user, kernel, and start (see !runaway).

1 Like

If you have a repeatable problem, you add some instrumentation to the code to keep track of this, then recreate the problem. Make sure that you store the value in something like a volatile global so that the compiler does not elide or re-order the write in optimized builds

If you have only a crash dump from an incident that you can’t reproduce, then you look for inferential information - usually higher up in the call stack. Sequence numbers, timestamps and counters are often helpful, but it requires a detailed knowledge of what the specific program does to make much sense of this kind of information.

But more to the point, why do you care? I don’t think that I have ever used knowledge of the duration of a wait to successfully diagnose a live lock or dead lock problem. Usually crash dumps are helpful in identifying the presence of these kinds of bugs, but usually nothing but the involved stacks are helpful in resolving them. Detailed review of the lock hierarchy is almost always the solution in my experience. Which makes it even more of a shame that MS badly broke the SAL annotations when restructuring their compiler. In my shop we still add them to document the assumptions made in the code - even if the automated tools fail to consider them properly