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以检查相应的利用率。

更多相关文章

  1. 获取Android应用程序的Linux UID
  2. 线程同步-生产者消费者问题
  3. Linux多线程总结
  4. Linux多线程实践(一)线程基本概念和理论
  5. linux线程函数中代替sleep的方法
  6. 在Linux中的脚本中安装应用程序
  7. linux 多线程基础
  8. 如何发送一个字节(或字节)来测试在我的应用程序中监听的套接字?
  9. 〖Linux〗使用Qt5.2.0开发Android的NDK应用程序

随机推荐

  1. android启动界面
  2. Qt For Android(安卓)文件存储
  3. Android圆环控件
  4. Google 将 Android 4.0.4 源代码送交 AOS
  5. Android消息机制(native层)
  6. Android LinearLayout的android:layout_w
  7. Android布局文件的属性值解析
  8. android日志分析与记录.
  9. Android(安卓)控件之Gallery图片集
  10. Android 文件的保存与读取之自带储存空间