<?xml version="1.0" encoding="UTF-8" ?>
<rss version="2.0">
<channel>
<title><![CDATA[向东博客 专注WEB应用 构架之美 --- 构架之美，在于尽态极妍 | 应用之美，在于药到病除]]></title> 
<link>http://jackxiang.com/index.php</link> 
<description><![CDATA[赢在IT，Playin' with IT,Focus on Killer Application,Marketing Meets Technology.]]></description> 
<language>zh-cn</language> 
<copyright><![CDATA[向东博客 专注WEB应用 构架之美 --- 构架之美，在于尽态极妍 | 应用之美，在于药到病除]]></copyright>
<item>
<link>http://jackxiang.com/post/4963/</link>
<title><![CDATA[[多核时代]linux查看多核负载（经典）]]></title> 
<author>jack &lt;xdy108@126.com&gt;</author>
<category><![CDATA[WEB2.0]]></category>
<pubDate>Wed, 08 Feb 2012 15:49:22 +0000</pubDate> 
<guid>http://jackxiang.com/post/4963/</guid> 
<description>
<![CDATA[ 
	1. Linux下，如何看每个CPU的使用率：<br/>#top -d 1<br/>之后按下数字1. 则显示多个CPU&nbsp;&nbsp; （top后按1也一样）<br/>Cpu0&nbsp;&nbsp;:&nbsp;&nbsp;1.0%us,&nbsp;&nbsp;3.0%sy,&nbsp;&nbsp;0.0%ni, 96.0%id,&nbsp;&nbsp;0.0%wa,&nbsp;&nbsp;0.0%hi,&nbsp;&nbsp;0.0%si,&nbsp;&nbsp;0.0%st<br/>Cpu1&nbsp;&nbsp;:&nbsp;&nbsp;0.0%us,&nbsp;&nbsp;0.0%sy,&nbsp;&nbsp;0.0%ni,100.0%id,&nbsp;&nbsp;0.0%wa,&nbsp;&nbsp;0.0%hi,&nbsp;&nbsp;0.0%si,&nbsp;&nbsp;0.0%st<br/> <br/>2. 在Linux下，如何确认是多核或多CPU:<br/>#cat /proc/cpuinfo<br/>如果有多个类似以下的项目，则为多核或多CPU:<br/>processor&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; : 0<br/>......<br/>processor&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; : 1<br/> <br/> <br/>3. 如何察看某个进程在哪个CPU上运行：<br/>#top -d 1<br/>之后按下f.进入top Current Fields设置页面：<br/>选中：j: P&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;= Last used cpu (SMP)<br/>则多了一项：P 显示此进程使用哪个CPU。<br/> <br/>Sam经过试验发现：同一个进程，在不同时刻，会使用不同CPU Core.这应该是Linux Kernel SMP处理的。<br/> <br/> <br/>4. 配置Linux Kernel使之支持多Core：<br/>内核配置期间必须启用 CONFIG_SMP 选项，以使内核感知 SMP。<br/>Processor type and features&nbsp;&nbsp;---&gt; Symmetric multi-processing support<br/> <br/>察看当前Linux Kernel是否支持（或者使用）SMP<br/>#uname -a<br/> <br/>5. Kernel 2.6的SMP负载平衡：<br/>在 SMP 系统中创建任务时，这些任务都被放到一个给定的 CPU 运行队列中。通常来说，我们无法知道一个任务何时是短期存在的，何时需要长期运行。因此，最初任务到 CPU 的分配可能并不理想。<br/>为了在 CPU 之间维护任务负载的均衡，任务可以重新进行分发：将任务从负载重的 CPU 上移动到负载轻的 CPU 上。Linux 2.6 版本的调度器使用负载均衡（load balancing） 提供了这种功能。每隔 200ms，处理器都会检查 CPU 的负载是否不均衡；如果不均衡，处理器就会在 CPU 之间进行一次任务均衡操作。<br/>这个过程的一点负面影响是新 CPU 的缓存对于迁移过来的任务来说是冷的（需要将数据读入缓存中）。<br/> <br/>记住 CPU 缓存是一个本地（片上）内存，提供了比系统内存更快的访问能力。如果一个任务是在某个 CPU 上执行的，与这个任务有关的数据都会被放到这个 CPU 的本地缓存中，这就称为热的。如果对于某个任务来说，CPU 的本地缓存中没有任何数据，那么这个缓存就称为冷的。<br/> <br/>不幸的是，保持 CPU 繁忙会出现 CPU 缓存对于迁移过来的任务为冷的情况。<br/> <br/> <br/>6. 应用程序如何利用多Core :<br/>开发人员可将可并行的代码写入线程，而这些线程会被SMP操作系统安排并发运行。<br/>另外，Sam设想，对于必须顺序执行的代码。可以将其分为多个节点，每个节点为一个thread.并在节点间放置channel.节点间形如流水线。这样也可以大大增强CPU利用率。<br/> <br/>例如：<br/>游戏可以分为3个节点。<br/>1.接受外部信息，声称数据 （1ms）<br/>2.利用数据，物理运算（3ms）<br/>3.将物理运算的结果展示出来。(2ms)<br/>如果线性编程，整个流程需要6ms.<br/>但如果将每个节点作为一个thread。但thread间又同步执行。则整个流程只需要3ms.<br/><br/>来自：<br/>http://blog.csdn.net/zhangxinrun/article/details/6708399
]]>
</description>
</item><item>
<link>http://jackxiang.com/post/4963/#blogcomment63420</link>
<title><![CDATA[[评论] [多核时代]linux查看多核负载（经典）]]></title> 
<author>hxngb4pf &lt;wdrs47@mail114.net&gt;</author>
<category><![CDATA[评论]]></category>
<pubDate>Thu, 09 Feb 2012 17:06:35 +0000</pubDate> 
<guid>http://jackxiang.com/post/4963/#blogcomment63420</guid> 
<description>
<![CDATA[ 
	辛苦了，祝大家新春快乐
]]>
</description>
</item><item>
<link>http://jackxiang.com/post/4963/#blogcomment63441</link>
<title><![CDATA[[评论] [多核时代]linux查看多核负载（经典）]]></title> 
<author>pengruncs511 &lt;chuangkhpwnknl21@tom.com&gt;</author>
<category><![CDATA[评论]]></category>
<pubDate>Thu, 16 Feb 2012 17:53:35 +0000</pubDate> 
<guid>http://jackxiang.com/post/4963/#blogcomment63441</guid> 
<description>
<![CDATA[ 
	吃着糖在嘴里的感觉真好
]]>
</description>
</item><item>
<link>http://jackxiang.com/post/4963/#blogcomment63444</link>
<title><![CDATA[[评论] [多核时代]linux查看多核负载（经典）]]></title> 
<author>hxngb5af &lt;aavc92@mail114.net&gt;</author>
<category><![CDATA[评论]]></category>
<pubDate>Thu, 16 Feb 2012 18:02:51 +0000</pubDate> 
<guid>http://jackxiang.com/post/4963/#blogcomment63444</guid> 
<description>
<![CDATA[ 
	参考参考，我认为很好，大家说说
]]>
</description>
</item><item>
<link>http://jackxiang.com/post/4963/#blogcomment63463</link>
<title><![CDATA[[评论] [多核时代]linux查看多核负载（经典）]]></title> 
<author>hxngb9if &lt;yksv59@mail114.net&gt;</author>
<category><![CDATA[评论]]></category>
<pubDate>Sat, 18 Feb 2012 18:11:00 +0000</pubDate> 
<guid>http://jackxiang.com/post/4963/#blogcomment63463</guid> 
<description>
<![CDATA[ 
	谢谢楼主的共享，我同意楼主的看法
]]>
</description>
</item><item>
<link>http://jackxiang.com/post/4963/#blogcomment63474</link>
<title><![CDATA[[评论] [多核时代]linux查看多核负载（经典）]]></title> 
<author>wobuzhidaop &lt;yavn25@mail114.net&gt;</author>
<category><![CDATA[评论]]></category>
<pubDate>Sat, 18 Feb 2012 22:23:40 +0000</pubDate> 
<guid>http://jackxiang.com/post/4963/#blogcomment63474</guid> 
<description>
<![CDATA[ 
	这里有木有大侠？有木有？
]]>
</description>
</item><item>
<link>http://jackxiang.com/post/4963/#blogcomment63536</link>
<title><![CDATA[[评论] [多核时代]linux查看多核负载（经典）]]></title> 
<author>hxngb3tf &lt;nbnt62@mail114.net&gt;</author>
<category><![CDATA[评论]]></category>
<pubDate>Mon, 20 Feb 2012 17:58:23 +0000</pubDate> 
<guid>http://jackxiang.com/post/4963/#blogcomment63536</guid> 
<description>
<![CDATA[ 
	楼主说得好，支持一下
]]>
</description>
</item><item>
<link>http://jackxiang.com/post/4963/#blogcomment63604</link>
<title><![CDATA[[评论] [多核时代]linux查看多核负载（经典）]]></title> 
<author>hxngb5bf &lt;rvsi08@mail114.net&gt;</author>
<category><![CDATA[评论]]></category>
<pubDate>Wed, 22 Feb 2012 17:10:36 +0000</pubDate> 
<guid>http://jackxiang.com/post/4963/#blogcomment63604</guid> 
<description>
<![CDATA[ 
	谢谢楼主的共享，我同意楼主的看法
]]>
</description>
</item>
</channel>
</rss>