免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 3372 | 回复: 2
打印 上一主题 下一主题

多线程应用程序和双核多cpu环境,ps的cpu占用率问题 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2006-06-03 10:17 |只看该作者 |倒序浏览
ps和top显示两个程序的cpu专用率为什么不一样呢?这个跟双核cpu有关系么?以下是我具体操作的情况.


双核双cpu环境下,我写了个java的多线程应用程序,运行nohup ./start.sh &
start.sh内容为/usr/java/jdk1.5.0_04/bin/java -Xmx1024m -cp test.jar com.test.Test
ps该进程显示cpu专用率为39.9%
top该进程cpu 0为99.9%  

top显示如下:
CPU0 states: 100.0% user   0.0% system    0.0% nice   0.0% iowait   0.0% idle
CPU1 states: 00.0% user   0.4% system    0.0% nice   0.0% iowait   99.6% idle
CPU2 states: 0.0% user   0.0% system    0.0% nice   0.0% iowait   100.0% idle
CPU3 states: 0.0% user   0.0% system    0.0% nice   0.0% iowait  100.0% idle


  PID USER     PRI  NI  SIZE  RSS SHARE STAT %CPU %MEM   TIME CPU COMMAND
6157 root      23   0 30564  29M 10980 S      99.9      0.7     29:15   0     java


ps aux|grep java显示如下:
root      6157 39.9  0.7 1241844 30560 pts/1 S    08:47  32:06 /usr/java/jdk1.5.0_04/bin/java -Xmx1024m -cp test.jar com.test.Test

[ 本帖最后由 placidy 于 2006-6-3 10:46 编辑 ]

论坛徽章:
0
2 [报告]
发表于 2006-06-03 11:22 |只看该作者
top和ps表示的cpu占用率概念不一样。

http://www.die.net/doc/linux/man/man1/ps.1.html

CPU usage is currently expressed as the percentage of time spent running during the entire lifetime of a process. This is not ideal, and it does not conform to the standards that ps otherwise conforms to. CPU usage is unlikely to add up to exactly 100%.

论坛徽章:
0
3 [报告]
发表于 2006-06-03 11:27 |只看该作者
But with top command:
k: %CPU  --  CPU usage
          The task's share of the elapsed CPU time since the last screen update, expressed as a percentage of  total  CPU
          time
.   In  a  true  SMP  environment,  if  'Irix mode' is Off, top will operate in number of CPUs.  You toggle
          'Irix/Solaris' modes with the 'I' interactive command.
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP