在Linux中查找线程的CPU使用情况
I have a C based application running on linux, with around 30 threads. Now I need to write a small utility which finds the CPU usage of each thread at given time. It can be a separate or part of the application.
我有一个在Linux上运行的基于C的应用程序,有大约30个线程。现在我需要编写一个小实用程序,它在给定时间查找每个线程的CPU使用情况。它可以是应用程序的单独或部分。
One of the problem of /proc is finding which thread is what.
/ proc的问题之一是找到哪个线程是什么。
Please give me some ideas on how to start.
请给我一些如何开始的想法。
Thanks
1 个解决方案
#1
0
Though I am a naive in this field I think the below approach might work
虽然我在这个领域很天真,但我认为以下方法可行
1)maintain a updated list of new PID's that are getting created in your program in a shared memory segment ( My idea was to take help of IPC's )
1)维护在程序中在共享内存段中创建的新PID的更新列表(我的想法是获取IPC的帮助)
2) develop an application which is capable to access the previously created shared segment and fetch the PID's to check the corresponding utilization.
2)开发一个能够访问先前创建的共享段的应用程序并获取PID以检查相应的利用率。
更多相关文章
- 获取Android应用程序的Linux UID
- 线程同步-生产者消费者问题
- Linux多线程总结
- Linux多线程实践(一)线程基本概念和理论
- linux线程函数中代替sleep的方法
- 在Linux中的脚本中安装应用程序
- linux 多线程基础
- 如何发送一个字节(或字节)来测试在我的应用程序中监听的套接字?
- 〖Linux〗使用Qt5.2.0开发Android的NDK应用程序