2010-08-16 7 views
3

나는 C로 프로그램을 작성했으며 다른 프로세서 코어에서 실행되는 하나의 함수 만 원할뿐입니다.멀티 코어 프로세서의 스레드

다른 코어에 스레드를 배포하는 방법을 아는 사람이 있습니까? 하나의 코어에서 실행중인 단일 실행 스레드는 코어가 얼마나 사용 중인지에 따라 때로는 다른 코어도 활용할 수 있습니까?

+6

일종의 기계 번역을 통과 했습니까? – Hasturkun

답변

5

나는 친한 친구 설정 기능을 찾고 있다고 생각합니다.

Processor affinity is a modification of the native central queue scheduling 
algorithm in a symmetric multiprocessing operating system. Each task 
(be it process or thread) in the queue has a tag indicating its 
preferred/kin processor. At allocation time, each task is allocated to 
its kin processor in preference to others. 

this thread은 특정 스레드에 대한 선호도 설정 사용법을 설명합니다. 이 스레드에서 발췌 :

int sched_setaffinity(pid_t pid,size_t cpusetsize,cpu_set_t *mask); 

Passing 0 as the pid, and it'll apply to the current thread only, or have other 
thread report their kernel pid with the linux specific call pid_t gettid(void); 
and pass that in as the pid. 
2

난 당신이 스레드 멀티 프로세서 CPU에서 서로 다른 프로세서에서 실행되도록 배포합니까 방법을 요구하고있다 생각하십니까? 그렇다면, 내 이해는 이것이 운영 체제에 의해 제어되는 것입니다. 이 SO question을보세요.

+0

먼저 생각합니다. 그러나 나는 .NET과 parallet을 원하지 않지만 Linux와는 달리 api 또는 c Libary !!! – farka

관련 문제