Chinaunix首页 | 论坛 | 博客
  • 博客访问: 341903
  • 博文数量: 89
  • 博客积分: 2919
  • 博客等级: 少校
  • 技术积分: 951
  • 用 户 组: 普通用户
  • 注册时间: 2006-05-23 11:51
个人简介

好懒,什么都没写

文章分类

全部博文(89)

文章存档

2012年(3)

2011年(17)

2007年(20)

2006年(49)

我的朋友

分类:

2006-05-23 12:00:20

solaris系统中获取cpu个数

/*Time-stamp: <2006-05-22 18:27:26 yechao>
 *author    :yechao
 *file name :getcpunum.c
 *description:get the phsical cpu number in the system
 *compile    :cc getcpunum.c
 *在SunOS 5.9  上成功编译并执行
 */
#include//#include
#include
#include
#include
#include

int main(int argc,char **argv)
{
    int n_cpunum = 0;
    processorid_t i;
    processorid_t cpuid_max;
    cpuid_max = sysconf(_SC_CPUID_MAX);
    printf("cpuid_max=%d\n",cpuid_max);
    for(i=0; i<=cpuid_max; i++)
    {
        if(p_online(i,P_STATUS)!=-1 )
        {
            n_cpunum++; 
            printf("processor %d present\n",i);
        }     
    }//End of for statement
    printf("Physical processor number is:%d\n",n_cpunum);
    return 0;
}//End of function main
/*
 */
阅读(1913) | 评论(0) | 转发(0) |
0

上一篇:没有了

下一篇:My emacs dotemacs file

给主人留下些什么吧!~~