1. Trace pattern
1."Signal Catcher" daemon prio=5 tid=3 Runnable
2. | group="system" sCount=0 dsCount=0 obj=0x32c050d0 self=0x7f97dd1400
3. | sysTid=9729 nice=0 cgrp=default sched=0/0 handle=0x7fa200e450
4. | state=R schedstat=( 217991249 1074429 82 ) utm=15 stm=6 core=4 HZ=100
5. | stack=0x7fa1f14000-0x7fa1f16000 stackSize=1005KB
6. | held mutexes= "mutator lock"(shared held)
2. 解释
第1行:
“Signal Catcher”:线程名称,daemon:是否是daemon线程(如果不是,则不打印“daemon”),prio=5:java线程Thread对象中的优先级,tid=3:vm中对应的 threadid,Runnable:线程在虚拟机中的状态;(如果当前线程没有attach,则第一行显示: “name” prio=num (not attached));
第2行:
group: ThreadGroup,sCount: Suspend count, dsCount: debugger suspend count(小于等于sCount),obj:对应java线程 java.lang.Thread对象,self:native 对应的 thread 指针;
第3行:
sysTid:对应linux线程 tid, nice:线程调度执行优先级,cgrp: cgroup,cpu调度group,sched:调度策略和调度优先级,handle:当前线程对应的pthread_t
第4行:
state:linux线程的状态,schedstat:线程调度情况,utm=15:线程在用户态运行的时间, stm=6:线程在内核态运行的时间, core=4:线程最后运行在哪个cpu上, HZ=100:系统时钟频率
state=R 任务的状态,R:running, S:sleeping (TASK_INTERRUPTIBLE), D:disk sleep (TASK_UNINTERRUPTIBLE), T: stopped, T:tracing stop,Z:zombie, X:dead
第5行:
stack=0x7fa1f14000-0x7fa1f16000 stackSize=1005KB
线程栈的start 和 end,以及 stack size;
第6行:
held mutexes= “mutator lock”(shared held)
线程持有的当前虚拟机中的mutex的名称,及持有方式:shared held: 共享锁,exclusive held:独占锁;
每个线程在完成suspend时,都会把 “mutator lock”释放;
实际上,Suspend所有线程时,判断是否suspend完成,就是通过获取"mutator lock"独占锁来判断的,
如果能获取独占锁,说明其他线程都不再 独占/共享 持有 “mutator lock” ,说明所有线程suspend已经完成。
3. 关键词对照
关键词 | 解释 |
---|---|
prio | 优先级 |
tid | 线程id |
group | 组名 |
sCount | 挂起次数 |
dsCount | 调试下 挂起计数 |
obj | 同辈线程对象 |
self | 当前线程对象 |
sysTid | 线程id |
nice | 进程优先级 |
sched | 调度者优先级 |
cgrp | 调度者组名 |
handle | 线程缓存句柄 |
state | native线程状态 |
schedstat | 调度者状态 |
utm | 用户态CPU时间 |
stm | 内核态CPU时间 |
core | 运行所在核 |
参考