Linux下多執行緒檢視工具(pstree、ps、pstack)
1. pstree
pstree以樹結構顯示程式
$ pstree -p work | grep ad
sshd(22669)---bash(22670)---ad_preprocess(4551)-+-{ad_preprocess}(4552)
|-{ad_preprocess}(4553)
|-{ad_preprocess}(4554)
|-{ad_preprocess}(4555)
|-{ad_preprocess}(4556)
`-{ad_preprocess}(4557)
work為工作使用者,-p為顯示pid,ad_preprocess共啟動了6個子執行緒,加上主執行緒共7個執行緒
2. ps -Lf
$ ps -Lf 4551 或ps -eLf |grep server
UID PID PPID LWP C NLWP STIME TTY STAT TIME CMD
work 4551 22670 4551 2 7 16:30 pts/2 Sl+ 0:02 ./ad_preprocess
work 4551 22670 4552 0 7 16:30 pts/2 Sl+ 0:00 ./ad_preprocess
work 4551 22670 4553 0 7 16:30 pts/2 Sl+ 0:00 ./ad_preprocess
work 4551 22670 4554 0 7 16:30 pts/2 Sl+ 0:00 ./ad_preprocess
work 4551 22670 4555 0 7 16:30 pts/2 Sl+ 0:00 ./ad_preprocess
work 4551 22670 4556 0 7 16:30 pts/2 Sl+ 0:00 ./ad_preprocess
work 4551 22670 4557 0 7 16:30 pts/2 Sl+ 0:00 ./ad_preprocess
程式共啟動了7個執行緒
3. pstack
pstack顯示每個程式的棧跟蹤
$ pstack 4551
Thread 7 (Thread 1084229984 (LWP 4552)):
#0 0x000000302afc63dc in epoll_wait () from /lib64/tls/libc.so.6
#1 0x00000000006f0730 in ub::EPollEx::poll ()
#2 0x00000000006f172a in ub::NetReactor::callback ()
#3 0x00000000006fbbbb in ub::UBTask::CALLBACK ()
#4 0x000000302b80610a in start_thread () from /lib64/tls/libpthread.so.0
#5 0x000000302afc6003 in clone () from /lib64/tls/libc.so.6
#6 0x0000000000000000 in ?? ()
Thread 6 (Thread 1094719840 (LWP 4553)):
#0 0x000000302afc63dc in epoll_wait () from /lib64/tls/libc.so.6
#1 0x00000000006f0730 in ub::EPollEx::poll ()
#2 0x00000000006f172a in ub::NetReactor::callback ()
#3 0x00000000006fbbbb in ub::UBTask::CALLBACK ()
#4 0x000000302b80610a in start_thread () from /lib64/tls/libpthread.so.0
#5 0x000000302afc6003 in clone () from /lib64/tls/libc.so.6
#6 0x0000000000000000 in ?? ()
Thread 5 (Thread 1105209696 (LWP 4554)):
#0 0x000000302b80baa5 in __nanosleep_nocancel ()
#1 0x000000000079e758 in comcm::ms_sleep ()
#2 0x00000000006c8581 in ub::UbClientManager::healthyCheck ()
#3 0x00000000006c8471 in ub::UbClientManager::start_healthy_check ()
#4 0x000000302b80610a in start_thread () from /lib64/tls/libpthread.so.0
#5 0x000000302afc6003 in clone () from /lib64/tls/libc.so.6
#6 0x0000000000000000 in ?? ()
Thread 4 (Thread 1115699552 (LWP 4555)):
#0 0x000000302b80baa5 in __nanosleep_nocancel ()
#1 0x0000000000482b0e in armor::armor_check_thread ()
#2 0x000000302b80610a in start_thread () from /lib64/tls/libpthread.so.0
#3 0x000000302afc6003 in clone () from /lib64/tls/libc.so.6
#4 0x0000000000000000 in ?? ()
Thread 3 (Thread 1126189408 (LWP 4556)):
#0 0x000000302af8f1a5 in __nanosleep_nocancel () from /lib64/tls/libc.so.6
#1 0x000000302af8f010 in sleep () from /lib64/tls/libc.so.6
#2 0x000000000044c972 in Business_config_manager::run ()
#3 0x0000000000457b83 in Thread::run_thread ()
#4 0x000000302b80610a in start_thread () from /lib64/tls/libpthread.so.0
#5 0x000000302afc6003 in clone () from /lib64/tls/libc.so.6
#6 0x0000000000000000 in ?? ()
Thread 2 (Thread 1136679264 (LWP 4557)):
#0 0x000000302af8f1a5 in __nanosleep_nocancel () from /lib64/tls/libc.so.6
#1 0x000000302af8f010 in sleep () from /lib64/tls/libc.so.6
#2 0x00000000004524bb in Process_thread::sleep_period ()
#3 0x0000000000452641 in Process_thread::run ()
#4 0x0000000000457b83 in Thread::run_thread ()
#5 0x000000302b80610a in start_thread () from /lib64/tls/libpthread.so.0
#6 0x000000302afc6003 in clone () from /lib64/tls/libc.so.6
#7 0x0000000000000000 in ?? ()
Thread 1 (Thread 182894129792 (LWP 4551)):
#0 0x000000302af8f1a5 in __nanosleep_nocancel () from /lib64/tls/libc.so.6
#1 0x000000302af8f010 in sleep () from /lib64/tls/libc.so.6
#2 0x0000000000420d79 in Ad_preprocess::run ()
#3 0x0000000000450ad0 in main ()
UID為User ID.
PID為processid,程式識別符號
PPID為 parent processid,父程式識別符號2,
LWP為light weight process, or thread, 輕量級程式,即執行緒識別符號
NLWP為number of lwps(threads) in the process, 執行緒的數量
相關文章
- ftp多執行緒下載工具FTP執行緒
- linux 檢視 程式 執行緒數Linux執行緒
- windows下檢視oracle 執行緒 (session)WindowsOracle執行緒Session
- https多執行緒下載程式碼HTTP執行緒
- 多執行緒下載工具 NeatDownloadManager下載執行緒
- Linux中檢視程式的多執行緒Linux執行緒
- linux檢視是否開啟超執行緒Linux執行緒
- 強推!多執行緒下載工具 NeatDownloadManager執行緒
- 檢視執行緒所在模組執行緒
- linux 下檢視物理CPU,邏輯CPU,CPU core,超執行緒Linux執行緒
- 4、Linux多執行緒,執行緒同步(2)Linux執行緒
- Linux下的多執行緒程式設計Linux執行緒程式設計
- 自己開發的線上視訊下載工具,基於Java多執行緒Java執行緒
- 輕巧的執行緒堆疊檢視工具HotThreads執行緒thread
- linux-多執行緒Linux執行緒
- pstree
- 多執行緒下的list執行緒
- Greendao多執行緒下載執行緒
- IOS下使用多執行緒iOS執行緒
- .NET下多執行緒初探執行緒
- UNIX如何檢視執行緒執行情況執行緒
- Linux下的多執行緒程式設計(轉)Linux執行緒程式設計
- 多執行緒和多執行緒同步執行緒
- Linux c多執行緒執行順序Linux執行緒
- 多執行緒下的下載原理執行緒
- 超強Mac多執行緒下載工具 NeatDownloadManager MacMac執行緒
- 多執行緒【執行緒池】執行緒
- 多執行緒--執行緒管理執行緒
- Java多執行緒——執行緒Java執行緒
- 執行緒與多執行緒執行緒
- Linux多執行緒面試題Linux執行緒面試題
- Linux -c- 多執行緒Linux執行緒
- Linux多執行緒學習Linux執行緒
- 多執行緒下載檔案執行緒
- Java多執行緒下載分析Java執行緒
- 簡易多執行緒下載執行緒
- 多執行緒下的單例執行緒單例
- VC多執行緒 C++ 多執行緒執行緒C++