简体   繁体   中英

How do I tell what a Linux process is waiting for?

I'm trying to track down the cause of performance bottlenecks in an application I'm debugging under Linux. The various processes involved seem to spend a lot of their time blocking on I/O requests, and I was wondering if anybody knew any Linux tricks that let you see why a particular process is blocked/what resource it's waiting for? Is there anything useful in /proc for instance?

Whatever process it is, you use top to check the state. Then you could run it through truss or strace . That should detail what is going on. If that is not possible, hook it up to gdb . Tools like iostat might show you in general what is going on (eg if disk is bottleneck).

You could use the strace command to see what your process is up to. You might also find it useful to run lsof on your process to see what files and sockets it is using.

strace是你的朋友,因为你可以花时间进入每个系统调用,另外你可以选择你感兴趣的文件描述符和系统调用。但你也可以从内核获得支持:看看latencytop

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM