gcc에서 core 갯수 알아오는 함수가 있을까요?

neodeath의 이미지

gcc에서 core 갯수 알아오는 함수를 알고 싶은데요..
도움 주시면 감사하겠습니다 ^^

bushi의 이미지

[bushi@rose kernel-2.6]$ 
[bushi@rose kernel-2.6]$ getconf _NPROCESSORS_ONLN
4
[bushi@rose kernel-2.6]$ 
[bushi@rose kernel-2.6]$ cat c.c
#include <stdio.h>
#include <unistd.h>
 
int main()
{
        return printf("online cpu: %ld\n", sysconf(_SC_NPROCESSORS_ONLN));
}
[bushi@rose kernel-2.6]$ 
[bushi@rose kernel-2.6]$ gcc -s -o c c.c -Wall
[bushi@rose kernel-2.6]$ 
[bushi@rose kernel-2.6]$ ./c
online cpu: 4
[bushi@rose kernel-2.6]$ 

man getconf
man sysconf
참고하시고, 이게 POSIX 인지 아닌지 아리송합니다.

어쨌든,

[bushi@rose kernel-2.6]$ cat /proc/cpuinfo | grep processor
processor       : 0
processor       : 1
processor       : 2
processor       : 3
[bushi@rose kernel-2.6]$

리눅스에서는 통합니다.

OTL

neodeath의 이미지

도움주셔서 정말 감사합니다 ^^

언제 고수되나.