/*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 /* */