특정 core에서 thread를 동작시키고 싶습니다.

astzlra955의 이미지

안녕하세요.

제가 test를 위해서 특정 core에서 thread를 실행히켜야 할 일이 있습니다.
그래서 찾아보고 있는 중,

int pthread_setaffinity_np(pthread_t th,size_t size,const cpu_set_t *cpuset);
int pthread_getaffinity_np(pthread_t th,size_t size,cpu_set_t *cpuset);
int pthread_attr_setaffinity_np(pthread_attr_t *at,size_t size,const cpu_set_t *cpuset);
int pthread_attr_getaffinity_np(pthread_attr_t *at,size_t size,cpu_set_t *cpuset);

이런 함수가 있다고 들었는데, 제가 사용하는 kernel에는 위 함수가 존재하지 않더군요.

kernel 버전은 3.1.10 입니다.

위 방법 말고 다른 방법으로 특정 core에서 thread를 실행시킬 수 있는 방법을 알려주시면 감사하겠습니다.

cinsk의 이미지

#define _GNU_SOURCE
#include <pthread.h>
...

익명 사용자의 이미지

그리고, 맨페이지에 따르면, compile and link with -pthread 네요.
http://man7.org/linux/man-pages/man3/pthread_setaffinity_np.3.html