免费注册 查看新帖 |

Chinaunix

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

双核cpu如何支持? [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2006-02-27 08:23 |只看该作者 |倒序浏览
请问诸位,现在这么多的发行版linux中,哪些版本是支持双核cpu的呢?

论坛徽章:
0
2 [报告]
发表于 2006-02-27 10:04 |只看该作者
RedHat AS3 update4

论坛徽章:
0
3 [报告]
发表于 2006-02-27 10:31 |只看该作者
首先內核一定要支持多cpu工作先...

论坛徽章:
0
4 [报告]
发表于 2006-02-27 11:27 |只看该作者
如果你的“双核”一词指SMT技术, 2.4就支持了, 2.6更好一些; 如果指SMP技术, 2.0以后就支持了。

论坛徽章:
0
5 [报告]
发表于 2006-02-27 21:29 |只看该作者
原帖由 albcamus 于 2006-2-27 11:27 发表
如果你的“双核”一词指SMT技术, 2.4就支持了, 2.6更好一些; 如果指SMP技术, 2.0以后就支持了。

请教 albcamus 兄,在 SMT 方面,2.4 和 2.6 的差别大吗?大概有多少?有这方面资料吗?

论坛徽章:
0
6 [报告]
发表于 2006-04-07 12:53 |只看该作者
相比本人最初发表此贴时的一窍不通,现在经过实践,多少对cpu算是有了点心得,在此不敢独享,现对多(双)核CPU平台下CPU的操作作一个总结:
#define  __USE_GNU
#include <sched.h>
#include <ctype.h>

sysconf(_SC_NPROCESSORS_CONF) 可以用来取得系统中CPU的个数,但无法区别超线程和双核,
在代码中可用
__asm__ __volatile__(                                                       
    "xor     %%eax,        %%eax      \n\t"
    "movl   $1,           %%eax      \n\t"
    "xor     %%ebx,   %%ebx      \n\t"
    "CPUID                            \n\t"
    "and $0x00ff0000,  %%ebx  \n\t"
    :"=b"(temp1)
    :);
    ebx_count = (temp1 >> 16);
通过判断ebx_count 的值是否大于1来决定是否为超线程
另外,由于系统使用了多核处理器(smp),所以你可以将你所要运行代码强制性的绑定在某一特定的核上(并不完全肯定,因为内核自身对cpu的调度可能会改变这一绑定,所以在此只能表达为尽可能长时间的绑定在某一CPU上),具体的执行是通过一下步骤来完成,
cpu_set_t mask;   //声明一个bit mask set,相当于select的fd_set
CPU_ZERO(&mask);  //清零
CPU_SET(thread_num, &mask); //将对应的cpu在掩码集中设置为1
sched_setaffinity( 0, sizeof(mask), &mask );
此函数不好描述,在此引用一段原话
/*  sched_setaffinity sets the CPU affinity mask of the process denoted by pid.
     If pid is zero, then the current process is used.

     The affinity mask is represented by the bitmask stored in mask. The least
     significant bit corresponds to the first logical processor number on the
     system, while the most significant bit corresponds to the last logical
     processor number on the system. A set bit corresponds to a legally schedulable
     CPU while an unset bit corresponds to an illegally schedulable CPU. In other
     words, a process is bound to and will only run on processors whose
     corresponding bit is set. Usually, all bits in the mask are set.
    Also the affinity is passed on to any children!                                  */
/*  Now we have a single thread bound to each cpu on the system */
cpu_set_t mycpuid;
同样,可以通过sched_getaffinity(0, sizeof(mycpuid), &mycpuid);来取得目前cpu设置的绑定情况(亲和性设定)。
好了,以上是本人通过一些实践之后对所使用的cpu了解,希望在此能够起到抛砖引玉的作用
本人试验的平台为 IBM x346,x336系列pc server

[[i] 本帖最后由 dragonII 于 2006-4-7 13:37 编辑 [/i]]
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

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

清除 Cookies - ChinaUnix - Archiver - WAP - TOP