[Windbg] Wait Start TickCount, Ticks, KeTickCount

DeadLock 또는 Spiking Thread 등을 분석할 때 Wait Start TickCount, Ticks 등의 정보가 굉장히 유용하게 활용되곤 합니다.  각각의 정보에 대해 간단히 적어보도록 하곘습니다.

1: kd> !thread 8a362da8
THREAD 8a362da8  Cid 0004.0010  Teb: 00000000 Win32Thread: 00000000 WAIT: (WrQueue) UserMode Non-Alertable
8056c5c0  Unknown
Not impersonating
DeviceMap                 e10021a8
Owning Process            8a363830       Image:         System
Attached Process          N/A            Image:         N/A
Wait Start TickCount      87697 Ticks: 34 (0:00:00:00.531)
Context Switch Count      20714
UserTime                  00:00:00.000
KernelTime                00:00:00.203
Start Address nt!ExpWorkerThread (0×804e4311)
Stack Init f78bb000 Current f78bad24 Base f78bb000 Limit f78b8000 Call 0
Priority 13 BasePriority 13 PriorityDecrement 0 DecrementCount 16


ChildEBP RetAddr  Args to Child
f78bad3c 804e3bf2 8a362e18 8a362da8 804e42f6 nt!KiSwapContext+0×2f (FPO: [Uses EBP] [0,0,4])
f78bad48 804e42f6 8a358ac8 8056c5c0 8a362da8 nt!KiSwapThread+0×8a (FPO: [0,0,0])
f78bad74 804e43ae 00000001 00000001 00000000 nt!KeRemoveQueue+0×22a (FPO: [3,6,4])
f78badac 80577723 8a358ac8 00000000 00000000 nt!ExpWorkerThread+0xcc (FPO: [1,6,0])
f78baddc 804ee6f9 804e4311 00000000 00000000 nt!PspSystemThreadStartup+0×34 (FPO: [Non-Fpo])
00000000 00000000 00000000 00000000 00000000 nt!KiThreadStartup+0×16

간단한 Worker Thread를 하나 예로 들어 보죠 .

Wait Start TickCount는 실제로 이 Thread가 “Wait 되기 시작한 시점”을 말해줍니다. ( 착각하기 쉬운건 전체 Wait Time이 아닙니다. ) 측 TickCount 가 87697인 시점 부터 Wait 되기 시작했다는 의미 입니다.  그 옆에 Ticks가 보이죠. Ticks는 이 “Thread가 Wait 되어 있던 시간”을 의미합니다.

그럼 Ticks = KeTickCount( 현재 TickCount ) - Wait Start TickCount 라는 공식이 성립하게 됩니다.

1: kd> dd KeTickCount L1
8055c000  000156b3

1: kd> .formats 000156b3
Evaluate expression:
Hex:     000156b3
Decimal: 87731
Octal:   00000253263
Binary:  00000000 00000001 01010110 10110011
Chars:   ..V.
Time:    Fri Jan 02 09:22:11 1970
Float:   low 1.22937e-040 high 0
Double:  4.33449e-319

주의 : Wait Start TickCount와 Ticks는 10진수로 나타나기 때문에 KeTickCount는 10진수로 변환 후 계산해야합니다
88731 - 87697 = 34 라는 게 정확히 성립되는걸 볼 수 있습니다. Ticks의 옆에 시간이 정확한지 여부를 판단하기 위해서 Ticks의 값을 16진수 ( 0×22 ) 로 바꿔서 !whattime Extension을 수행해 보겠습니다.
1: kd> !whattime 0×22
34 Ticks in Standard Time: 00.531s

값이 정확히 맞아 떨어지는 것을 확인 할 수있습니다.

Wait Time과 관련된 정보는 특히 동기화 Object 과련 Dead Lock , WorkQueue 관련 Dead Lock 과 같은 형태의 Memory Dump를 분석 할때 굉장히 유용하게 사용됩니다. 기회가 된다면 꼭 활용해 보시길..

Enjoy Debugging!!

Share and Enjoy:
  • Digg
  • Google
  • TwitThis

0 Responses to “[Windbg] Wait Start TickCount, Ticks, KeTickCount”


  1. No Comments

Leave a Reply