linuxÏß³ÌÔõôÉó²é
linux ÌṩÁ˶àÖÖÉó²éÏ̵߳ÄÒªÁ죺1. ʹÓà ps -efl ÏÂÁîÉó²é pid ºÍÏß³Ì״̬£»2. ʹÓà top ÏÂÁî°´Ï “h” ºÍ “t” ¼üÉó²é cpu ʹÓÃÂÊ£»3. ʹÓà pstree -p ÏÂÁîÏÔʾÀú³ÌºÍÏß³ÌÌõÀí½á¹¹£»4. µ¼º½µ½ /proc/[pid]/task Ŀ¼Éó²éÏß³ÌÐÅÏ¢£»5. ʹÓà gdb µ÷ÊÔÆ÷ºÍ “info threads” ÏÂÁ6. ʹÓà perf ÆÊÎöÆ÷ºÍ “top -p [pid]” ÏÂÁîÉó²é cpu ʹÓÃÂÊ¡£
ÔõÑùÉó²é Linux Ïß³Ì
Linux ÌṩÁ˶àÖÖÒªÁìÀ´Éó²éϵͳÖеÄÏ̡߳£ÒÔÏÂÊÇһЩ×î³£ÓõÄÒªÁ죺
1. ʹÓà ps ÏÂÁî
ps ÏÂÁî¿ÉÒÔÏÔʾÕýÔÚÔËÐеÄÀú³ÌºÍÏ̵߳ÄÐÅÏ¢£¬°üÀ¨ËüÃÇµÄ PID¡¢Ïß³Ì ID¡¢Ïß³Ì״̬ºÍÏÂÁîÃû³Æ¡£ÒªÉó²éËùÓÐỊ̈߳¬¿ÉÒÔʹÓÃÒÔÏÂÏÂÁ
ps -efL
µÇ¼ºó¸´ÖÆ
2. ʹÓà top ÏÂÁî
top ÏÂÁî¿ÉÒÔʵʱÏÔʾϵͳµÄÐÔÄÜÐÅÏ¢£¬°üÀ¨Ïß³ÌÔ˶¯¡£ÒªÉó²éỊ̈߳¬Çë°´ “H” ¼ü£¬È»ºó°´ “t” ¼üÅÅÐò¡£Õ⽫ÏÔʾÿ¸öÏß³ÌµÄ CPU ʹÓÃÂÊ¡¢ÄÚ´æʹÓÃÂʺÍ״̬¡£
3. ʹÓà pstree ÏÂÁî
pstree ÏÂÁî¿ÉÒÔÒÔÊ÷×´½á¹¹ÏÔʾÀú³ÌºÍÏ̵߳ÄÌõÀí¹Øϵ¡£ÒªÉó²éËùÓÐỊ̈߳¬¿ÉÒÔʹÓÃÒÔÏÂÏÂÁ
pstree -p
µÇ¼ºó¸´ÖÆ
4. ʹÓà proc Îļþϵͳ
proc Îļþϵͳ°üÀ¨ÓйØϵͳÖÐÀú³ÌºÍÏß³ÌÐÅÏ¢¡£ÒªÉó²éỊ̈߳¬¿ÉÒÔµ¼º½µ½ /proc/[pid]/task Ŀ¼£¬ÆäÖÐ [pid] ÊÇÀú³ÌµÄÀú³Ì ID¡£¸ÃĿ¼°üÀ¨ÓйØÿ¸öÏ̵߳ÄÐÅÏ¢£¬°üÀ¨Æä״̬ºÍÕ»¡£
5. ʹÓà gdb µ÷ÊÔÆ÷
gdb µ÷ÊÔÆ÷¿ÉÒÔÓÃÀ´µ÷ÊÔÕýÔÚÔËÐеÄÀú³Ì¡£ÒªÉó²éỊ̈߳¬¿ÉÒÔʹÓÃÒÔÏÂÏÂÁ
gdb [pid]
µÇ¼ºó¸´ÖÆ
È»ºóʹÓÃÒÔÏÂÏÂÁ
info threads
µÇ¼ºó¸´ÖÆ
6. ʹÓà perf ÆÊÎöÆ÷
perf ÆÊÎöÆ÷¿ÉÒÔÓÃÀ´ÆÊÎöϵͳµÄÐÔÄÜ¡£ÒªÉó²éỊ̈߳¬¿ÉÒÔʹÓÃÒÔÏÂÏÂÁ
perf top -p [pid]
µÇ¼ºó¸´ÖÆ
Õ⽫ÏÔʾÿ¸öÏß³ÌµÄ CPU ʹÓÃÂÊ¡£
×¢ÖØ£ºÆ¾Ö¤ÄúµÄ Linux ¿¯Ðа棬һЩÏÂÁî¿ÉÄÜÐèҪʹÓà sudo ȨÏ޲ŻªÔËÐС£
ÒÔÉϾÍÊÇlinuxÏß³ÌÔõôÉó²éµÄÏêϸÄÚÈÝ£¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡